Makefile 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  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. ifndef $(TARGET_PREFIX)
  32. TARGET_PREFIX = `pwd`/_install
  33. endif
  34. all: headers uClibc_config.h subdirs $(DO_SHARED) done
  35. Config:
  36. @echo
  37. @echo "You didn't read the README, did you... =)"
  38. @echo "Choose a configuration file in extras/Config/ and copy it to ./Config."
  39. @echo
  40. @exit 1
  41. shared:
  42. @$(MAKE) -C libc shared
  43. @$(MAKE) -C ldso/util
  44. ifeq ($(LDSO_PRESENT), $(TARGET_ARCH))
  45. @$(MAKE) -C ldso shared
  46. endif
  47. @$(MAKE) -C libcrypt shared
  48. @$(MAKE) -C libutil shared
  49. @$(MAKE) -C libm shared
  50. @$(MAKE) -C libresolv shared
  51. done: $(DO_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 -s $(KERNEL_SOURCE)/include/asm-ppc include/asm; \
  59. else \
  60. if [ $(HAS_MMU) != "true" ]; then \
  61. ln -s $(KERNEL_SOURCE)/include/asm-$(TARGET_ARCH)nommu include/asm;\
  62. else \
  63. ln -s $(KERNEL_SOURCE)/include/asm-$(TARGET_ARCH) include/asm; \
  64. fi; \
  65. fi;
  66. @if [ ! -f include/asm/unistd.h ] ; then \
  67. echo " "; \
  68. echo "The path '$(KERNEL_SOURCE)/include/asm' doesn't exist."; \
  69. echo "I bet you didn't set KERNEL_SOURCE, TARGET_ARCH or HAS_MMU in \`Config'"; \
  70. echo "correctly. Please edit \`Config' and fix these settings."; \
  71. echo " "; \
  72. /bin/false; \
  73. fi;
  74. @if [ $(HAS_MMU) != "true" ] && [ $(TARGET_ARCH) = "i386" ] ; then \
  75. echo "WARNING: I bet your x86 system really has an MMU, right?"; \
  76. echo " malloc and friends won't work unless you fix \`Config'"; \
  77. echo " "; \
  78. sleep 10; \
  79. fi;
  80. @ln -s $(KERNEL_SOURCE)/include/linux include/linux
  81. @ln -s ../libc/sysdeps/linux/$(TARGET_ARCH)/bits include/bits
  82. (cd include/bits; ln -sf ../../../../../uClibc_config.h uClibc_config.h)
  83. $(MAKE) -C libc/sysdeps/linux/$(TARGET_ARCH) headers
  84. uClibc_config.h: Makefile Config
  85. @echo "/* WARNING!!! AUTO-GENERATED FILE!!! DO NOT EDIT!!! */" > uClibc_config.h
  86. @echo "#if !defined __FEATURES_H && !defined __need_uClibc_config_h" >> uClibc_config.h
  87. @echo "#error Never include <bits/uClibc_config.h> directly; use <features.h> instead." >> uClibc_config.h
  88. @echo "#endif" >> uClibc_config.h
  89. @echo "#define linux 1" >> uClibc_config.h
  90. @echo "#define __linux__ 1" >> uClibc_config.h
  91. @if [ "$(HAS_MMU)" = "true" ] ; then \
  92. echo "#define __UCLIBC_HAS_MMU__ 1" >> uClibc_config.h ; \
  93. else \
  94. echo "#undef __UCLIBC_HAS_MMU__" >> uClibc_config.h ; \
  95. fi
  96. @if [ "$(HAS_FLOATING_POINT)" = "true" ] ; then \
  97. echo "#define __UCLIBC_HAS_FLOATS__ 1" >> uClibc_config.h ; \
  98. else \
  99. echo "#undef __UCLIBC_HAS_FLOATS__" >> uClibc_config.h ; \
  100. fi
  101. @if [ "$(HAS_LIBM_FLOAT)" = "true" ] ; then \
  102. echo "#define __UCLIBC_HAS_LIBM_FLOAT__ 1" >> uClibc_config.h ; \
  103. else \
  104. echo "#undef __UCLIBC_HAS_LIBM_FLOAT__" >> uClibc_config.h ; \
  105. fi
  106. @if [ "$(HAS_LIBM_DOUBLE)" = "true" ] ; then \
  107. echo "#define __UCLIBC_HAS_LIBM_DOUBLE__ 1" >> uClibc_config.h ; \
  108. else \
  109. echo "#undef __UCLIBC_HAS_LIBM_DOUBLE__" >> uClibc_config.h ; \
  110. fi
  111. @if [ "$(HAS_LIBM_LONG_DOUBLE)" = "true" ] ; then \
  112. echo "#define __UCLIBC_HAS_LIBM_LONG_DOUBLE__ 1" >> uClibc_config.h ; \
  113. else \
  114. echo "#undef __UCLIBC_HAS_LIBM_LONG_DOUBLE__" >> uClibc_config.h ; \
  115. fi
  116. @if [ "$(HAS_LONG_LONG)" = "true" ] ; then \
  117. echo "#define __UCLIBC_HAS_LONG_LONG__ 1" >> uClibc_config.h ; \
  118. else \
  119. echo "#undef __UCLIBC_HAS_LONG_LONG__" >> uClibc_config.h ; \
  120. fi
  121. @if [ "$(HAS_LOCALE)" = "true" ] ; then \
  122. echo "#define __UCLIBC_HAS_LOCALE__ 1" >> uClibc_config.h ; \
  123. echo "#define __UCLIBC_LOCALE_DIR \""$(LOCALE_DIR)"\"" >> uClibc_config.h ; \
  124. else \
  125. echo "#undef __UCLIBC_HAS_LOCALE__" >> uClibc_config.h ; \
  126. fi
  127. @if [ "$(HAVE_ELF)" = "false" ] ; then \
  128. echo "#undef HAVE_ELF" >> uClibc_config.h ; \
  129. else \
  130. echo "#define HAVE_ELF 1" >> uClibc_config.h ; \
  131. fi
  132. @if [ "$(HAVE_SHARED)" = "false" ] ; then \
  133. echo "#undef HAVE_SHARED" >> uClibc_config.h ; \
  134. else \
  135. echo "#define HAVE_SHARED 1" >> uClibc_config.h ; \
  136. fi
  137. @if [ "$(TARGET_ARCH)" = "sh" ] ; then \
  138. echo "#define NO_UNDERSCORES 1" >> uClibc_config.h ; \
  139. else \
  140. echo "#undef NO_UNDERSCORES" >> uClibc_config.h ; \
  141. fi
  142. @if [ "$(INCLUDE_RPC)" = "true" ] ; then \
  143. echo "#define __UCLIBC_HAS_RPC__ 1" >> uClibc_config.h ; \
  144. else \
  145. echo "#undef __UCLIBC_HAS_RPC__" >> uClibc_config.h ; \
  146. fi
  147. @if [ "$(UNIFIED_SYSCALL)" = "true" ] ; then \
  148. echo "#define __UCLIBC_USE_UNIFIED_SYSCALL__ 1" >> uClibc_config.h ; \
  149. else \
  150. echo "#undef __UCLIBC_USE_UNIFIED_SYSCALL__" >> uClibc_config.h ; \
  151. fi
  152. subdirs: $(patsubst %, _dir_%, $(DIRS))
  153. $(patsubst %, _dir_%, $(DIRS)) : dummy
  154. $(MAKE) -C $(patsubst _dir_%, %, $@)
  155. tags:
  156. ctags -R
  157. install: install_dev
  158. # Installs shared libraries for a target.
  159. install_target:
  160. ifeq ($(DO_SHARED),shared)
  161. install -d $(TARGET_PREFIX)$(ROOT_DIR)/lib
  162. cp -fa lib/*.so* $(TARGET_PREFIX)$(ROOT_DIR)/lib;
  163. install -d $(TARGET_PREFIX)$(ROOT_DIR)/etc
  164. install -d $(TARGET_PREFIX)$(ROOT_DIR)/sbin
  165. install -d $(TARGET_PREFIX)$(ROOT_DIR)/usr/bin
  166. cp -f ldso/util/ldd $(TARGET_PREFIX)$(ROOT_DIR)/usr/bin
  167. cp -f ldso/util/ldconfig $(TARGET_PREFIX)$(ROOT_DIR)/sbin
  168. ifeq ($(NATIVE_ARCH), $(TARGET_ARCH))
  169. -@if [ -x ldso/util/ldconfig ] ; then ldso/util/ldconfig; fi
  170. endif
  171. endif
  172. # Installs development library and headers
  173. # This is done with the assumption that it can blow away anything
  174. # in $(DEVEL_PREFIX)$(ROOT_DIR)/include. Probably true only if you're using
  175. # a packaging system.
  176. install_dev:
  177. install -d $(DEVEL_PREFIX)$(ROOT_DIR)/usr/lib
  178. cp -fa lib/*.[ao] $(DEVEL_PREFIX)$(ROOT_DIR)/usr/lib;
  179. ifeq ($(DO_SHARED),shared)
  180. install -d $(DEVEL_PREFIX)$(ROOT_DIR)/lib
  181. cp -fa lib/*.so* $(DEVEL_PREFIX)$(ROOT_DIR)/lib;
  182. install -d $(DEVEL_PREFIX)$(ROOT_DIR)/etc
  183. install -d $(DEVEL_PREFIX)$(ROOT_DIR)/sbin
  184. install -d $(DEVEL_PREFIX)$(ROOT_DIR)/usr/bin
  185. cp -f ldso/util/ldd $(DEVEL_PREFIX)$(ROOT_DIR)/usr/bin
  186. cp -f ldso/util/ldconfig $(DEVEL_PREFIX)$(ROOT_DIR)/sbin
  187. ifeq ($(NATIVE_ARCH), $(TARGET_ARCH))
  188. -@if [ -x ldso/util/ldconfig ] ; then ldso/util/ldconfig; fi
  189. endif
  190. endif
  191. install -d $(DEVEL_PREFIX)$(ROOT_DIR)/etc
  192. install -d $(DEVEL_PREFIX)$(ROOT_DIR)/usr/include
  193. install -d $(DEVEL_PREFIX)$(ROOT_DIR)/usr/include/bits
  194. rm -f $(DEVEL_PREFIX)$(ROOT_DIR)/usr/include/asm
  195. rm -f $(DEVEL_PREFIX)$(ROOT_DIR)/usr/include/linux
  196. ln -s $(KERNEL_SOURCE)/include/asm $(DEVEL_PREFIX)$(ROOT_DIR)/usr/include/asm
  197. ln -s $(KERNEL_SOURCE)/include/linux $(DEVEL_PREFIX)$(ROOT_DIR)/usr/include/linux
  198. find include/ -type f -depth -not -path "*CVS*" -exec install \
  199. -D -m 644 {} $(DEVEL_PREFIX)$(ROOT_DIR)/usr/'{}' ';'
  200. find include/bits/ -type f -depth -not -path "*CVS*" -exec install \
  201. -D -m 644 {} $(DEVEL_PREFIX)$(ROOT_DIR)/usr/'{}' ';'
  202. install -m 644 include/bits/uClibc_config.h $(DEVEL_PREFIX)$(ROOT_DIR)/usr/include/bits/
  203. $(MAKE) -C extra/gcc-uClibc install
  204. clean:
  205. @rm -rf tmp lib include/bits/uClibc_config.h uClibc_config.h
  206. - find include -type l -exec rm -f {} \;
  207. - find . \( -name \*.o -o -name \*.a -o -name \*.so -o -name core \) -exec rm -f {} \;
  208. $(MAKE) -C ldso clean
  209. $(MAKE) -C libc/unistd clean
  210. $(MAKE) -C libc/sysdeps/linux/common clean
  211. $(MAKE) -C libc/sysdeps/linux/$(TARGET_ARCH) clean
  212. $(MAKE) -C extra/gcc-uClibc clean
  213. .PHONY: dummy subdirs