Makefile 15 KB

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