Makefile 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407
  1. # Makefile for uClibc
  2. #
  3. # Copyright (C) 2000-2003 Erik Andersen <andersen@uclibc.org>
  4. #
  5. # This program is free software; you can redistribute it and/or
  6. # modify it under the terms of the GNU Library General Public
  7. # License as published by the Free Software Foundation; either
  8. # version 2 of the License, or (at your option) any later
  9. # version.
  10. #
  11. # This program is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU Library General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU Library General
  17. # Public License along with this program; if not, write to the
  18. # Free Software Foundation, Inc., 59 Temple Place, Suite 330,
  19. # Boston, MA 02111-1307 USA
  20. #--------------------------------------------------------------
  21. # You shouldn't need to mess with anything beyond this point...
  22. #--------------------------------------------------------------
  23. noconfig_targets := menuconfig config oldconfig randconfig \
  24. defconfig allyesconfig allnoconfig clean distclean \
  25. release tags TAGS
  26. TOPDIR=./
  27. include Rules.mak
  28. DIRS = extra ldso libc libcrypt libresolv libnsl libutil libm libpthread libintl
  29. ifeq ($(strip $(HAVE_DOT_CONFIG)),y)
  30. all: headers subdirs shared utils finished
  31. # In this section, we need .config
  32. -include .config.cmd
  33. .PHONY: $(SHARED_TARGET)
  34. shared: $(SHARED_TARGET)
  35. ifeq ($(strip $(HAVE_SHARED)),y)
  36. @$(MAKE) -C libc shared
  37. @$(MAKE) -C ldso shared
  38. @$(MAKE) -C libcrypt shared
  39. @$(MAKE) -C libresolv shared
  40. @$(MAKE) -C libnsl shared
  41. @$(MAKE) -C libutil shared
  42. @$(MAKE) -C libm shared
  43. @$(MAKE) -C libpthread shared
  44. @$(MAKE) -C libintl shared
  45. else
  46. ifeq ($(SHARED_TARGET),)
  47. @echo
  48. @echo Not building shared libraries...
  49. @echo
  50. endif
  51. endif
  52. ifneq ($(SHARED_TARGET),)
  53. lib/main.o: $(ROOTDIR)/lib/libc/main.c
  54. $(CC) $(CFLAGS) $(ARCH_CFLAGS) -c -o $@ $(ROOTDIR)/lib/libc/main.c
  55. bogus $(SHARED_TARGET): lib/libc.a lib/main.o Makefile
  56. make -C $(ROOTDIR) relink
  57. $(CC) -nostartfiles -o $(SHARED_TARGET) $(ARCH_CFLAGS) -Wl,-elf2flt -nostdlib \
  58. -Wl,-shared-lib-id,${LIBID} \
  59. lib/main.o \
  60. -Wl,--whole-archive,lib/libc.a,-lgcc,--no-whole-archive
  61. $(OBJCOPY) -L _GLOBAL_OFFSET_TABLE_ -L main -L __main -L _start \
  62. -L __uClibc_main -L __uClibc_start_main -L lib_main \
  63. -L _exit_dummy_ref \
  64. -L __do_global_dtors -L __do_global_ctors \
  65. -L __CTOR_LIST__ -L __DTOR_LIST__ \
  66. -L _current_shared_library_a5_offset_ \
  67. $(SHARED_TARGET).gdb
  68. ln -sf $(SHARED_TARGET).gdb .
  69. endif
  70. finished: shared
  71. @echo
  72. @echo Finally finished compiling...
  73. @echo
  74. #
  75. # Target for uClinux distro
  76. #
  77. .PHONY: romfs
  78. romfs:
  79. @if [ "$(CONFIG_BINFMT_SHARED_FLAT)" = "y" ]; then \
  80. [ -e $(ROMFSDIR)/lib ] || mkdir -p $(ROMFSDIR)/lib; \
  81. $(ROMFSINST) $(SHARED_TARGET) /lib/lib$(LIBID).so; \
  82. fi
  83. ifeq ($(strip $(HAVE_SHARED)),y)
  84. install -d $(ROMFSDIR)/lib
  85. install -m 644 lib/lib*-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
  86. $(ROMFSDIR)/lib
  87. cp -fa lib/*.so.* $(ROMFSDIR)/lib/.
  88. @if [ -x lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so ] ; then \
  89. set -x -e; \
  90. install -m 755 lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
  91. $(ROMFSDIR)/lib; \
  92. $(ROMFSINST) -s \
  93. /lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
  94. /lib/ld-linux.so.2; \
  95. fi;
  96. endif
  97. include/bits/uClibc_config.h: .config
  98. @if [ ! -x ./extra/config/conf ] ; then \
  99. make -C extra/config conf; \
  100. fi;
  101. rm -rf include/bits
  102. mkdir -p include/bits
  103. @./extra/config/conf -o extra/Configs/Config.$(TARGET_ARCH)
  104. headers: include/bits/uClibc_config.h
  105. ifeq ($(strip $(UCLIBC_HAS_MMU)),y)
  106. @./extra/scripts/fix_includes.sh -k $(KERNEL_SOURCE) -t $(TARGET_ARCH)
  107. else
  108. @./extra/scripts/fix_includes.sh -k $(KERNEL_SOURCE) -t $(TARGET_ARCH) -n
  109. endif
  110. @if [ "$(TARGET_ARCH)" = "mipsel" ]; then \
  111. (cd libc/sysdeps/linux; \
  112. ln -fs mips mipsel); \
  113. (cd ldso/ldso; \
  114. ln -fs mips mipsel); \
  115. (cd libpthread/linuxthreads/sysdeps; \
  116. ln -fs mips mipsel); \
  117. fi;
  118. @cd include/bits; \
  119. set -e; \
  120. for i in `ls ../../libc/sysdeps/linux/common/bits/*.h` ; do \
  121. ln -fs $$i .; \
  122. done; \
  123. if [ -d ../../libc/sysdeps/linux/$(TARGET_ARCH)/bits ] ; then \
  124. for i in `ls ../../libc/sysdeps/linux/$(TARGET_ARCH)/bits/*.h` ; do \
  125. ln -fs $$i .; \
  126. done; \
  127. fi
  128. @cd include/sys; \
  129. set -e; \
  130. for i in `ls ../../libc/sysdeps/linux/common/sys/*.h` ; do \
  131. ln -fs $$i .; \
  132. done; \
  133. if [ -d ../../libc/sysdeps/linux/$(TARGET_ARCH)/sys ] ; then \
  134. for i in `ls ../../libc/sysdeps/linux/$(TARGET_ARCH)/sys/*.h` ; do \
  135. ln -fs $$i .; \
  136. done; \
  137. fi
  138. @cd $(TOPDIR); \
  139. set -x -e; \
  140. TOPDIR=. CC="$(CC)" /bin/sh extra/scripts/gen_bits_syscall_h.sh > include/bits/sysnum.h.new; \
  141. if cmp include/bits/sysnum.h include/bits/sysnum.h.new >/dev/null 2>&1; then \
  142. $(RM) include/bits/sysnum.h.new; \
  143. else \
  144. mv -f include/bits/sysnum.h.new include/bits/sysnum.h; \
  145. fi
  146. $(MAKE) -C libc/sysdeps/linux/$(TARGET_ARCH) headers
  147. subdirs: $(patsubst %, _dir_%, $(DIRS))
  148. $(patsubst %, _dir_%, $(DIRS)) : dummy
  149. $(MAKE) -C $(patsubst _dir_%, %, $@)
  150. tags:
  151. ctags -R
  152. install: install_dev install_runtime install_toolchain install_utils finished2
  153. # Installs header files and development library links.
  154. install_dev:
  155. install -d $(PREFIX)$(DEVEL_PREFIX)/lib
  156. install -d $(PREFIX)$(DEVEL_PREFIX)/usr/lib
  157. install -d $(PREFIX)$(DEVEL_PREFIX)/include
  158. -install -m 644 lib/*.[ao] $(PREFIX)$(DEVEL_PREFIX)/lib/
  159. tar -chf - include | tar -xf - -C $(PREFIX)$(DEVEL_PREFIX);
  160. -@for i in `find $(PREFIX)$(DEVEL_PREFIX) -type d` ; do \
  161. chmod -f 755 $$i; chmod -f 644 $$i/*.h; \
  162. done;
  163. -find $(PREFIX)$(DEVEL_PREFIX) -name CVS | xargs rm -rf;
  164. -chown -R `id | sed 's/^uid=\([0-9]*\).*gid=\([0-9]*\).*$$/\1.\2/'` $(PREFIX)$(DEVEL_PREFIX)
  165. ifeq ($(strip $(HAVE_SHARED)),y)
  166. -install -m 644 lib/*.so $(PREFIX)$(DEVEL_PREFIX)/lib/
  167. -find lib/ -type l -name '*.so' -exec cp -fa {} $(PREFIX)$(DEVEL_PREFIX)/lib ';'
  168. # If we build shared libraries then the static libs are PIC...
  169. # Make _pic.a symlinks to make mklibs.py and similar tools happy.
  170. for i in `find lib/ -type f -name '*.a' | sed -e 's/lib\///'` ; do \
  171. ln -sf $$i $(PREFIX)$(DEVEL_PREFIX)/lib/`echo $$i | sed -e 's/\.a$$/_pic.a/'`; \
  172. done
  173. endif
  174. # Installs run-time libraries and helper apps onto the host system
  175. # allowing cross development. If you want to deploy to a target
  176. # system, use the "install_target" target instead...
  177. install_runtime:
  178. ifeq ($(strip $(HAVE_SHARED)),y)
  179. install -d $(PREFIX)$(DEVEL_PREFIX)/lib
  180. install -d $(PREFIX)$(DEVEL_PREFIX)/bin
  181. install -m 644 lib/lib*-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
  182. $(PREFIX)$(DEVEL_PREFIX)/lib
  183. cp -fa lib/*.so.* $(PREFIX)$(DEVEL_PREFIX)/lib
  184. @if [ -x lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so ] ; then \
  185. set -x -e; \
  186. install -m 755 lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
  187. $(PREFIX)$(DEVEL_PREFIX)/lib; \
  188. fi;
  189. #@if [ -x lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so ] ; then \
  190. # install -d $(PREFIX)$(SHARED_LIB_LOADER_PATH); \
  191. # ln -sf $(PREFIX)$(DEVEL_PREFIX)/lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
  192. # $(PREFIX)$(SHARED_LIB_LOADER_PATH)/$(UCLIBC_LDSO); \
  193. #fi;
  194. endif
  195. install_toolchain:
  196. install -d $(PREFIX)$(DEVEL_PREFIX)/lib
  197. install -d $(PREFIX)$(DEVEL_PREFIX)/bin
  198. install -d $(PREFIX)$(DEVEL_TOOL_PREFIX)/bin
  199. install -d $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin
  200. $(MAKE) -C extra/gcc-uClibc install
  201. ifeq ($(strip $(HAVE_SHARED)),y)
  202. utils: $(TOPDIR)ldso/util/ldd
  203. $(MAKE) -C ldso utils
  204. else
  205. utils: dummy
  206. endif
  207. install_utils: utils
  208. ifeq ($(strip $(HAVE_SHARED)),y)
  209. install -d $(PREFIX)$(DEVEL_TOOL_PREFIX)/bin;
  210. install -m 755 ldso/util/ldd \
  211. $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-ldd
  212. ln -fs $(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-ldd \
  213. $(PREFIX)$(DEVEL_TOOL_PREFIX)/bin/ldd
  214. # For now, don't bother with readelf since surely the host
  215. # system has binutils, or we couldn't have gotten this far...
  216. #install -m 755 ldso/util/readelf \
  217. # $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-readelf
  218. #ln -fs $(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-readelf \
  219. # $(PREFIX)$(DEVEL_TOOL_PREFIX)/bin/readelf
  220. @if [ -x ldso/util/ldconfig ] ; then \
  221. set -x -e; \
  222. install -d $(PREFIX)$(DEVEL_PREFIX)/etc; \
  223. install -m 755 ldso/util/ldconfig \
  224. $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-ldconfig; \
  225. ln -fs $(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-ldconfig \
  226. $(PREFIX)$(DEVEL_TOOL_PREFIX)/bin/ldconfig; \
  227. fi;
  228. endif
  229. # Installs run-time libraries and helper apps in preparation for
  230. # deploying onto a target system, but installed below wherever
  231. # $PREFIX is set to, allowing you to package up the result for
  232. # deployment onto your target system.
  233. install_target:
  234. ifeq ($(strip $(HAVE_SHARED)),y)
  235. install -d $(PREFIX)$(TARGET_PREFIX)/lib
  236. install -d $(PREFIX)$(TARGET_PREFIX)/usr/bin
  237. install -m 644 lib/lib*-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
  238. $(PREFIX)$(TARGET_PREFIX)/lib
  239. cp -fa lib/*.so.* $(PREFIX)$(TARGET_PREFIX)/lib
  240. @if [ -x lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so ] ; then \
  241. set -x -e; \
  242. install -m 755 lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
  243. $(PREFIX)$(TARGET_PREFIX)/lib; \
  244. fi;
  245. #@if [ -x lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so ] ; then \
  246. # install -d $(PREFIX)$(SHARED_LIB_LOADER_PATH); \
  247. # ln -sf $(PREFIX)$(TARGET_PREFIX)/lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
  248. # $(PREFIX)$(SHARED_LIB_LOADER_PATH)/$(UCLIBC_LDSO); \
  249. #fi;
  250. endif
  251. install_target_utils:
  252. ifeq ($(strip $(HAVE_SHARED)),y)
  253. @$(MAKE) -C ldso/util ldd.target readelf.target #ldconfig.target
  254. install -d $(PREFIX)$(TARGET_PREFIX)/usr/bin;
  255. install -m 755 ldso/util/ldd.target $(PREFIX)$(TARGET_PREFIX)/usr/bin/ldd
  256. install -m 755 ldso/util/readelf.target $(PREFIX)$(TARGET_PREFIX)/usr/bin/readelf
  257. @if [ -x ldso/util/ldconfig.target ] ; then \
  258. set -x -e; \
  259. install -d $(PREFIX)$(TARGET_PREFIX)/etc; \
  260. install -d $(PREFIX)$(TARGET_PREFIX)/sbin; \
  261. install -m 755 ldso/util/ldconfig.target $(PREFIX)$(TARGET_PREFIX)/sbin/ldconfig; \
  262. fi;
  263. endif
  264. ifeq ($(strip $(UCLIBC_HAS_LOCALE)),y)
  265. @$(MAKE) -C libc/misc/wchar iconv.target
  266. install -d $(PREFIX)$(TARGET_PREFIX)/usr/bin;
  267. install -m 755 libc/misc/wchar/iconv.target $(PREFIX)$(TARGET_PREFIX)/usr/bin/iconv
  268. endif
  269. finished2:
  270. @echo
  271. @echo Finished installing...
  272. @echo
  273. else # ifeq ($(strip $(HAVE_DOT_CONFIG)),y)
  274. all: menuconfig
  275. # configuration
  276. # ---------------------------------------------------------------------------
  277. extra/config/conf:
  278. make -C extra/config conf
  279. -@if [ ! -f .config ] ; then \
  280. cp extra/Configs/Config.$(TARGET_ARCH).default .config; \
  281. fi
  282. extra/config/mconf:
  283. make -C extra/config ncurses conf mconf
  284. -@if [ ! -f .config ] ; then \
  285. cp extra/Configs/Config.$(TARGET_ARCH).default .config; \
  286. fi
  287. menuconfig: extra/config/mconf
  288. rm -rf include/bits
  289. mkdir -p include/bits
  290. @./extra/config/mconf extra/Configs/Config.$(TARGET_ARCH)
  291. config: extra/config/conf
  292. rm -rf include/bits
  293. mkdir -p include/bits
  294. @./extra/config/conf extra/Configs/Config.$(TARGET_ARCH)
  295. oldconfig: extra/config/conf
  296. rm -rf include/bits
  297. mkdir -p include/bits
  298. @./extra/config/conf -o extra/Configs/Config.$(TARGET_ARCH)
  299. randconfig: extra/config/conf
  300. rm -rf include/bits
  301. mkdir -p include/bits
  302. @./extra/config/conf -r extra/Configs/Config.$(TARGET_ARCH)
  303. allyesconfig: extra/config/conf
  304. rm -rf include/bits
  305. mkdir -p include/bits
  306. @./extra/config/conf -y extra/Configs/Config.$(TARGET_ARCH)
  307. allnoconfig: extra/config/conf
  308. rm -rf include/bits
  309. mkdir -p include/bits
  310. @./extra/config/conf -n extra/Configs/Config.$(TARGET_ARCH)
  311. defconfig: extra/config/conf
  312. rm -rf include/bits
  313. mkdir -p include/bits
  314. @./extra/config/conf -d extra/Configs/Config.$(TARGET_ARCH)
  315. clean:
  316. - find . \( -name \*.o -o -name \*.a -o -name \*.so -o -name core -o -name .\#\* \) -exec rm -f {} \;
  317. @rm -rf tmp lib include/bits libc/tmp _install
  318. $(MAKE) -C test clean
  319. $(MAKE) -C ldso clean
  320. $(MAKE) -C libc/misc/internals clean
  321. $(MAKE) -C libc/misc/wchar clean
  322. $(MAKE) -C libc/unistd clean
  323. $(MAKE) -C libc/sysdeps/linux/common clean
  324. $(MAKE) -C extra/gcc-uClibc clean
  325. $(MAKE) -C extra/locale clean
  326. @set -e; \
  327. for i in `(cd $(TOPDIR)/libc/sysdeps/linux/common/sys; ls *.h)` ; do \
  328. rm -f include/sys/$$i; \
  329. done; \
  330. if [ -d libc/sysdeps/linux/$(TARGET_ARCH)/sys ] ; then \
  331. for i in `(cd libc/sysdeps/linux/$(TARGET_ARCH)/sys; ls *.h)` ; do \
  332. rm -f include/sys/$$i; \
  333. done; \
  334. fi;
  335. @rm -f include/linux include/scsi include/asm
  336. @if [ -d libc/sysdeps/linux/$(TARGET_ARCH) ]; then \
  337. $(MAKE) -C libc/sysdeps/linux/$(TARGET_ARCH) clean; \
  338. fi;
  339. @if [ "$(TARGET_ARCH)" = "mipsel" ]; then \
  340. $(MAKE) -C libc/sysdeps/linux/mips clean; \
  341. rm -f ldso/ldso/mipsel; \
  342. rm -f libc/sysdeps/linux/mipsel; \
  343. rm -f libpthread/linuxthreads/sysdeps/mipsel; \
  344. fi;
  345. distclean: clean
  346. rm -f .config .config.old .config.cmd
  347. $(MAKE) -C extra clean
  348. release: distclean
  349. cd ..; \
  350. rm -rf uClibc-$(VERSION); \
  351. cp -fa uClibc uClibc-$(VERSION); \
  352. find uClibc-$(VERSION)/ -type f \
  353. -name .\#* -exec rm -rf {} \; ; \
  354. find uClibc-$(VERSION)/ -type d \
  355. -name CVS -exec rm -rf {} \; ; \
  356. \
  357. tar -cvzf uClibc-$(VERSION).tar.gz uClibc-$(VERSION)/;
  358. endif # ifeq ($(strip $(HAVE_DOT_CONFIG)),y)
  359. .PHONY: dummy subdirs release distclean clean config oldconfig menuconfig