Makefile 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. # Makefile for uClibc
  2. #
  3. # Copyright (C) 2000 by Lineo, inc.
  4. #
  5. # This program is free software; you can redistribute it and/or modify it under
  6. # the terms of the GNU Library General Public License as published by the Free
  7. # Software Foundation; either version 2 of the License, or (at your option) any
  8. # later version.
  9. #
  10. # This program is distributed in the hope that it will be useful, but WITHOUT
  11. # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  12. # FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more
  13. # details.
  14. #
  15. # You should have received a copy of the GNU Library General Public License
  16. # along with this program; if not, write to the Free Software Foundation, Inc.,
  17. # 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  18. #
  19. # Derived in part from the Linux-8086 C library, the GNU C Library, and several
  20. # other sundry sources. Files within this library are copyright by their
  21. # respective copyright holders.
  22. #--------------------------------------------------------
  23. #
  24. #There are a number of configurable options in "Config"
  25. #
  26. #--------------------------------------------------------
  27. TOPDIR=./
  28. include Rules.mak
  29. DIRS = extra misc pwd_grp stdio string termios inet signal stdlib sysdeps unistd crypt libutil libm
  30. ifeq ($(strip $(HAS_MMU)),true)
  31. DO_SHARED=shared
  32. endif
  33. all: halfclean headers uClibc_config.h subdirs $(LIBNAME) $(DO_SHARED) done
  34. $(LIBNAME): subdirs
  35. $(CROSS)ranlib $(LIBNAME)
  36. shared: $(LIBNAME)
  37. @rm -rf tmp
  38. @mkdir tmp
  39. @$(MAKE) -C ld.so-1 ldso
  40. @(cd tmp; CC=$(CC) /bin/sh ../extra/scripts/get-needed-libgcc-objects.sh)
  41. if [ -s ./tmp/libgcc-need.a ] ; then \
  42. $(CC) -g $(LDFLAGS) -shared -o $(SHARED_FULLNAME) \
  43. -Wl,-soname,$(SHARED_MAJORNAME) -Wl,--whole-archive \
  44. ./$(LIBNAME) ./tmp/libgcc-need.a \
  45. $(LDSO) ; \
  46. else \
  47. $(CC) -g $(LDFLAGS) -shared -o $(SHARED_FULLNAME) \
  48. -Wl,-soname,$(SHARED_MAJORNAME) -Wl,--whole-archive \
  49. ./$(LIBNAME) $(LDSO) ; \
  50. fi
  51. @rm -rf tmp
  52. ln -sf $(SHARED_FULLNAME) $(SHARED_MAJORNAME)
  53. ln -sf $(SHARED_MAJORNAME) libc.so
  54. @$(MAKE) -C crypt shared
  55. @$(MAKE) -C libutil shared
  56. @$(MAKE) -C libm shared
  57. @$(MAKE) -C ld.so-1
  58. done: $(LIBNAME) $(DO_SHARED)
  59. @echo
  60. @echo Finally finished compiling...
  61. @echo
  62. halfclean:
  63. @rm -f $(LIBNAME) crt0.o uClibc_config.h
  64. @rm -f $(SHARED_FULLNAME) $(SHARED_MAJORNAME) uClibc-0.* libc.so*
  65. headers: dummy
  66. @rm -f include/asm include/linux include/bits
  67. @ln -s $(KERNEL_SOURCE)/include/asm include/asm
  68. @if [ ! -f include/asm/unistd.h ] ; then \
  69. echo " "; \
  70. echo "The path '$(KERNEL_SOURCE)/include/asm' doesn't exist."; \
  71. echo "I bet you didn't set KERNEL_SOURCE, TARGET_ARCH or HAS_MMU in \`Config'"; \
  72. echo "correctly. Please edit \`Config' and fix these settings."; \
  73. echo " "; \
  74. /bin/false; \
  75. fi;
  76. @if [ $(HAS_MMU) != "true" ] && [ $(TARGET_ARCH) = "i386" ] ; then \
  77. echo "WARNING: I bet your x86 system really has an MMU, right?"; \
  78. echo " malloc and friends won't work unless you fix \`Config'"; \
  79. echo " "; \
  80. sleep 10; \
  81. fi;
  82. @ln -s $(KERNEL_SOURCE)/include/linux include/linux
  83. @ln -s ../sysdeps/linux/$(TARGET_ARCH)/bits include/bits
  84. @ln -sf ../../../../uClibc_config.h sysdeps/linux/$(TARGET_ARCH)/bits/uClibc_config.h
  85. tags:
  86. ctags -R
  87. clean: subdirs_clean halfclean
  88. @rm -rf tmp
  89. rm -f include/asm include/linux include/bits
  90. @$(MAKE) -C ld.so-1 clean
  91. subdirs: $(patsubst %, _dir_%, $(DIRS))
  92. subdirs_clean: $(patsubst %, _dirclean_%, $(DIRS) test)
  93. $(patsubst %, _dir_%, $(DIRS)) : dummy
  94. $(MAKE) -C $(patsubst _dir_%, %, $@)
  95. $(patsubst %, _dirclean_%, $(DIRS) test) : dummy
  96. $(MAKE) -C $(patsubst _dirclean_%, %, $@) clean
  97. install: install_runtime install_dev install_ldso
  98. # Installs shared library
  99. install_runtime:
  100. @$(MAKE) -C crypt install
  101. @$(MAKE) -C libutil install
  102. @$(MAKE) -C libm install
  103. ifneq ($(DO_SHARED),)
  104. install -d $(INSTALL_DIR)/lib
  105. rm -rf $(INSTALL_DIR)/lib/$(SHARED_FULLNAME)
  106. rm -rf $(INSTALL_DIR)/lib/$(SHARED_MAJORNAME)
  107. rm -rf $(INSTALL_DIR)/lib/libc.so
  108. install -m 755 $(SHARED_FULLNAME) $(INSTALL_DIR)/lib/
  109. (cd $(INSTALL_DIR)/lib;ln -sf $(SHARED_FULLNAME) $(SHARED_MAJORNAME))
  110. (cd $(INSTALL_DIR)/lib;ln -sf $(SHARED_MAJORNAME) libc.so)
  111. # ldconfig is really not necessary, and impossible to cross
  112. #ifeq ($(INSTALL_DIR),)
  113. # /sbin/ldconfig -n $(INSTALL_DIR)/lib
  114. #endif
  115. else
  116. echo shared library not installed
  117. endif
  118. # Installs development library and headers
  119. # This is done with the assumption that it can blow away anything
  120. # in $(INSTALL_DIR)/include. Probably true only if you're using
  121. # a packaging system.
  122. install_dev:
  123. install -d $(INSTALL_DIR)/include
  124. install -d $(INSTALL_DIR)/include/bits
  125. rm -f $(INSTALL_DIR)/include/asm
  126. rm -f $(INSTALL_DIR)/include/linux
  127. ln -s $(KERNEL_SOURCE)/include/asm $(INSTALL_DIR)/include/asm
  128. ln -s $(KERNEL_SOURCE)/include/linux $(INSTALL_DIR)/include/linux
  129. find include/ -type f -depth -not -path "*CVS*" -exec install -D -m 644 {} $(INSTALL_DIR)/'{}' ';'
  130. find include/bits/ -type f -depth -not -path "*CVS*" -exec install -D -m 644 {} $(INSTALL_DIR)/'{}' ';'
  131. install -m 644 include/bits/uClibc_config.h $(INSTALL_DIR)/include/bits/
  132. install -d $(INSTALL_DIR)/lib
  133. rm -f $(INSTALL_DIR)/lib/$(LIBNAME)
  134. install -m 644 $(LIBNAME) $(INSTALL_DIR)/lib/
  135. @if [ -f crt0.o ] ; then install -m 644 crt0.o $(INSTALL_DIR)/lib/; fi
  136. install -d $(INSTALL_DIR)/bin
  137. $(MAKE) -C extra/gcc-uClibc install
  138. install_ldso:
  139. ifeq ($(strip $(DO_SHARED)),shared)
  140. $(MAKE) -C ld.so-1 install
  141. install -d $(INSTALL_DIR)/etc
  142. $(TOPDIR)ld.so-1/util/ldconfig
  143. else
  144. @echo "Skipping shared library support"
  145. endif
  146. uClibc_config.h: Config
  147. @echo "/* WARNING!!! AUTO-GENERATED FILE!!! DO NOT EDIT!!! */" > uClibc_config.h
  148. @echo "#if !defined __FEATURES_H && !defined __need_uClibc_config_h" >> uClibc_config.h
  149. @echo "#error Never include <bits/uClibc_config.h> directly; use <features.h> instead." >> uClibc_config.h
  150. @echo "#endif" >> uClibc_config.h
  151. @echo "#define linux 1" >> uClibc_config.h
  152. @echo "#define __linux__ 1" >> uClibc_config.h
  153. @if [ "$(HAS_MMU)" = "true" ] ; then \
  154. echo "#define __UCLIBC_HAS_MMU__ 1" >> uClibc_config.h ; \
  155. else \
  156. echo "#undef __UCLIBC_HAS_MMU__" >> uClibc_config.h ; \
  157. fi
  158. @if [ "$(HAS_FLOATS)" = "true" ] ; then \
  159. echo "#define __UCLIBC_HAS_FLOATS__ 1" >> uClibc_config.h ; \
  160. else \
  161. echo "#undef __UCLIBC_HAS_FLOATS__" >> uClibc_config.h ; \
  162. fi
  163. @if [ "$(HAS_DOUBLE)" = "true" ] ; then \
  164. echo "#define __UCLIBC_HAS_DOUBLE__ 1" >> uClibc_config.h ; \
  165. else \
  166. echo "#undef __UCLIBC_HAS_DOUBLE__" >> uClibc_config.h ; \
  167. fi
  168. @if [ "$(HAS_LONG_DOUBLE)" = "true" ] ; then \
  169. echo "#define __UCLIBC_HAS_LONG_DOUBLE__ 1" >> uClibc_config.h ; \
  170. else \
  171. echo "#undef __UCLIBC_HAS_LONG_DOUBLE__" >> uClibc_config.h ; \
  172. fi
  173. @if [ "$(HAS_LONG_LONG)" = "true" ] ; then \
  174. echo "#define __UCLIBC_HAS_LONG_LONG__ 1" >> uClibc_config.h ; \
  175. else \
  176. echo "#undef __UCLIBC_HAS_LONG_LONG__" >> uClibc_config.h ; \
  177. fi
  178. @if [ "$(HAS_LOCALE)" = "true" ] ; then \
  179. echo "#define __UCLIBC_HAS_LOCALE__ 1" >> uClibc_config.h ; \
  180. echo "#define __UCLIBC_LOCALE_DIR \""$(LOCALE_DIR)"\"" >> uClibc_config.h ; \
  181. else \
  182. echo "#undef __UCLIBC_HAS_LOCALE__" >> uClibc_config.h ; \
  183. fi
  184. @if [ "$(TARGET_ARCH)" = "m68k" ] ; then \
  185. echo "#define __VFORK_MACRO__ 1" >> uClibc_config.h ; \
  186. if [ `expr match "$(CC)" ".*\(m68k-elf-.*\)"`x = x ]; then \
  187. echo "#define const" >> uClibc_config.h ; \
  188. echo "#define __const" >> uClibc_config.h ; \
  189. echo "#define __extension" >> uClibc_config.h ; \
  190. fi; \
  191. else \
  192. echo "#undef __VFORK_MACRO__" >> uClibc_config.h ; \
  193. fi
  194. @if [ "$(TARGET_ARCH)" = "sh" ] ; then \
  195. echo "#define NO_UNDERSCORES 1" >> uClibc_config.h ; \
  196. else \
  197. echo "#undef NO_UNDERSCORES" >> uClibc_config.h ; \
  198. fi
  199. @if [ "$(INCLUDE_RPC)" = "true" ] ; then \
  200. echo "#define __UCLIBC_HAS_RPC__ 1" >> uClibc_config.h ; \
  201. else \
  202. echo "#undef __UCLIBC_HAS_RPC__" >> uClibc_config.h ; \
  203. fi
  204. .PHONY: dummy subdirs