Makefile 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. # Makefile for uClibc
  2. #
  3. # Copyright (C) 2000 by Lineo, inc.
  4. # Copyright (C) 2000,2001 Erik Andersen <andersen@uclibc.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. # Makefile for uClibc
  20. #
  21. # Derived in part from the Linux-8086 C library, the GNU C Library, and several
  22. # other sundry sources. Files within this library are copyright by their
  23. # respective copyright holders.
  24. #--------------------------------------------------------
  25. #
  26. #There are a number of configurable options in "Config"
  27. #
  28. #--------------------------------------------------------
  29. TOPDIR=./
  30. include Rules.mak
  31. DIRS = extra ldso libc libcrypt libresolv libutil libm #libpthread
  32. all: headers uClibc_config.h subdirs shared done
  33. Config:
  34. @echo
  35. @echo "You didn't read the README, did you... =)"
  36. @echo "Choose a configuration file in extras/Config/ and copy it to ./Config"
  37. @echo
  38. @exit 1
  39. shared:
  40. ifeq ($(strip $(HAVE_SHARED)),true)
  41. @$(MAKE) -C libc shared
  42. @$(MAKE) -C ldso shared
  43. @$(MAKE) -C libcrypt shared
  44. @$(MAKE) -C libresolv shared
  45. @$(MAKE) -C libutil shared
  46. @$(MAKE) -C libm shared
  47. #@$(MAKE) -C libpthread shared
  48. else
  49. @echo
  50. @echo Not building shared libraries...
  51. @echo
  52. endif
  53. done: shared
  54. @echo
  55. @echo Finally finished compiling...
  56. @echo
  57. headers: dummy
  58. @rm -f include/asm include/linux include/bits
  59. @if [ $(TARGET_ARCH) = "powerpc" ];then \
  60. ln -fs $(KERNEL_SOURCE)/include/asm-ppc include/asm; \
  61. elif [ $(TARGET_ARCH) = "v850" ];then \
  62. ln -fs $(KERNEL_SOURCE)/include/asm-v850 include/asm; \
  63. else \
  64. if [ $(HAS_MMU) != "true" ]; then \
  65. ln -fs $(KERNEL_SOURCE)/include/asm-$(TARGET_ARCH)nommu include/asm;\
  66. else \
  67. ln -fs $(KERNEL_SOURCE)/include/asm-$(TARGET_ARCH) include/asm; \
  68. fi; \
  69. fi;
  70. @if [ ! -f include/asm/unistd.h ] ; then \
  71. echo " "; \
  72. echo "The path '$(KERNEL_SOURCE)/include/asm' doesn't exist."; \
  73. echo "I bet you didn't set KERNEL_SOURCE, TARGET_ARCH or HAS_MMU in \`Config'"; \
  74. echo "correctly. Please edit \`Config' and fix these settings."; \
  75. echo " "; \
  76. /bin/false; \
  77. fi;
  78. @if [ $(HAS_MMU) != "true" ] && [ $(TARGET_ARCH) = "i386" ] ; then \
  79. echo "WARNING: I bet your x86 system really has an MMU, right?"; \
  80. echo " malloc and friends won't work unless you fix \`Config'"; \
  81. echo " "; \
  82. sleep 10; \
  83. fi;
  84. @ln -fs $(KERNEL_SOURCE)/include/linux include/linux
  85. @ln -fs ../libc/sysdeps/linux/$(TARGET_ARCH)/bits include/bits
  86. (cd include/bits; ln -sf ../../../../../uClibc_config.h uClibc_config.h)
  87. $(MAKE) -C libc/sysdeps/linux/$(TARGET_ARCH) headers
  88. uClibc_config.h: Makefile Config
  89. @echo "/* WARNING!!! AUTO-GENERATED FILE!!! DO NOT EDIT!!! */" > uClibc_config.h
  90. @echo "#if !defined __FEATURES_H && !defined __need_uClibc_config_h" >> uClibc_config.h
  91. @echo "#error Never include <bits/uClibc_config.h> directly; use <features.h> instead." >> uClibc_config.h
  92. @echo "#endif" >> uClibc_config.h
  93. @echo "#define linux 1" >> uClibc_config.h
  94. @echo "#define __linux__ 1" >> uClibc_config.h
  95. @if [ "$(INCLUDE_IPV6)" = "true" ] ; then \
  96. echo "#define __UCLIBC_HAS_IPV6__ 1" >> uClibc_config.h ; \
  97. else \
  98. echo "#undef __UCLIBC_HAS_IPV6__" >> uClibc_config.h ; \
  99. fi
  100. @if [ "$(HAS_MMU)" = "true" ] ; then \
  101. echo "#define __UCLIBC_HAS_MMU__ 1" >> uClibc_config.h ; \
  102. else \
  103. echo "#undef __UCLIBC_HAS_MMU__" >> uClibc_config.h ; \
  104. fi
  105. @if [ "$(HAS_FLOATING_POINT)" = "true" ] ; then \
  106. echo "#define __UCLIBC_HAS_FLOATS__ 1" >> uClibc_config.h ; \
  107. else \
  108. echo "#undef __UCLIBC_HAS_FLOATS__" >> uClibc_config.h ; \
  109. fi
  110. @if [ "$(HAS_LONG_LONG)" = "true" ] ; then \
  111. echo "#define __UCLIBC_HAS_LONG_LONG__ 1" >> uClibc_config.h ; \
  112. else \
  113. echo "#undef __UCLIBC_HAS_LONG_LONG__" >> uClibc_config.h ; \
  114. fi
  115. @if [ "$(HAS_LOCALE)" = "true" ] ; then \
  116. echo "#define __UCLIBC_HAS_LOCALE__ 1" >> uClibc_config.h ; \
  117. echo "#define __UCLIBC_LOCALE_DIR \""$(LOCALE_DIR)"\"" >> uClibc_config.h ; \
  118. else \
  119. echo "#undef __UCLIBC_HAS_LOCALE__" >> uClibc_config.h ; \
  120. fi
  121. @if [ "$(HAVE_ELF)" = "false" ] ; then \
  122. echo "#undef HAVE_ELF" >> uClibc_config.h ; \
  123. else \
  124. echo "#define HAVE_ELF 1" >> uClibc_config.h ; \
  125. fi
  126. @if [ "$(HAVE_SHARED)" = "false" ] ; then \
  127. echo "#undef HAVE_SHARED" >> uClibc_config.h ; \
  128. else \
  129. echo "#define HAVE_SHARED 1" >> uClibc_config.h ; \
  130. fi
  131. @if [ "$(TARGET_ARCH)" = "sh" ] ; then \
  132. echo "#define NO_UNDERSCORES 1" >> uClibc_config.h ; \
  133. else \
  134. echo "#undef NO_UNDERSCORES" >> uClibc_config.h ; \
  135. fi
  136. @if [ "$(INCLUDE_RPC)" = "true" ] ; then \
  137. echo "#define __UCLIBC_HAS_RPC__ 1" >> uClibc_config.h ; \
  138. else \
  139. echo "#undef __UCLIBC_HAS_RPC__" >> uClibc_config.h ; \
  140. fi
  141. @if [ "$(UNIFIED_SYSCALL)" = "true" ] ; then \
  142. echo "#define __UCLIBC_USE_UNIFIED_SYSCALL__ 1" >> uClibc_config.h ; \
  143. else \
  144. echo "#undef __UCLIBC_USE_UNIFIED_SYSCALL__" >> uClibc_config.h ; \
  145. fi
  146. @echo "#define C_SYMBOL_PREFIX "\""$(C_SYMBOL_PREFIX)"\" >> uClibc_config.h
  147. @if [ "$(DOLFS)" = "true" ] ; then \
  148. echo "#define __UCLIBC_HAVE_LFS__ 1" >> uClibc_config.h ; \
  149. else \
  150. echo "#undef __UCLIBC_HAVE_LFS__" >> uClibc_config.h ; \
  151. fi
  152. subdirs: $(patsubst %, _dir_%, $(DIRS))
  153. $(patsubst %, _dir_%, $(DIRS)) : dummy
  154. $(MAKE) -C $(patsubst _dir_%, %, $@)
  155. tags:
  156. ctags -R
  157. install: install_dev install_runtime install_gcc
  158. # Installs header files and development library links.
  159. install_dev:
  160. install -d $(PREFIX)$(DEVEL_PREFIX)/lib
  161. install -m 644 lib/*.[ao] $(PREFIX)$(DEVEL_PREFIX)/lib/
  162. install -d $(PREFIX)$(DEVEL_PREFIX)/usr/lib
  163. install -d $(PREFIX)$(DEVEL_PREFIX)/include
  164. cp -LR include/ $(PREFIX)$(DEVEL_PREFIX)/
  165. chmod 755 `find $(PREFIX)$(DEVEL_PREFIX) -type d`
  166. chmod 644 `find $(PREFIX)$(DEVEL_PREFIX)/include -name '*.h'`
  167. ifeq ($(strip $(HAVE_SHARED)),true)
  168. find lib/ -type l -name '*.so' -exec cp -a {} $(PREFIX)$(DEVEL_PREFIX)/lib ';'
  169. endif
  170. # Installs run-time libraries and helper apps onto the host system
  171. # allowing cross development. If you want to deploy to a target
  172. # system, use the "install_target" target instead...
  173. install_runtime:
  174. ifeq ($(strip $(HAVE_SHARED)),true)
  175. install -d $(PREFIX)$(DEVEL_PREFIX)/lib
  176. install -d $(PREFIX)$(DEVEL_PREFIX)/bin
  177. install -m 644 lib/lib*-$(MAJOR_VERSION).$(MINOR_VERSION).so $(PREFIX)$(DEVEL_PREFIX)/lib
  178. cp -a lib/*.so.* $(PREFIX)$(DEVEL_PREFIX)/lib
  179. install -m 755 ldso/util/ldd $(PREFIX)$(DEVEL_PREFIX)/bin
  180. install -m 755 ldso/util/readelf $(PREFIX)$(DEVEL_PREFIX)/bin
  181. install -d $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin
  182. ln -fs $(DEVEL_PREFIX)/bin/ldd $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-ldd
  183. ln -fs $(DEVEL_PREFIX)/bin/readelf $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-readelf
  184. if [ -x lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).so ] ; then \
  185. install -m 755 lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).so $(PREFIX)$(DEVEL_PREFIX)/lib; \
  186. mkdir -p $(PREFIX)$(SHARED_LIB_LOADER_PATH); \
  187. ln -s $(DEVEL_PREFIX)/lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).so \
  188. $(PREFIX)$(SHARED_LIB_LOADER_PATH)/$(UCLIBC_LDSO) || true; \
  189. fi;
  190. if [ -x ldso/util/ldconfig ] ; then \
  191. install -d $(PREFIX)$(DEVEL_PREFIX)/etc; \
  192. install -m 755 ldso/util/ldconfig $(PREFIX)$(DEVEL_PREFIX)/bin; \
  193. ln -fs $(DEVEL_PREFIX)/sbin/ldconfig $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-ldconfig; \
  194. fi;
  195. endif
  196. install_gcc:
  197. $(MAKE) -C extra/gcc-uClibc install
  198. # Installs run-time libraries and helper apps in preparation for
  199. # deploying onto a target system, but installed below wherever
  200. # $PREFIX is set to, allowing you to package up the result for
  201. # deployment onto your target system.
  202. install_target:
  203. ifeq ($(strip $(HAVE_SHARED)),true)
  204. install -d $(PREFIX)$(TARGET_PREFIX)/lib
  205. install -d $(PREFIX)$(TARGET_PREFIX)/sbin
  206. install -d $(PREFIX)$(TARGET_PREFIX)/usr/bin
  207. install -m 644 lib/lib*-$(MAJOR_VERSION).$(MINOR_VERSION).so $(PREFIX)$(TARGET_PREFIX)/lib
  208. cp -a lib/*.so.* $(PREFIX)$(TARGET_PREFIX)/lib
  209. install -m 755 ldso/util/ldd $(PREFIX)$(TARGET_PREFIX)/usr/bin
  210. install -m 755 ldso/util/readelf $(PREFIX)$(TARGET_PREFIX)/usr/bin
  211. if [ -x lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).so ] ; then \
  212. install -m 755 lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).so $(PREFIX)$(TARGET_PREFIX)/lib; \
  213. mkdir -p $(PREFIX)$(SHARED_LIB_LOADER_PATH); \
  214. ln -s $(TARGET_PREFIX)/lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).so \
  215. $(PREFIX)$(SHARED_LIB_LOADER_PATH)/$(UCLIBC_LDSO) || true; \
  216. fi;
  217. if [ -x ldso/util/ldconfig ] ; then \
  218. install -d $(PREFIX)$(TARGET_PREFIX)/etc; \
  219. install -m 755 ldso/util/ldconfig $(PREFIX)$(TARGET_PREFIX)/sbin; \
  220. fi;
  221. endif
  222. distclean clean:
  223. @rm -rf tmp lib include/bits/uClibc_config.h uClibc_config.h
  224. - find include -type l -exec rm -f {} \;
  225. - find . \( -name \*.o -o -name \*.a -o -name \*.so -o -name core -o -name .\#\* \) -exec rm -f {} \;
  226. $(MAKE) -C test clean
  227. $(MAKE) -C ldso clean
  228. $(MAKE) -C libc/unistd clean
  229. $(MAKE) -C libc/sysdeps/linux/common clean
  230. $(MAKE) -C libc/sysdeps/linux/$(TARGET_ARCH) clean
  231. $(MAKE) -C extra/gcc-uClibc clean
  232. dist release: distclean
  233. cd ..; \
  234. rm -rf uClibc-$(VERSION); \
  235. cp -a uClibc uClibc-$(VERSION); \
  236. \
  237. find uClibc-$(VERSION)/ -type d \
  238. -name CVS \
  239. -exec rm -rf {} \; ; \
  240. \
  241. tar -cvzf uClibc-$(VERSION).tar.gz --exclude CVS uClibc-$(VERSION)/;
  242. .PHONY: dummy subdirs