Makefile 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  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 $(DO_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. @$(MAKE) -C libc shared
  40. @$(MAKE) -C ldso/util
  41. ifeq ($(LDSO_PRESENT), $(TARGET_ARCH))
  42. @$(MAKE) -C ldso shared
  43. endif
  44. @$(MAKE) -C libcrypt shared
  45. @$(MAKE) -C libutil shared
  46. @$(MAKE) -C libm shared
  47. @$(MAKE) -C libresolv shared
  48. done: $(DO_SHARED)
  49. @echo
  50. @echo Finally finished compiling...
  51. @echo
  52. headers: dummy
  53. @rm -f include/asm include/linux include/bits
  54. @if [ $(TARGET_ARCH) = "powerpc" ];then \
  55. ln -fs $(KERNEL_SOURCE)/include/asm-ppc include/asm; \
  56. else \
  57. if [ $(HAS_MMU) != "true" ]; then \
  58. ln -fs $(KERNEL_SOURCE)/include/asm-$(TARGET_ARCH)nommu include/asm;\
  59. else \
  60. ln -fs $(KERNEL_SOURCE)/include/asm-$(TARGET_ARCH) include/asm; \
  61. fi; \
  62. fi;
  63. @if [ ! -f include/asm/unistd.h ] ; then \
  64. echo " "; \
  65. echo "The path '$(KERNEL_SOURCE)/include/asm' doesn't exist."; \
  66. echo "I bet you didn't set KERNEL_SOURCE, TARGET_ARCH or HAS_MMU in \`Config'"; \
  67. echo "correctly. Please edit \`Config' and fix these settings."; \
  68. echo " "; \
  69. /bin/false; \
  70. fi;
  71. @if [ $(HAS_MMU) != "true" ] && [ $(TARGET_ARCH) = "i386" ] ; then \
  72. echo "WARNING: I bet your x86 system really has an MMU, right?"; \
  73. echo " malloc and friends won't work unless you fix \`Config'"; \
  74. echo " "; \
  75. sleep 10; \
  76. fi;
  77. @ln -fs $(KERNEL_SOURCE)/include/linux include/linux
  78. @ln -fs ../libc/sysdeps/linux/$(TARGET_ARCH)/bits include/bits
  79. (cd include/bits; ln -sf ../../../../../uClibc_config.h uClibc_config.h)
  80. $(MAKE) -C libc/sysdeps/linux/$(TARGET_ARCH) headers
  81. uClibc_config.h: Makefile Config
  82. @echo "/* WARNING!!! AUTO-GENERATED FILE!!! DO NOT EDIT!!! */" > uClibc_config.h
  83. @echo "#if !defined __FEATURES_H && !defined __need_uClibc_config_h" >> uClibc_config.h
  84. @echo "#error Never include <bits/uClibc_config.h> directly; use <features.h> instead." >> uClibc_config.h
  85. @echo "#endif" >> uClibc_config.h
  86. @echo "#define linux 1" >> uClibc_config.h
  87. @echo "#define __linux__ 1" >> uClibc_config.h
  88. @if [ "$(INCLUDE_IPV6)" = "true" ] ; then \
  89. echo "#define __UCLIBC_HAS_IPV6__ 1" >> uClibc_config.h ; \
  90. else \
  91. echo "#undef __UCLIBC_HAS_IPV6__" >> uClibc_config.h ; \
  92. fi
  93. @if [ "$(HAS_MMU)" = "true" ] ; then \
  94. echo "#define __UCLIBC_HAS_MMU__ 1" >> uClibc_config.h ; \
  95. else \
  96. echo "#undef __UCLIBC_HAS_MMU__" >> uClibc_config.h ; \
  97. fi
  98. @if [ "$(HAS_FLOATING_POINT)" = "true" ] ; then \
  99. echo "#define __UCLIBC_HAS_FLOATS__ 1" >> uClibc_config.h ; \
  100. else \
  101. echo "#undef __UCLIBC_HAS_FLOATS__" >> uClibc_config.h ; \
  102. fi
  103. @if [ "$(HAS_LIBM_FLOAT)" = "true" ] ; then \
  104. echo "#define __UCLIBC_HAS_LIBM_FLOAT__ 1" >> uClibc_config.h ; \
  105. else \
  106. echo "#undef __UCLIBC_HAS_LIBM_FLOAT__" >> uClibc_config.h ; \
  107. fi
  108. @if [ "$(HAS_LIBM_DOUBLE)" = "true" ] ; then \
  109. echo "#define __UCLIBC_HAS_LIBM_DOUBLE__ 1" >> uClibc_config.h ; \
  110. else \
  111. echo "#undef __UCLIBC_HAS_LIBM_DOUBLE__" >> uClibc_config.h ; \
  112. fi
  113. @if [ "$(HAS_LIBM_LONG_DOUBLE)" = "true" ] ; then \
  114. echo "#define __UCLIBC_HAS_LIBM_LONG_DOUBLE__ 1" >> uClibc_config.h ; \
  115. else \
  116. echo "#undef __UCLIBC_HAS_LIBM_LONG_DOUBLE__" >> uClibc_config.h ; \
  117. fi
  118. @if [ "$(HAS_LONG_LONG)" = "true" ] ; then \
  119. echo "#define __UCLIBC_HAS_LONG_LONG__ 1" >> uClibc_config.h ; \
  120. else \
  121. echo "#undef __UCLIBC_HAS_LONG_LONG__" >> uClibc_config.h ; \
  122. fi
  123. @if [ "$(HAS_LOCALE)" = "true" ] ; then \
  124. echo "#define __UCLIBC_HAS_LOCALE__ 1" >> uClibc_config.h ; \
  125. echo "#define __UCLIBC_LOCALE_DIR \""$(LOCALE_DIR)"\"" >> uClibc_config.h ; \
  126. else \
  127. echo "#undef __UCLIBC_HAS_LOCALE__" >> uClibc_config.h ; \
  128. fi
  129. @if [ "$(HAVE_ELF)" = "false" ] ; then \
  130. echo "#undef HAVE_ELF" >> uClibc_config.h ; \
  131. else \
  132. echo "#define HAVE_ELF 1" >> uClibc_config.h ; \
  133. fi
  134. @if [ "$(HAVE_SHARED)" = "false" ] ; then \
  135. echo "#undef HAVE_SHARED" >> uClibc_config.h ; \
  136. else \
  137. echo "#define HAVE_SHARED 1" >> uClibc_config.h ; \
  138. fi
  139. @if [ "$(TARGET_ARCH)" = "sh" ] ; then \
  140. echo "#define NO_UNDERSCORES 1" >> uClibc_config.h ; \
  141. else \
  142. echo "#undef NO_UNDERSCORES" >> uClibc_config.h ; \
  143. fi
  144. @if [ "$(INCLUDE_RPC)" = "true" ] ; then \
  145. echo "#define __UCLIBC_HAS_RPC__ 1" >> uClibc_config.h ; \
  146. else \
  147. echo "#undef __UCLIBC_HAS_RPC__" >> uClibc_config.h ; \
  148. fi
  149. @if [ "$(UNIFIED_SYSCALL)" = "true" ] ; then \
  150. echo "#define __UCLIBC_USE_UNIFIED_SYSCALL__ 1" >> uClibc_config.h ; \
  151. else \
  152. echo "#undef __UCLIBC_USE_UNIFIED_SYSCALL__" >> uClibc_config.h ; \
  153. fi
  154. subdirs: $(patsubst %, _dir_%, $(DIRS))
  155. $(patsubst %, _dir_%, $(DIRS)) : dummy
  156. $(MAKE) -C $(patsubst _dir_%, %, $@)
  157. tags:
  158. ctags -R
  159. install: install_dev install_runtime install_gcc
  160. # install_target:
  161. # Installs run-time libraries and helper apps (ldconfig) to the
  162. # locations that one would expect on a host that is running uClibc
  163. # as the primary libc. TARGET_PREFIX is the location of the root
  164. # directory.
  165. install_target:
  166. ifeq ($(DO_SHARED),shared)
  167. install -d $(TARGET_PREFIX)/lib
  168. install -d $(TARGET_PREFIX)/etc
  169. install -d $(TARGET_PREFIX)/sbin
  170. install -d $(TARGET_PREFIX)/usr/bin
  171. install -m 644 lib/lib*-0.9.5.so $(TARGET_PREFIX)/lib
  172. cp -a lib/*.so.* $(TARGET_PREFIX)/lib
  173. ifeq ($(LDSO_PRESENT),$(TARGET_ARCH))
  174. install -m 755 lib/ld-uClibc-0.9.5.so $(TARGET_PREFIX)/lib
  175. install -m 755 ldso/util/ldd $(TARGET_PREFIX)/usr/bin
  176. install -m 755 ldso/util/ldconfig $(TARGET_PREFIX)/sbin
  177. endif
  178. ifeq ($(NATIVE_ARCH), $(TARGET_ARCH))
  179. # -@if [ -x ldso/util/ldconfig ] ; then ldso/util/ldconfig; fi
  180. endif
  181. endif
  182. # install_runtime:
  183. # Installs run-time libraries and helper apps (ldconfig) to the
  184. # locations one would expect on a host that is running a different
  185. # libary as the primary libc.
  186. install_runtime:
  187. ifeq ($(DO_SHARED),shared)
  188. install -d $(DEVEL_PREFIX)/lib
  189. install -d $(DEVEL_PREFIX)/etc
  190. install -d $(DEVEL_PREFIX)/bin
  191. install -m 644 lib/lib*-0.9.5.so $(DEVEL_PREFIX)/lib
  192. cp -a lib/*.so.* $(DEVEL_PREFIX)/lib
  193. ifeq ($(LDSO_PRESENT),$(TARGET_ARCH))
  194. install -m 755 lib/ld-uClibc-0.9.5.so $(DEVEL_PREFIX)/lib
  195. install -m 755 ldso/util/ldd $(DEVEL_PREFIX)/bin
  196. install -m 755 ldso/util/ldconfig $(DEVEL_PREFIX)/bin
  197. install -d $(PREFIX)/bin
  198. ln -fs $(DEVEL_PREFIX)/bin/ldd $(PREFIX)/bin/$(TARGET_ARCH)-uclibc-ldd
  199. install -d $(PREFIX)/sbin
  200. ln -fs $(DEVEL_PREFIX)/sbin/ldconfig $(PREFIX)/sbin/$(TARGET_ARCH)-uclibc-ldconfig
  201. endif
  202. endif
  203. # install_dev:
  204. # Installs header files and development library links.
  205. # DEVEL_PREFIX should be $(PREFIX)/$(target)-linux-uclibc/
  206. install_dev:
  207. install -d $(DEVEL_PREFIX)/lib
  208. install -m 644 lib/*.[ao] $(DEVEL_PREFIX)/lib/
  209. ifeq ($(DO_SHARED),shared)
  210. find lib/ -type l -name '*.so' -exec cp -a {} $(DEVEL_PREFIX)/lib ';'
  211. ifeq ($(NATIVE_ARCH), $(TARGET_ARCH))
  212. # -@if [ -x ldso/util/ldconfig ] ; then ldso/util/ldconfig; fi
  213. endif
  214. endif
  215. install -d $(DEVEL_PREFIX)/include
  216. find include/ -name '*.h' -depth -follow -exec install \
  217. -D -m 644 {} $(DEVEL_PREFIX)/'{}' ';'
  218. install_gcc:
  219. $(MAKE) -C extra/gcc-uClibc install
  220. clean:
  221. @rm -rf tmp lib include/bits/uClibc_config.h uClibc_config.h
  222. - find include -type l -exec rm -f {} \;
  223. - find . \( -name \*.o -o -name \*.a -o -name \*.so -o -name core \) -exec rm -f {} \;
  224. $(MAKE) -C ldso clean
  225. $(MAKE) -C libc/unistd clean
  226. $(MAKE) -C libc/sysdeps/linux/common clean
  227. $(MAKE) -C libc/sysdeps/linux/$(TARGET_ARCH) clean
  228. $(MAKE) -C extra/gcc-uClibc clean
  229. .PHONY: dummy subdirs