Makefile 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  1. # Makefile for uClibc
  2. #
  3. # Copyright (C) 2000, 2001 by Lineo, inc.
  4. # Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.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. #
  20. # Derived in part from the Linux-8086 C library, the GNU C Library, and several
  21. # other sundry sources. Files within this library are copyright by their
  22. # respective copyright holders.
  23. #--------------------------------------------------------
  24. #
  25. #There are a number of configurable options in "Config"
  26. #
  27. #--------------------------------------------------------
  28. TOPDIR=./
  29. include Rules.mak
  30. DIRS = extra ldso libc libcrypt libresolv libutil libm
  31. all: headers uClibc_config.h subdirs shared done
  32. Config:
  33. @echo
  34. @echo "You didn't read the README, did you... =)"
  35. @echo "Choose a configuration file in extras/Config/ and copy it to ./Config."
  36. @echo
  37. @exit 1
  38. shared:
  39. ifeq ($(strip $(HAVE_SHARED)),true)
  40. @$(MAKE) -C libc shared
  41. @$(MAKE) -C ldso shared
  42. @$(MAKE) -C libcrypt shared
  43. @$(MAKE) -C libutil shared
  44. @$(MAKE) -C libm shared
  45. @$(MAKE) -C libresolv shared
  46. else
  47. @echo
  48. @echo Not building shared libraries...
  49. @echo
  50. endif
  51. done: shared
  52. @echo
  53. @echo Finally finished compiling...
  54. @echo
  55. headers: dummy
  56. @rm -f include/asm include/linux include/bits
  57. @if [ $(TARGET_ARCH) = "powerpc" ];then \
  58. ln -fs $(KERNEL_SOURCE)/include/asm-ppc include/asm; \
  59. elif [ $(TARGET_ARCH) = "v850" ];then \
  60. ln -fs $(KERNEL_SOURCE)/include/asm-v850 include/asm; \
  61. else \
  62. if [ $(HAS_MMU) != "true" ]; then \
  63. ln -fs $(KERNEL_SOURCE)/include/asm-$(TARGET_ARCH)nommu include/asm;\
  64. else \
  65. ln -fs $(KERNEL_SOURCE)/include/asm-$(TARGET_ARCH) include/asm; \
  66. fi; \
  67. fi;
  68. @if [ ! -f include/asm/unistd.h ] ; then \
  69. echo " "; \
  70. echo "The path '$(KERNEL_SOURCE)/include/asm' doesn't exist."; \
  71. echo "I bet you didn't set KERNEL_SOURCE, TARGET_ARCH or HAS_MMU in \`Config'"; \
  72. echo "correctly. Please edit \`Config' and fix these settings."; \
  73. echo " "; \
  74. /bin/false; \
  75. fi;
  76. @if [ $(HAS_MMU) != "true" ] && [ $(TARGET_ARCH) = "i386" ] ; then \
  77. echo "WARNING: I bet your x86 system really has an MMU, right?"; \
  78. echo " malloc and friends won't work unless you fix \`Config'"; \
  79. echo " "; \
  80. sleep 10; \
  81. fi;
  82. @ln -fs $(KERNEL_SOURCE)/include/linux include/linux
  83. @ln -fs ../libc/sysdeps/linux/$(TARGET_ARCH)/bits include/bits
  84. (cd include/bits; ln -sf ../../../../../uClibc_config.h uClibc_config.h)
  85. $(MAKE) -C libc/sysdeps/linux/$(TARGET_ARCH) headers
  86. uClibc_config.h: Makefile Config
  87. @echo "/* WARNING!!! AUTO-GENERATED FILE!!! DO NOT EDIT!!! */" > uClibc_config.h
  88. @echo "#if !defined __FEATURES_H && !defined __need_uClibc_config_h" >> uClibc_config.h
  89. @echo "#error Never include <bits/uClibc_config.h> directly; use <features.h> instead." >> uClibc_config.h
  90. @echo "#endif" >> uClibc_config.h
  91. @echo "#define linux 1" >> uClibc_config.h
  92. @echo "#define __linux__ 1" >> uClibc_config.h
  93. @if [ "$(INCLUDE_IPV6)" = "true" ] ; then \
  94. echo "#define __UCLIBC_HAS_IPV6__ 1" >> uClibc_config.h ; \
  95. else \
  96. echo "#undef __UCLIBC_HAS_IPV6__" >> uClibc_config.h ; \
  97. fi
  98. @if [ "$(HAS_MMU)" = "true" ] ; then \
  99. echo "#define __UCLIBC_HAS_MMU__ 1" >> uClibc_config.h ; \
  100. else \
  101. echo "#undef __UCLIBC_HAS_MMU__" >> uClibc_config.h ; \
  102. fi
  103. @if [ "$(HAS_FLOATING_POINT)" = "true" ] ; then \
  104. echo "#define __UCLIBC_HAS_FLOATS__ 1" >> uClibc_config.h ; \
  105. else \
  106. echo "#undef __UCLIBC_HAS_FLOATS__" >> uClibc_config.h ; \
  107. fi
  108. @if [ "$(HAS_LIBM_FLOAT)" = "true" ] ; then \
  109. echo "#define __UCLIBC_HAS_LIBM_FLOAT__ 1" >> uClibc_config.h ; \
  110. else \
  111. echo "#undef __UCLIBC_HAS_LIBM_FLOAT__" >> uClibc_config.h ; \
  112. fi
  113. @if [ "$(HAS_LIBM_DOUBLE)" = "true" ] ; then \
  114. echo "#define __UCLIBC_HAS_LIBM_DOUBLE__ 1" >> uClibc_config.h ; \
  115. else \
  116. echo "#undef __UCLIBC_HAS_LIBM_DOUBLE__" >> uClibc_config.h ; \
  117. fi
  118. @if [ "$(HAS_LIBM_LONG_DOUBLE)" = "true" ] ; then \
  119. echo "#define __UCLIBC_HAS_LIBM_LONG_DOUBLE__ 1" >> uClibc_config.h ; \
  120. else \
  121. echo "#undef __UCLIBC_HAS_LIBM_LONG_DOUBLE__" >> uClibc_config.h ; \
  122. fi
  123. @if [ "$(HAS_LONG_LONG)" = "true" ] ; then \
  124. echo "#define __UCLIBC_HAS_LONG_LONG__ 1" >> uClibc_config.h ; \
  125. else \
  126. echo "#undef __UCLIBC_HAS_LONG_LONG__" >> uClibc_config.h ; \
  127. fi
  128. @if [ "$(HAS_LOCALE)" = "true" ] ; then \
  129. echo "#define __UCLIBC_HAS_LOCALE__ 1" >> uClibc_config.h ; \
  130. echo "#define __UCLIBC_LOCALE_DIR \""$(LOCALE_DIR)"\"" >> uClibc_config.h ; \
  131. else \
  132. echo "#undef __UCLIBC_HAS_LOCALE__" >> uClibc_config.h ; \
  133. fi
  134. @if [ "$(HAVE_ELF)" = "false" ] ; then \
  135. echo "#undef HAVE_ELF" >> uClibc_config.h ; \
  136. else \
  137. echo "#define HAVE_ELF 1" >> uClibc_config.h ; \
  138. fi
  139. @if [ "$(HAVE_SHARED)" = "false" ] ; then \
  140. echo "#undef HAVE_SHARED" >> uClibc_config.h ; \
  141. else \
  142. echo "#define HAVE_SHARED 1" >> uClibc_config.h ; \
  143. fi
  144. @if [ "$(TARGET_ARCH)" = "sh" ] ; then \
  145. echo "#define NO_UNDERSCORES 1" >> uClibc_config.h ; \
  146. else \
  147. echo "#undef NO_UNDERSCORES" >> uClibc_config.h ; \
  148. fi
  149. @if [ "$(INCLUDE_RPC)" = "true" ] ; then \
  150. echo "#define __UCLIBC_HAS_RPC__ 1" >> uClibc_config.h ; \
  151. else \
  152. echo "#undef __UCLIBC_HAS_RPC__" >> uClibc_config.h ; \
  153. fi
  154. @if [ "$(UNIFIED_SYSCALL)" = "true" ] ; then \
  155. echo "#define __UCLIBC_USE_UNIFIED_SYSCALL__ 1" >> uClibc_config.h ; \
  156. else \
  157. echo "#undef __UCLIBC_USE_UNIFIED_SYSCALL__" >> uClibc_config.h ; \
  158. fi
  159. @if [ "$(OLD_STYLE_MMAP)" != "false" ] ; then \
  160. echo "#define __UCLIBC_OLD_STYLE_MMAP__ 1" >> uClibc_config.h ; \
  161. else \
  162. echo "#undef __UCLIBC_OLD_STYLE_MMAP__" >> uClibc_config.h ; \
  163. fi
  164. @echo "#define C_SYMBOL_PREFIX "\""$(C_SYMBOL_PREFIX)"\" >> uClibc_config.h
  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_gcc
  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)/include
  176. install -d $(PREFIX)$(DEVEL_PREFIX)/usr/lib
  177. find include/ -name '*.h' -depth -follow -exec install \
  178. -D -m 644 {} $(PREFIX)$(DEVEL_PREFIX)/'{}' ';'
  179. ifeq ($(strip $(HAVE_SHARED)),true)
  180. find lib/ -type l -name '*.so' -exec cp -a {} $(PREFIX)$(DEVEL_PREFIX)/lib ';'
  181. endif
  182. # Installs run-time libraries and helper apps onto the host system
  183. # allowing cross development. If you want to deploy to a target
  184. # system, use the "install_target" target instead...
  185. install_runtime:
  186. ifeq ($(strip $(HAVE_SHARED)),true)
  187. install -d $(PREFIX)$(DEVEL_PREFIX)/lib
  188. install -d $(PREFIX)$(DEVEL_PREFIX)/bin
  189. install -m 644 lib/lib*-$(MAJOR_VERSION).$(MINOR_VERSION).so $(PREFIX)$(DEVEL_PREFIX)/lib
  190. cp -a lib/*.so.* $(PREFIX)$(DEVEL_PREFIX)/lib
  191. install -m 755 ldso/util/ldd $(PREFIX)$(DEVEL_PREFIX)/bin
  192. install -m 755 ldso/util/readelf $(PREFIX)$(DEVEL_PREFIX)/bin
  193. install -d $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin
  194. ln -fs $(DEVEL_PREFIX)/bin/ldd $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-ldd
  195. ln -fs $(DEVEL_PREFIX)/bin/readelf $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-readelf
  196. if [ -x lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).so ] ; then \
  197. install -m 755 lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).so $(PREFIX)$(DEVEL_PREFIX)/lib; \
  198. mkdir -p $(PREFIX)$(SHARED_LIB_LOADER_PATH); \
  199. ln -s $(DEVEL_PREFIX)/lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).so \
  200. $(PREFIX)$(SHARED_LIB_LOADER_PATH)/$(UCLIBC_LDSO) || true; \
  201. fi;
  202. if [ -x ldso/util/ldconfig ] ; then \
  203. install -d $(PREFIX)$(DEVEL_PREFIX)/etc; \
  204. install -m 755 ldso/util/ldconfig $(PREFIX)$(DEVEL_PREFIX)/bin; \
  205. ln -fs $(DEVEL_PREFIX)/sbin/ldconfig $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-ldconfig; \
  206. fi;
  207. endif
  208. install_gcc:
  209. $(MAKE) -C extra/gcc-uClibc install
  210. # Installs run-time libraries and helper apps in preparation for
  211. # deploying onto a target system, but installed below wherever
  212. # $PREFIX is set to, allowing you to package up the result for
  213. # deployment onto your target system.
  214. install_target:
  215. ifeq ($(strip $(HAVE_SHARED)),true)
  216. install -d $(PREFIX)$(TARGET_PREFIX)/lib
  217. install -d $(PREFIX)$(TARGET_PREFIX)/sbin
  218. install -d $(PREFIX)$(TARGET_PREFIX)/usr/bin
  219. install -m 644 lib/lib*-$(MAJOR_VERSION).$(MINOR_VERSION).so $(PREFIX)$(TARGET_PREFIX)/lib
  220. cp -a lib/*.so.* $(PREFIX)$(TARGET_PREFIX)/lib
  221. install -m 755 ldso/util/ldd $(PREFIX)$(TARGET_PREFIX)/usr/bin
  222. install -m 755 ldso/util/readelf $(PREFIX)$(TARGET_PREFIX)/usr/bin
  223. if [ -x lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).so ] ; then \
  224. install -m 755 lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).so $(PREFIX)$(TARGET_PREFIX)/lib; \
  225. mkdir -p $(PREFIX)$(SHARED_LIB_LOADER_PATH); \
  226. ln -s $(TARGET_PREFIX)/lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).so \
  227. $(PREFIX)$(SHARED_LIB_LOADER_PATH)/$(UCLIBC_LDSO) || true; \
  228. fi;
  229. if [ -x ldso/util/ldconfig ] ; then \
  230. install -d $(PREFIX)$(TARGET_PREFIX)/etc; \
  231. install -m 755 ldso/util/ldconfig $(PREFIX)$(TARGET_PREFIX)/sbin; \
  232. fi;
  233. endif
  234. distclean clean:
  235. @rm -rf tmp lib include/bits/uClibc_config.h uClibc_config.h
  236. - find include -type l -exec rm -f {} \;
  237. - find . \( -name \*.o -o -name \*.a -o -name \*.so -o -name core -o -name .\#\* \) -exec rm -f {} \;
  238. $(MAKE) -C test clean
  239. $(MAKE) -C ldso clean
  240. $(MAKE) -C libc/unistd clean
  241. $(MAKE) -C libc/sysdeps/linux/common clean
  242. $(MAKE) -C libc/sysdeps/linux/$(TARGET_ARCH) clean
  243. $(MAKE) -C extra/gcc-uClibc clean
  244. dist release: distclean
  245. cd ..; \
  246. rm -rf uClibc-$(VERSION); \
  247. cp -a uClibc uClibc-$(VERSION); \
  248. \
  249. find uClibc-$(VERSION)/ -type d \
  250. -name CVS \
  251. -exec rm -rf {} \; ; \
  252. \
  253. tar -cvzf uClibc-$(VERSION).tar.gz --exclude CVS uClibc-$(VERSION)/;
  254. .PHONY: dummy subdirs