Makefile 7.8 KB

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