Makefile 7.1 KB

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