Makefile 8.2 KB

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