Makefile 7.3 KB

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