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