Makefile 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388
  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. #
  26. #There are a number of configurable options in "Config"
  27. #
  28. #--------------------------------------------------------
  29. TOPDIR=./
  30. include Rules.mak
  31. DIRS = extra ldso libc libcrypt libresolv libutil libm libpthread
  32. all: headers include/bits/uClibc_config.h subdirs shared util finished
  33. Config:
  34. @echo
  35. @echo "You didn't read the README, did you... =)"
  36. @echo "Choose a configuration file in extras/Config/ and then run"
  37. @echo " ln -s ./extra/Configs/Config.<arch> ./Config"
  38. @echo
  39. @exit 1
  40. shared:
  41. ifeq ($(strip $(HAVE_SHARED)),true)
  42. @$(MAKE) -C libc shared
  43. @$(MAKE) -C ldso shared
  44. @$(MAKE) -C libcrypt shared
  45. @$(MAKE) -C libresolv shared
  46. @$(MAKE) -C libutil shared
  47. @$(MAKE) -C libm shared
  48. @$(MAKE) -C libpthread shared
  49. else
  50. @echo
  51. @echo Not building shared libraries...
  52. @echo
  53. endif
  54. util:
  55. ifeq ($(strip $(HAVE_SHARED)),true)
  56. @$(MAKE) -C ldso utils
  57. endif
  58. finished: shared
  59. @echo
  60. @echo Finally finished compiling...
  61. @echo
  62. #
  63. # dummy target for uClinux distro
  64. #
  65. romfs:
  66. headers: dummy
  67. rm -f include/asm;
  68. @if [ $(TARGET_ARCH) = "powerpc" ];then \
  69. ln -fs $(KERNEL_SOURCE)/include/asm-ppc include/asm; \
  70. elif [ $(TARGET_ARCH) = "v850" ];then \
  71. ln -fs $(KERNEL_SOURCE)/include/asm-v850 include/asm; \
  72. elif [ $(TARGET_ARCH) = "mips" ];then \
  73. ln -fs $(KERNEL_SOURCE)/include/asm-mips include/asm; \
  74. elif [ $(TARGET_ARCH) = "mipsel" ];then \
  75. ln -fs $(KERNEL_SOURCE)/include/asm-mips include/asm; \
  76. cd $(shell pwd)/libc/sysdeps/linux; \
  77. ln -fs mips mipsel; \
  78. cd $(shell pwd)/ldso/ldso; \
  79. ln -fs mips mipsel; \
  80. cd $(shell pwd)/libpthread/linuxthreads/sysdeps; \
  81. ln -fs mips mipsel; \
  82. elif [ $(TARGET_ARCH) = "h8300" ];then \
  83. ln -fs $(KERNEL_SOURCE)/include/asm-h8300 include/asm; \
  84. else \
  85. if [ $(HAS_MMU) != "true" ]; then \
  86. ln -fs $(KERNEL_SOURCE)/include/asm-$(TARGET_ARCH)nommu include/asm;\
  87. else \
  88. ln -fs $(KERNEL_SOURCE)/include/asm-$(TARGET_ARCH) include/asm; \
  89. fi; \
  90. fi;
  91. @if [ ! -f include/asm/unistd.h ] ; then \
  92. set -e; \
  93. echo " "; \
  94. echo "The path '$(KERNEL_SOURCE)/include/asm' doesn't exist."; \
  95. echo "I bet you didn't set KERNEL_SOURCE, TARGET_ARCH or HAS_MMU in \`Config'"; \
  96. echo "correctly. Please edit \`Config' and fix these settings."; \
  97. echo " "; \
  98. /bin/false; \
  99. fi;
  100. @if [ $(HAS_MMU) != "true" -a $(TARGET_ARCH) = "i386" ] ; then \
  101. set -e; \
  102. echo "WARNING: I bet your x86 system really has an MMU, right?"; \
  103. echo " malloc and friends won't work unless you fix \`Config'"; \
  104. echo " "; \
  105. sleep 10; \
  106. fi;
  107. rm -f include/linux include/scsi
  108. ln -fs $(KERNEL_SOURCE)/include/linux include/linux
  109. ln -fs $(KERNEL_SOURCE)/include/scsi include/scsi
  110. rm -rf include/bits
  111. mkdir -p include/bits
  112. @cd include/bits; \
  113. set -e; \
  114. for i in `ls ../../libc/sysdeps/linux/common/bits/*.h` ; do \
  115. ln -fs $$i .; \
  116. done; \
  117. if [ -d ../../libc/sysdeps/linux/$(TARGET_ARCH)/bits ] ; then \
  118. for i in `ls ../../libc/sysdeps/linux/$(TARGET_ARCH)/bits/*.h` ; do \
  119. ln -fs $$i .; \
  120. done; \
  121. fi
  122. @cd include/sys; \
  123. set -e; \
  124. for i in `ls ../../libc/sysdeps/linux/common/sys/*.h` ; do \
  125. ln -fs $$i .; \
  126. done; \
  127. if [ -d ../../libc/sysdeps/linux/$(TARGET_ARCH)/sys ] ; then \
  128. for i in `ls ../../libc/sysdeps/linux/$(TARGET_ARCH)/sys/*.h` ; do \
  129. ln -fs $$i .; \
  130. done; \
  131. fi
  132. @cd $(TOPDIR); \
  133. set -x -e; \
  134. rm -f include/bits/syscall.h; \
  135. TOPDIR=$(TOPDIR) CC=$(CC) /bin/sh $(TOPDIR)/extra/scripts/gen_bits_syscall_h.sh > include/bits/syscall.h
  136. $(MAKE) -C libc/sysdeps/linux/$(TARGET_ARCH) headers
  137. include/bits/uClibc_config.h: Makefile Config
  138. @echo "/* WARNING!!! AUTO-GENERATED FILE!!! DO NOT EDIT!!! */" > include/bits/uClibc_config.h
  139. @echo "#if !defined __FEATURES_H && !defined __need_uClibc_config_h" >> include/bits/uClibc_config.h
  140. @echo "#error Never include <bits/uClibc_config.h> directly; use <features.h> instead." >> include/bits/uClibc_config.h
  141. @echo "#endif" >> include/bits/uClibc_config.h
  142. @echo "#define __UCLIBC_MAJOR__ $(MAJOR_VERSION)" >> include/bits/uClibc_config.h
  143. @echo "#define __UCLIBC_MINOR__ $(MINOR_VERSION)" >> include/bits/uClibc_config.h
  144. @echo "#define __UCLIBC_SUBLEVEL__ $(SUBLEVEL)" >> include/bits/uClibc_config.h
  145. @echo "#define linux 1" >> include/bits/uClibc_config.h
  146. @echo "#define __linux__ 1" >> include/bits/uClibc_config.h
  147. @if [ "$(INCLUDE_IPV6)" = "true" ] ; then \
  148. echo "#define __UCLIBC_HAS_IPV6__ 1" >> include/bits/uClibc_config.h ; \
  149. else \
  150. echo "#undef __UCLIBC_HAS_IPV6__" >> include/bits/uClibc_config.h ; \
  151. fi
  152. @if [ "$(HAS_MMU)" = "true" ] ; then \
  153. echo "#define __UCLIBC_HAS_MMU__ 1" >> include/bits/uClibc_config.h ; \
  154. else \
  155. echo "#undef __UCLIBC_HAS_MMU__" >> include/bits/uClibc_config.h ; \
  156. fi
  157. @if [ "$(HAS_FLOATING_POINT)" = "true" ] ; then \
  158. echo "#define __UCLIBC_HAS_FLOATS__ 1" >> include/bits/uClibc_config.h ; \
  159. else \
  160. echo "#undef __UCLIBC_HAS_FLOATS__" >> include/bits/uClibc_config.h ; \
  161. fi
  162. @if [ "$(HAS_LONG_LONG)" = "true" ] ; then \
  163. echo "#define __UCLIBC_HAS_LONG_LONG__ 1" >> include/bits/uClibc_config.h ; \
  164. else \
  165. echo "#undef __UCLIBC_HAS_LONG_LONG__" >> include/bits/uClibc_config.h ; \
  166. fi
  167. @if [ "$(HAS_LOCALE)" = "true" ] ; then \
  168. echo "#define __UCLIBC_HAS_LOCALE__ 1" >> include/bits/uClibc_config.h ; \
  169. else \
  170. echo "#undef __UCLIBC_HAS_LOCALE__" >> include/bits/uClibc_config.h ; \
  171. fi
  172. @if [ "$(HAS_WCHAR)" = "true" ] ; then \
  173. echo "#define __UCLIBC_HAS_WCHAR__ 1" >> include/bits/uClibc_config.h ; \
  174. else \
  175. echo "#undef __UCLIBC_HAS_WCHAR__" >> include/bits/uClibc_config.h ; \
  176. fi
  177. @if [ "$(HAVE_ELF)" = "false" ] ; then \
  178. echo "#undef HAVE_ELF" >> include/bits/uClibc_config.h ; \
  179. else \
  180. echo "#define HAVE_ELF 1" >> include/bits/uClibc_config.h ; \
  181. fi
  182. @if [ "$(HAVE_SHARED)" = "false" ] ; then \
  183. echo "#undef HAVE_SHARED" >> include/bits/uClibc_config.h ; \
  184. else \
  185. echo "#define HAVE_SHARED 1" >> include/bits/uClibc_config.h ; \
  186. fi
  187. @if [ "$(TARGET_ARCH)" = "sh" ] ; then \
  188. echo "#define NO_UNDERSCORES 1" >> include/bits/uClibc_config.h ; \
  189. else \
  190. echo "#undef NO_UNDERSCORES" >> include/bits/uClibc_config.h ; \
  191. fi
  192. @if [ "$(INCLUDE_RPC)" = "true" ] ; then \
  193. echo "#define __UCLIBC_HAS_RPC__ 1" >> include/bits/uClibc_config.h ; \
  194. else \
  195. echo "#undef __UCLIBC_HAS_RPC__" >> include/bits/uClibc_config.h ; \
  196. fi
  197. @if [ "$(UNIFIED_SYSCALL)" = "true" ] ; then \
  198. echo "#define __UCLIBC_USE_UNIFIED_SYSCALL__ 1" >> include/bits/uClibc_config.h ; \
  199. else \
  200. echo "#undef __UCLIBC_USE_UNIFIED_SYSCALL__" >> include/bits/uClibc_config.h ; \
  201. fi
  202. @echo "#define C_SYMBOL_PREFIX "\""$(C_SYMBOL_PREFIX)"\" >> include/bits/uClibc_config.h
  203. @if [ "$(DOLFS)" = "true" ] ; then \
  204. echo "#define __UCLIBC_HAVE_LFS__ 1" >> include/bits/uClibc_config.h ; \
  205. else \
  206. echo "#undef __UCLIBC_HAVE_LFS__" >> include/bits/uClibc_config.h ; \
  207. fi
  208. @if [ "$(INCLUDE_THREADS)" = "true" ] ; then \
  209. echo "#define __UCLIBC_HAS_THREADS__ 1" >> include/bits/uClibc_config.h ; \
  210. else \
  211. echo "#undef __UCLIBC_HAS_THREADS__" >> include/bits/uClibc_config.h ; \
  212. fi
  213. @if [ "$(INCLUDE_REGEX)" = "true" ] ; then \
  214. echo "#define __UCLIBC_HAS_REGEX__ 1" >> include/bits/uClibc_config.h ; \
  215. else \
  216. echo "#undef __UCLIBC_HAS_REGEX__" >> include/bits/uClibc_config.h ; \
  217. fi
  218. @if [ "$(UNIX98PTY_ONLY)" = "true" ] ; then \
  219. echo "#define UNIX98PTY_ONLY 1" >> include/bits/uClibc_config.h ; \
  220. else \
  221. echo "#undef UNIX98PTY_ONLY" >> include/bits/uClibc_config.h ; \
  222. fi
  223. @if [ "$(ASSUME_DEVPTS)" = "true" ] ; then \
  224. echo "#define ASSUME_DEVPTS 1" >> include/bits/uClibc_config.h ; \
  225. else \
  226. echo "#undef ASSUME_DEVPTS" >> include/bits/uClibc_config.h ; \
  227. fi
  228. subdirs: $(patsubst %, _dir_%, $(DIRS))
  229. $(patsubst %, _dir_%, $(DIRS)) : dummy
  230. $(MAKE) -C $(patsubst _dir_%, %, $@)
  231. tags:
  232. ctags -R
  233. install: install_dev install_runtime install_toolchain install_utils finished2
  234. # Installs header files and development library links.
  235. install_dev:
  236. install -d $(PREFIX)$(DEVEL_PREFIX)/lib
  237. install -d $(PREFIX)$(DEVEL_PREFIX)/usr/lib
  238. install -d $(PREFIX)$(DEVEL_PREFIX)/include
  239. -install -m 644 lib/*.[ao] $(PREFIX)$(DEVEL_PREFIX)/lib/
  240. tar -chf - include | tar -xf - -C $(PREFIX)$(DEVEL_PREFIX);
  241. -@for i in `find $(PREFIX)$(DEVEL_PREFIX) -type d` ; do \
  242. chmod -f 755 $$i; chmod -f 644 $$i/*.h; \
  243. done;
  244. -find $(PREFIX)$(DEVEL_PREFIX) -name CVS | xargs rm -rf;
  245. -chown -R `id | sed 's/^uid=\([0-9]*\).*gid=\([0-9]*\).*$$/\1.\2/'` $(PREFIX)$(DEVEL_PREFIX)
  246. ifeq ($(strip $(HAVE_SHARED)),true)
  247. -find lib/ -type l -name '*.so' -exec cp -a {} $(PREFIX)$(DEVEL_PREFIX)/lib ';'
  248. endif
  249. # Installs run-time libraries and helper apps onto the host system
  250. # allowing cross development. If you want to deploy to a target
  251. # system, use the "install_target" target instead...
  252. install_runtime:
  253. ifeq ($(strip $(HAVE_SHARED)),true)
  254. install -d $(PREFIX)$(DEVEL_PREFIX)/lib
  255. install -d $(PREFIX)$(DEVEL_PREFIX)/bin
  256. install -m 644 lib/lib*-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
  257. $(PREFIX)$(DEVEL_PREFIX)/lib
  258. cp -a lib/*.so.* $(PREFIX)$(DEVEL_PREFIX)/lib
  259. @if [ -x lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so ] ; then \
  260. set -x -e; \
  261. install -m 755 lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
  262. $(PREFIX)$(DEVEL_PREFIX)/lib; \
  263. mkdir -p $(PREFIX)$(SHARED_LIB_LOADER_PATH); \
  264. ln -s $(DEVEL_PREFIX)/lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
  265. $(PREFIX)$(SHARED_LIB_LOADER_PATH)/$(UCLIBC_LDSO) || true; \
  266. fi;
  267. endif
  268. install_toolchain:
  269. install -d $(PREFIX)$(DEVEL_PREFIX)/lib
  270. install -d $(PREFIX)$(DEVEL_PREFIX)/bin
  271. install -d $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin
  272. $(MAKE) -C extra/gcc-uClibc install
  273. install_utils:
  274. ifeq ($(strip $(HAVE_SHARED)),true)
  275. @$(MAKE) -C ldso utils
  276. install -m 755 ldso/util/ldd $(PREFIX)$(DEVEL_PREFIX)/bin
  277. ln -fs $(DEVEL_PREFIX)/bin/ldd $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-ldd
  278. # For now, don't bother with readelf since surely the host
  279. # system has binutils, or we couldn't have gotten this far...
  280. #install -m 755 ldso/util/readelf $(PREFIX)$(DEVEL_PREFIX)/bin
  281. #ln -fs $(DEVEL_PREFIX)/bin/readelf $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-readelf
  282. @if [ -x ldso/util/ldconfig ] ; then \
  283. set -x -e; \
  284. install -d $(PREFIX)$(DEVEL_PREFIX)/etc; \
  285. install -m 755 ldso/util/ldconfig $(PREFIX)$(DEVEL_PREFIX)/bin; \
  286. ln -fs $(DEVEL_PREFIX)/sbin/ldconfig $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-ldconfig; \
  287. fi;
  288. endif
  289. # Installs run-time libraries and helper apps in preparation for
  290. # deploying onto a target system, but installed below wherever
  291. # $PREFIX is set to, allowing you to package up the result for
  292. # deployment onto your target system.
  293. install_target:
  294. ifeq ($(strip $(HAVE_SHARED)),true)
  295. install -d $(PREFIX)$(TARGET_PREFIX)/lib
  296. install -d $(PREFIX)$(TARGET_PREFIX)/sbin
  297. install -d $(PREFIX)$(TARGET_PREFIX)/usr/bin
  298. install -m 644 lib/lib*-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
  299. $(PREFIX)$(TARGET_PREFIX)/lib
  300. cp -a lib/*.so.* $(PREFIX)$(TARGET_PREFIX)/lib
  301. @if [ -x lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so ] ; then \
  302. set -x -e; \
  303. install -m 755 lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
  304. $(PREFIX)$(TARGET_PREFIX)/lib; \
  305. mkdir -p $(PREFIX)$(SHARED_LIB_LOADER_PATH); \
  306. ln -s $(TARGET_PREFIX)/lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
  307. $(PREFIX)$(SHARED_LIB_LOADER_PATH)/$(UCLIBC_LDSO) || true; \
  308. fi;
  309. endif
  310. install_target_utils:
  311. ifeq ($(strip $(HAVE_SHARED)),true)
  312. install -m 755 ldso/util/ldd.target $(PREFIX)$(TARGET_PREFIX)/usr/bin/ldd
  313. install -m 755 ldso/util/readelf.target $(PREFIX)$(TARGET_PREFIX)/usr/bin/readelf
  314. @if [ -x ldso/util/ldconfig.target ] ; then \
  315. set -x -e; \
  316. install -d $(PREFIX)$(TARGET_PREFIX)/etc; \
  317. install -m 755 ldso/util/ldconfig.target $(PREFIX)$(TARGET_PREFIX)/sbin/ldconfig; \
  318. fi;
  319. endif
  320. finished2:
  321. @echo
  322. @echo Finished installing...
  323. @echo
  324. distclean clean:
  325. - find . \( -name \*.o -o -name \*.a -o -name \*.so -o -name core -o -name .\#\* \) -exec rm -f {} \;
  326. @rm -rf tmp lib include/bits libc/tmp _install
  327. $(MAKE) -C test clean
  328. $(MAKE) -C ldso clean
  329. $(MAKE) -C libc/misc/internals clean
  330. $(MAKE) -C libc/unistd clean
  331. $(MAKE) -C libc/sysdeps/linux/common clean
  332. $(MAKE) -C extra/gcc-uClibc clean
  333. @set -e; \
  334. for i in `(cd $(TOPDIR)/libc/sysdeps/linux/common/sys; ls *.h)` ; do \
  335. rm -f include/sys/$$i; \
  336. done; \
  337. if [ -d libc/sysdeps/linux/$(TARGET_ARCH)/sys ] ; then \
  338. for i in `(cd libc/sysdeps/linux/$(TARGET_ARCH)/sys; ls *.h)` ; do \
  339. rm -f include/sys/$$i; \
  340. done; \
  341. fi;
  342. @rm -f include/linux include/scsi include/asm
  343. @if [ -d libc/sysdeps/linux/$(TARGET_ARCH) ]; then \
  344. $(MAKE) -C libc/sysdeps/linux/$(TARGET_ARCH) clean; \
  345. fi;
  346. @if [ $(TARGET_ARCH) = "mipsel" -o $(TARGET_ARCH) = "mips" ]; then \
  347. rm -f libc/sysdeps/linux/$(TARGET_ARCH); \
  348. rm -f ldso/ldso/$(TARGET_ARCH); \
  349. rm -f libpthread/linuxthreads/sysdeps/$(TARGET_ARCH); \
  350. fi;
  351. dist release: distclean
  352. cd ..; \
  353. rm -rf uClibc-$(VERSION); \
  354. cp -a uClibc uClibc-$(VERSION); \
  355. find uClibc-$(VERSION)/ -type d \
  356. -name .\#* -exec rm -rf {} \; ; \
  357. \
  358. tar -cvzf uClibc-$(VERSION).tar.gz --exclude CVS uClibc-$(VERSION)/;
  359. .PHONY: dummy subdirs release distclean clean