Makefile 7.6 KB

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