Makefile 10 KB

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