Makefile 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  1. # Makefile for uClibc
  2. #
  3. # Copyright (C) 2000 by Lineo, inc.
  4. # Copyright (C) 2000,2001,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 uClibc_config.h subdirs shared 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. finished: shared
  55. @echo
  56. @echo Finally finished compiling...
  57. @echo
  58. headers: dummy
  59. @rm -f include/asm include/linux include/bits
  60. @if [ $(TARGET_ARCH) = "powerpc" ];then \
  61. ln -fs $(KERNEL_SOURCE)/include/asm-ppc include/asm; \
  62. elif [ $(TARGET_ARCH) = "v850" ];then \
  63. ln -fs $(KERNEL_SOURCE)/include/asm-v850 include/asm; \
  64. elif [ $(TARGET_ARCH) = "mips" ];then \
  65. ln -fs $(KERNEL_SOURCE)/include/asm-mips include/asm; \
  66. elif [ $(TARGET_ARCH) = "h8300" ];then \
  67. ln -fs $(KERNEL_SOURCE)/include/asm-h8300 include/asm; \
  68. else \
  69. if [ $(HAS_MMU) != "true" ]; then \
  70. ln -fs $(KERNEL_SOURCE)/include/asm-$(TARGET_ARCH)nommu include/asm;\
  71. else \
  72. ln -fs $(KERNEL_SOURCE)/include/asm-$(TARGET_ARCH) include/asm; \
  73. fi; \
  74. fi;
  75. @if [ ! -f include/asm/unistd.h ] ; then \
  76. set -e; \
  77. echo " "; \
  78. echo "The path '$(KERNEL_SOURCE)/include/asm' doesn't exist."; \
  79. echo "I bet you didn't set KERNEL_SOURCE, TARGET_ARCH or HAS_MMU in \`Config'"; \
  80. echo "correctly. Please edit \`Config' and fix these settings."; \
  81. echo " "; \
  82. /bin/false; \
  83. fi;
  84. @if [ $(HAS_MMU) != "true" ] && [ $(TARGET_ARCH) = "i386" ] ; then \
  85. set -e; \
  86. echo "WARNING: I bet your x86 system really has an MMU, right?"; \
  87. echo " malloc and friends won't work unless you fix \`Config'"; \
  88. echo " "; \
  89. sleep 10; \
  90. fi;
  91. @ln -fs $(KERNEL_SOURCE)/include/linux include/linux
  92. @ln -fs ../libc/sysdeps/linux/$(TARGET_ARCH)/bits include/bits
  93. (cd include/bits && ln -sf ../../../../../uClibc_config.h uClibc_config.h)
  94. $(MAKE) -C libc/sysdeps/linux/$(TARGET_ARCH) headers
  95. uClibc_config.h: Makefile Config
  96. @echo "/* WARNING!!! AUTO-GENERATED FILE!!! DO NOT EDIT!!! */" > uClibc_config.h
  97. @echo "#if !defined __FEATURES_H && !defined __need_uClibc_config_h" >> uClibc_config.h
  98. @echo "#error Never include <bits/uClibc_config.h> directly; use <features.h> instead." >> uClibc_config.h
  99. @echo "#endif" >> uClibc_config.h
  100. @echo "#define linux 1" >> uClibc_config.h
  101. @echo "#define __linux__ 1" >> uClibc_config.h
  102. @if [ "$(INCLUDE_IPV6)" = "true" ] ; then \
  103. echo "#define __UCLIBC_HAS_IPV6__ 1" >> uClibc_config.h ; \
  104. else \
  105. echo "#undef __UCLIBC_HAS_IPV6__" >> uClibc_config.h ; \
  106. fi
  107. @if [ "$(HAS_MMU)" = "true" ] ; then \
  108. echo "#define __UCLIBC_HAS_MMU__ 1" >> uClibc_config.h ; \
  109. else \
  110. echo "#undef __UCLIBC_HAS_MMU__" >> uClibc_config.h ; \
  111. fi
  112. @if [ "$(HAS_FLOATING_POINT)" = "true" ] ; then \
  113. echo "#define __UCLIBC_HAS_FLOATS__ 1" >> uClibc_config.h ; \
  114. else \
  115. echo "#undef __UCLIBC_HAS_FLOATS__" >> uClibc_config.h ; \
  116. fi
  117. @if [ "$(HAS_LONG_LONG)" = "true" ] ; then \
  118. echo "#define __UCLIBC_HAS_LONG_LONG__ 1" >> uClibc_config.h ; \
  119. else \
  120. echo "#undef __UCLIBC_HAS_LONG_LONG__" >> uClibc_config.h ; \
  121. fi
  122. @if [ "$(HAS_LOCALE)" = "true" ] ; then \
  123. echo "#define __UCLIBC_HAS_LOCALE__ 1" >> uClibc_config.h ; \
  124. echo "#define __UCLIBC_LOCALE_DIR \""$(LOCALE_DIR)"\"" >> uClibc_config.h ; \
  125. else \
  126. echo "#undef __UCLIBC_HAS_LOCALE__" >> uClibc_config.h ; \
  127. fi
  128. @if [ "$(HAVE_ELF)" = "false" ] ; then \
  129. echo "#undef HAVE_ELF" >> uClibc_config.h ; \
  130. else \
  131. echo "#define HAVE_ELF 1" >> uClibc_config.h ; \
  132. fi
  133. @if [ "$(HAVE_SHARED)" = "false" ] ; then \
  134. echo "#undef HAVE_SHARED" >> uClibc_config.h ; \
  135. else \
  136. echo "#define HAVE_SHARED 1" >> uClibc_config.h ; \
  137. fi
  138. @if [ "$(TARGET_ARCH)" = "sh" ] ; then \
  139. echo "#define NO_UNDERSCORES 1" >> uClibc_config.h ; \
  140. else \
  141. echo "#undef NO_UNDERSCORES" >> uClibc_config.h ; \
  142. fi
  143. @if [ "$(INCLUDE_RPC)" = "true" ] ; then \
  144. echo "#define __UCLIBC_HAS_RPC__ 1" >> uClibc_config.h ; \
  145. else \
  146. echo "#undef __UCLIBC_HAS_RPC__" >> uClibc_config.h ; \
  147. fi
  148. @if [ "$(UNIFIED_SYSCALL)" = "true" ] ; then \
  149. echo "#define __UCLIBC_USE_UNIFIED_SYSCALL__ 1" >> uClibc_config.h ; \
  150. else \
  151. echo "#undef __UCLIBC_USE_UNIFIED_SYSCALL__" >> uClibc_config.h ; \
  152. fi
  153. @echo "#define C_SYMBOL_PREFIX "\""$(C_SYMBOL_PREFIX)"\" >> uClibc_config.h
  154. @if [ "$(DOLFS)" = "true" ] ; then \
  155. echo "#define __UCLIBC_HAVE_LFS__ 1" >> uClibc_config.h ; \
  156. else \
  157. echo "#undef __UCLIBC_HAVE_LFS__" >> uClibc_config.h ; \
  158. fi
  159. @if [ "$(INCLUDE_THREADS)" = "true" ] ; then \
  160. echo "#define __UCLIBC_HAS_THREADS__ 1" >> uClibc_config.h ; \
  161. else \
  162. echo "#undef __UCLIBC_HAS_THREADS__" >> uClibc_config.h ; \
  163. fi
  164. @if [ "$(UNIX98PTY_ONLY)" = "true" ] ; then \
  165. echo "#define UNIX98PTY_ONLY 1" >> uClibc_config.h ; \
  166. else \
  167. echo "#undef UNIX98PTY_ONLY" >> uClibc_config.h ; \
  168. fi
  169. @if [ "$(ASSUME_DEVPTS)" = "true" ] ; then \
  170. echo "#define ASSUME_DEVPTS 1" >> uClibc_config.h ; \
  171. else \
  172. echo "#undef ASSUME_DEVPTS" >> uClibc_config.h ; \
  173. fi
  174. subdirs: $(patsubst %, _dir_%, $(DIRS))
  175. $(patsubst %, _dir_%, $(DIRS)) : dummy
  176. $(MAKE) -C $(patsubst _dir_%, %, $@)
  177. tags:
  178. ctags -R
  179. install: install_dev install_runtime install_toolchain install_utils finished2
  180. # Installs header files and development library links.
  181. install_dev:
  182. install -d $(PREFIX)$(DEVEL_PREFIX)/lib
  183. install -d $(PREFIX)$(DEVEL_PREFIX)/usr/lib
  184. install -d $(PREFIX)$(DEVEL_PREFIX)/include
  185. install -m 644 lib/*.[ao] $(PREFIX)$(DEVEL_PREFIX)/lib/
  186. tar -chO include | tar -xf - -C $(PREFIX)$(DEVEL_PREFIX);
  187. -@for i in `find $(PREFIX)$(DEVEL_PREFIX) -type d` ; do \
  188. chmod -f 755 $$i; chmod -f 644 $$i/*.h; \
  189. done;
  190. -chown -R `id | sed 's/^uid=\([0-9]*\).*gid=\([0-9]*\).*$$/\1.\2/'` $(PREFIX)$(DEVEL_PREFIX)
  191. ifeq ($(strip $(HAVE_SHARED)),true)
  192. find lib/ -type l -name '*.so' -exec cp -a {} $(PREFIX)$(DEVEL_PREFIX)/lib ';'
  193. endif
  194. # Installs run-time libraries and helper apps onto the host system
  195. # allowing cross development. If you want to deploy to a target
  196. # system, use the "install_target" target instead...
  197. install_runtime:
  198. ifeq ($(strip $(HAVE_SHARED)),true)
  199. install -d $(PREFIX)$(DEVEL_PREFIX)/lib
  200. install -d $(PREFIX)$(DEVEL_PREFIX)/bin
  201. install -m 644 lib/lib*-$(MAJOR_VERSION).$(MINOR_VERSION).so $(PREFIX)$(DEVEL_PREFIX)/lib
  202. cp -a lib/*.so.* $(PREFIX)$(DEVEL_PREFIX)/lib
  203. @if [ -x lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).so ] ; then \
  204. set -x -e; \
  205. install -m 755 lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).so $(PREFIX)$(DEVEL_PREFIX)/lib; \
  206. mkdir -p $(PREFIX)$(SHARED_LIB_LOADER_PATH); \
  207. ln -s $(DEVEL_PREFIX)/lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).so \
  208. $(PREFIX)$(SHARED_LIB_LOADER_PATH)/$(UCLIBC_LDSO) || true; \
  209. fi;
  210. endif
  211. install_toolchain:
  212. install -d $(PREFIX)$(DEVEL_PREFIX)/lib
  213. install -d $(PREFIX)$(DEVEL_PREFIX)/bin
  214. install -d $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin
  215. $(MAKE) -C extra/gcc-uClibc install
  216. install_utils:
  217. ifeq ($(strip $(HAVE_SHARED)),true)
  218. @$(MAKE) -C ldso utils
  219. install -m 755 ldso/util/ldd $(PREFIX)$(DEVEL_PREFIX)/bin
  220. ln -fs $(DEVEL_PREFIX)/bin/ldd $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-ldd
  221. # For now, don't bother with readelf since surely the host
  222. # system has binutils, or we couldn't have gotten this far...
  223. #install -m 755 ldso/util/readelf $(PREFIX)$(DEVEL_PREFIX)/bin
  224. #ln -fs $(DEVEL_PREFIX)/bin/readelf $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-readelf
  225. @if [ -x ldso/util/ldconfig ] ; then \
  226. set -x -e; \
  227. install -d $(PREFIX)$(DEVEL_PREFIX)/etc; \
  228. install -m 755 ldso/util/ldconfig $(PREFIX)$(DEVEL_PREFIX)/bin; \
  229. ln -fs $(DEVEL_PREFIX)/sbin/ldconfig $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-ldconfig; \
  230. fi;
  231. endif
  232. # Installs run-time libraries and helper apps in preparation for
  233. # deploying onto a target system, but installed below wherever
  234. # $PREFIX is set to, allowing you to package up the result for
  235. # deployment onto your target system.
  236. install_target:
  237. ifeq ($(strip $(HAVE_SHARED)),true)
  238. install -d $(PREFIX)$(TARGET_PREFIX)/lib
  239. install -d $(PREFIX)$(TARGET_PREFIX)/sbin
  240. install -d $(PREFIX)$(TARGET_PREFIX)/usr/bin
  241. install -m 644 lib/lib*-$(MAJOR_VERSION).$(MINOR_VERSION).so $(PREFIX)$(TARGET_PREFIX)/lib
  242. cp -a lib/*.so.* $(PREFIX)$(TARGET_PREFIX)/lib
  243. @if [ -x lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).so ] ; then \
  244. set -x -e; \
  245. install -m 755 lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).so $(PREFIX)$(TARGET_PREFIX)/lib; \
  246. mkdir -p $(PREFIX)$(SHARED_LIB_LOADER_PATH); \
  247. ln -s $(TARGET_PREFIX)/lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).so \
  248. $(PREFIX)$(SHARED_LIB_LOADER_PATH)/$(UCLIBC_LDSO) || true; \
  249. fi;
  250. endif
  251. install_target_utils:
  252. ifeq ($(strip $(HAVE_SHARED)),true)
  253. install -m 755 ldso/util/ldd.target $(PREFIX)$(TARGET_PREFIX)/usr/bin/ldd
  254. install -m 755 ldso/util/readelf.target $(PREFIX)$(TARGET_PREFIX)/usr/bin/readelf
  255. @if [ -x ldso/util/ldconfig.target ] ; then \
  256. set -x -e; \
  257. install -d $(PREFIX)$(TARGET_PREFIX)/etc; \
  258. install -m 755 ldso/util/ldconfig.target $(PREFIX)$(TARGET_PREFIX)/sbin/ldconfig; \
  259. fi;
  260. endif
  261. finished2:
  262. @echo
  263. @echo Finished installing...
  264. @echo
  265. distclean clean:
  266. @rm -rf tmp lib include/bits/uClibc_config.h uClibc_config.h libc/tmp
  267. - find include -type l -exec rm -f {} \;
  268. - find . \( -name \*.o -o -name \*.a -o -name \*.so -o -name core -o -name .\#\* \) -exec rm -f {} \;
  269. $(MAKE) -C test clean
  270. $(MAKE) -C ldso clean
  271. $(MAKE) -C libc/unistd clean
  272. $(MAKE) -C libc/sysdeps/linux/common clean
  273. $(MAKE) -C libc/sysdeps/linux/$(TARGET_ARCH) clean
  274. $(MAKE) -C extra/gcc-uClibc clean
  275. dist release: distclean
  276. cd ..; \
  277. rm -rf uClibc-$(VERSION); \
  278. cp -a uClibc uClibc-$(VERSION); \
  279. find uClibc-$(VERSION)/ -type d \
  280. -name CVS -exec rm -rf {} \; ; \
  281. find uClibc-$(VERSION)/ -type d \
  282. -name .\#* -exec rm -rf {} \; ; \
  283. \
  284. tar -cvzf uClibc-$(VERSION).tar.gz --exclude CVS uClibc-$(VERSION)/;
  285. .PHONY: dummy subdirs