Makefile 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  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: libc.a $(DO_SHARED) done
  33. libc.a: halfclean headers uClibc_config.h subdirs
  34. $(CROSS)ranlib libc.a
  35. shared: libc.a
  36. @rm -rf tmp
  37. @mkdir tmp
  38. @(cd tmp; CC=$(CC) /bin/sh ../extra/scripts/get-needed-libgcc-objects.sh)
  39. if [ -s ./tmp/libgcc-need.a ] ; then \
  40. $(CC) -g $(LDFLAGS) -shared -o $(SHARED_FULLNAME) \
  41. -Wl,-soname,$(SHARED_MAJORNAME) -Wl,--whole-archive \
  42. ./libc.a ./tmp/libgcc-need.a ; \
  43. else \
  44. $(CC) -g $(LDFLAGS) -shared -o $(SHARED_FULLNAME) \
  45. -Wl,-soname,$(SHARED_MAJORNAME) -Wl,--whole-archive \
  46. ./libc.a ; \
  47. fi
  48. @rm -rf tmp
  49. ln -sf $(SHARED_FULLNAME) $(SHARED_MAJORNAME)
  50. ln -sf $(SHARED_MAJORNAME) libc.so
  51. done: libc.a $(DO_SHARED)
  52. @echo
  53. @echo Finally finished compiling...
  54. @echo
  55. halfclean:
  56. @rm -f libc.a crt0.o uClibc_config.h
  57. @rm -f $(SHARED_FULLNAME) $(SHARED_MAJORNAME) libc.so
  58. headers: dummy
  59. @rm -f include/asm include/linux include/bits
  60. @ln -s $(KERNEL_SOURCE)/include/asm include/asm
  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 ../sysdeps/linux/$(TARGET_ARCH)/bits include/bits
  77. @ln -sf ../../../../uClibc_config.h sysdeps/linux/$(TARGET_ARCH)/bits/uClibc_config.h
  78. tags:
  79. ctags -R
  80. clean: subdirs_clean halfclean
  81. @rm -rf tmp
  82. rm -f include/asm include/linux include/bits
  83. subdirs: $(patsubst %, _dir_%, $(DIRS))
  84. subdirs_clean: $(patsubst %, _dirclean_%, $(DIRS) test)
  85. $(patsubst %, _dir_%, $(DIRS)) : dummy
  86. $(MAKE) -C $(patsubst _dir_%, %, $@)
  87. $(patsubst %, _dirclean_%, $(DIRS) test) : dummy
  88. $(MAKE) -C $(patsubst _dirclean_%, %, $@) clean
  89. install_new: install_runtime install_dev
  90. # Installs shared library
  91. install_runtime:
  92. ifneq ($(DO_SHARED),)
  93. install -d $(INSTALL_DIR)/lib
  94. install -m 644 $(SHARED_FULLNAME) $(INSTALL_DIR)/lib/
  95. (cd $(INSTALL_DIR)/lib;ln -sf $(SHARED_FULLNAME) $(SHARED_MAJORNAME))
  96. (cd $(INSTALL_DIR)/lib;ln -sf $(SHARED_MAJORNAME) libc.so)
  97. # ldconfig is really not necessary, and impossible to cross
  98. #ifeq ($(INSTALL_DIR),)
  99. # /sbin/ldconfig -n $(INSTALL_DIR)/lib
  100. #endif
  101. else
  102. echo shared library not installed
  103. endif
  104. # Installs development library and headers
  105. # This is done with the assumption that it can blow away anything
  106. # in $(INSTALL_DIR)/include. Probably true only if you're using
  107. # a packaging system.
  108. install_dev:
  109. install -d $(INSTALL_DIR)/include
  110. install -d $(INSTALL_DIR)/include/bits
  111. rm -f $(INSTALL_DIR)/include/asm
  112. rm -f $(INSTALL_DIR)/include/linux
  113. ln -s $(KERNEL_SOURCE)/include/asm $(INSTALL_DIR)/include/asm
  114. ln -s $(KERNEL_SOURCE)/include/linux $(INSTALL_DIR)/include/linux
  115. find include/ -type f -depth -not -path "*CVS*" -exec install -D -m 644 {} $(INSTALL_DIR)/'{}' ';'
  116. find include/bits/ -type f -depth -not -path "*CVS*" -exec install -D -m 644 {} $(INSTALL_DIR)/'{}' ';'
  117. install -m 644 include/bits/uClibc_config.h $(INSTALL_DIR)/include/bits/
  118. install -d $(INSTALL_DIR)/lib
  119. rm -f $(INSTALL_DIR)/lib/libc.a
  120. install -m 644 libc.a $(INSTALL_DIR)/lib/
  121. @if [ -f crt0.o ] ; then install -m 644 crt0.o $(INSTALL_DIR)/lib/; fi
  122. install -d $(INSTALL_DIR)/bin
  123. @if [ -f extra/gcc-uClibc/$(TARGET_ARCH)-uclibc-gcc ] ; then install -m 755 extra/gcc-uClibc/$(TARGET_ARCH)-uclibc-gcc $(INSTALL_DIR)/bin/ ; fi
  124. install:
  125. echo Consider using 'make install_new'
  126. @if [ `id -u` -ne 0 ]; then \
  127. echo "Aborting install -- You must be root."; \
  128. /bin/false; \
  129. fi;
  130. @if [ -n "$(DO_SHARED)" ] ; then \
  131. set -x; \
  132. mv -f $(INSTALL_DIR)/lib/$(SHARED_NAME) \
  133. $(INSTALL_DIR)/lib/$(SHARED_NAME).old > /dev/null 2>&1; \
  134. rm -f $(INSTALL_DIR)/lib/$(SHARED_NAME).old; \
  135. cp $(SHARED_NAME) $(INSTALL_DIR)/lib; \
  136. chmod 644 $(INSTALL_DIR)/lib/$(SHARED_NAME); \
  137. chown -R root.root $(INSTALL_DIR)/lib/$(SHARED_NAME); \
  138. rm -f $(INSTALL_DIR)/lib/libc.so; \
  139. ln -s $(INSTALL_DIR)/lib/$(SHARED_NAME) \
  140. $(INSTALL_DIR)/lib/libc.so; \
  141. /sbin/ldconfig; \
  142. fi;
  143. @if [ "$(HAS_MMU)" = "false" ] ; then \
  144. set -x; \
  145. rm -f $(INSTALL_DIR)/include/asm; \
  146. rm -f $(INSTALL_DIR)/include/linux; \
  147. mkdir -p $(INSTALL_DIR)/include/bits; \
  148. ln -s $(KERNEL_SOURCE)/include/asm $(INSTALL_DIR)/include/asm; \
  149. ln -s $(KERNEL_SOURCE)/include/linux $(INSTALL_DIR)/include/linux; \
  150. find include/ -type f -depth -print | cpio -pdmu $(INSTALL_DIR); \
  151. find include/bits/ -depth -print | cpio -pdmu $(INSTALL_DIR); \
  152. rm -f $(INSTALL_DIR)/lib/libc.a; \
  153. cp libc.a $(INSTALL_DIR)/lib; \
  154. chmod 644 $(INSTALL_DIR)/lib/libc.a; \
  155. chown -R root.root $(INSTALL_DIR)/lib/libc.a; \
  156. if [ -f crt0.o ] ; then \
  157. rm -f $(INSTALL_DIR)/lib/crt0.o; \
  158. cp crt0.o $(INSTALL_DIR)/lib ; \
  159. chmod 644 $(INSTALL_DIR)/lib/crt0.o; \
  160. chown -R root.root $(INSTALL_DIR)/lib/crt0.o; \
  161. fi; \
  162. chmod -R 775 `find $(INSTALL_DIR)/include -type d`; \
  163. chmod -R 644 `find $(INSTALL_DIR)/include -type f`; \
  164. chown -R root.root $(INSTALL_DIR)/include; \
  165. fi;
  166. uClibc_config.h: Config
  167. @echo "/* WARNING!!! AUTO-GENERATED FILE!!! DO NOT EDIT!!! */" > uClibc_config.h
  168. @echo "#if !defined __FEATURES_H && !defined __need_uClibc_config_h" >> uClibc_config.h
  169. @echo "#error Never include <bits/uClibc_config.h> directly; use <features.h> instead." >> uClibc_config.h
  170. @echo "#endif" >> uClibc_config.h
  171. @echo "#define linux 1" >> uClibc_config.h
  172. @echo "#define __linux__ 1" >> uClibc_config.h
  173. @if [ "$(HAS_MMU)" = "true" ] ; then \
  174. echo "#define __UCLIBC_HAS_MMU__ 1" >> uClibc_config.h ; \
  175. else \
  176. echo "#undef __UCLIBC_HAS_MMU__" >> uClibc_config.h ; \
  177. fi
  178. @if [ "$(HAS_FLOATS)" = "true" ] ; then \
  179. echo "#define __UCLIBC_HAS_FLOATS__ 1" >> uClibc_config.h ; \
  180. else \
  181. echo "#undef __UCLIBC_HAS_FLOATS__" >> uClibc_config.h ; \
  182. fi
  183. @if [ "$(HAS_LONG_LONG)" = "true" ] ; then \
  184. echo "#define __UCLIBC_HAS_LONG_LONG__ 1" >> uClibc_config.h ; \
  185. else \
  186. echo "#undef __UCLIBC_HAS_LONG_LONG__" >> uClibc_config.h ; \
  187. fi
  188. @if [ "$(HAS_LOCALE)" = "true" ] ; then \
  189. echo "#define __UCLIBC_HAS_LOCALE__ 1" >> uClibc_config.h ; \
  190. echo "#define __UCLIBC_LOCALE_DIR \""$(LOCALE_DIR)"\"" >> uClibc_config.h ; \
  191. else \
  192. echo "#undef __UCLIBC_HAS_LOCALE__" >> uClibc_config.h ; \
  193. fi
  194. @if [ "$(TARGET_ARCH)" = "m68k" ] ; then \
  195. echo "#define __VFORK_MACRO__ 1" >> uClibc_config.h ; \
  196. if [ `expr match "$(CC)" ".*\(m68k-elf-.*\)"`x = x ]; then \
  197. echo "#define const" >> uClibc_config.h ; \
  198. echo "#define __const" >> uClibc_config.h ; \
  199. echo "#define __extension" >> uClibc_config.h ; \
  200. fi; \
  201. else \
  202. echo "#undef __VFORK_MACRO__" >> uClibc_config.h ; \
  203. fi
  204. @if [ "$(TARGET_ARCH)" = "sh" ] ; then \
  205. echo "#define NO_UNDERSCORES 1" >> uClibc_config.h ; \
  206. else \
  207. echo "#undef NO_UNDERSCORES" >> uClibc_config.h ; \
  208. fi
  209. .PHONY: dummy