Makefile 7.2 KB

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