Makefile 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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
  29. ifeq ($(strip $(HAS_MMU)),true)
  30. DO_SHARED=shared
  31. endif
  32. all: $(STATIC_NAME) $(DO_SHARED) done
  33. $(STATIC_NAME): halfclean headers 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; ar -x ../$(STATIC_NAME))
  41. @(cd tmp; CC=$(CC) /bin/sh ../extra/scripts/get-needed-libgcc-objects.sh)
  42. $(CC) -s -nostdlib -shared -o $(SHARED_NAME) -Wl,-soname,$(SHARED_NAME) tmp/*.o
  43. @rm -rf tmp
  44. done: $(STATIC_NAME) $(DO_SHARED)
  45. @echo
  46. @echo Finally finished compiling...
  47. @echo
  48. halfclean:
  49. @rm -f $(STATIC_NAME) $(SHARED_NAME) crt0.o
  50. headers: dummy
  51. @rm -f include/asm include/linux include/bits
  52. @ln -s $(KERNEL_SOURCE)/include/asm include/asm
  53. @if [ ! -f include/asm/unistd.h ] ; then \
  54. echo " "; \
  55. echo "The path '$(KERNEL_SOURCE)/include/asm' doesn't exist."; \
  56. echo "I bet you didn't set KERNEL_SOURCE, TARGET_ARCH or HAS_MMU in \`Config'"; \
  57. echo "correctly. Please edit \`Config' and fix these settings."; \
  58. echo " "; \
  59. /bin/false; \
  60. fi;
  61. @if [ $(HAS_MMU) != "true" ] && [ $(TARGET_ARCH) = "i386" ] ; then \
  62. echo "WARNING: I bet your x86 system really has an MMU, right?"; \
  63. echo " malloc and friends won't work unless you fix \`Config'"; \
  64. echo " "; \
  65. sleep 10; \
  66. fi;
  67. @ln -s $(KERNEL_SOURCE)/include/linux include/linux
  68. @ln -s ../sysdeps/linux/$(TARGET_ARCH)/bits include/bits
  69. tags:
  70. ctags -R
  71. clean: subdirs_clean
  72. @rm -rf tmp
  73. rm -f $(STATIC_NAME) crt0.o $(SHARED_NAME)
  74. rm -f include/asm include/linux include/bits
  75. subdirs: $(patsubst %, _dir_%, $(DIRS))
  76. subdirs_clean: $(patsubst %, _dirclean_%, $(DIRS) test)
  77. $(patsubst %, _dir_%, $(DIRS)) : dummy
  78. $(MAKE) -C $(patsubst _dir_%, %, $@)
  79. $(patsubst %, _dirclean_%, $(DIRS) test) : dummy
  80. $(MAKE) -C $(patsubst _dirclean_%, %, $@) clean
  81. install:
  82. @if [ `id -u` -ne 0 ]; then \
  83. echo "Aborting install -- You must be root."; \
  84. /bin/false; \
  85. fi;
  86. @if [ -n "$(DO_SHARED)" ] ; then \
  87. set -x; \
  88. mv -f $(INSTALL_DIR)/lib/$(SHARED_NAME) \
  89. $(INSTALL_DIR)/lib/$(SHARED_NAME).old > /dev/null 2>&1; \
  90. rm -f $(INSTALL_DIR)/lib/$(SHARED_NAME).old; \
  91. cp $(SHARED_NAME) $(INSTALL_DIR)/lib; \
  92. chmod 644 $(INSTALL_DIR)/lib/$(SHARED_NAME); \
  93. chown -R root.root $(INSTALL_DIR)/lib/$(SHARED_NAME); \
  94. rm -f $(INSTALL_DIR)/lib/libuClibc.so; \
  95. ln -s $(INSTALL_DIR)/lib/$(SHARED_NAME) \
  96. $(INSTALL_DIR)/lib/libuClibc.so; \
  97. ldconfig; \
  98. fi;
  99. @if [ "$(HAS_MMU)" = "false" ] ; then \
  100. set -x; \
  101. rm -f $(INSTALL_DIR)/include/asm; \
  102. rm -f $(INSTALL_DIR)/include/linux; \
  103. mkdir -p $(INSTALL_DIR)/include/bits; \
  104. ln -s $(KERNEL_SOURCE)/include/asm $(INSTALL_DIR)/include/asm; \
  105. ln -s $(KERNEL_SOURCE)/include/linux $(INSTALL_DIR)/include/linux; \
  106. find include/ -type f -depth -print | cpio -pdmu $(INSTALL_DIR); \
  107. find include/bits/ -depth -print | cpio -pdmu $(INSTALL_DIR); \
  108. rm -f $(INSTALL_DIR)/lib/$(STATIC_NAME); \
  109. cp $(STATIC_NAME) $(INSTALL_DIR)/lib; \
  110. chmod 644 $(INSTALL_DIR)/lib/$(STATIC_NAME); \
  111. chown -R root.root $(INSTALL_DIR)/lib/$(STATIC_NAME); \
  112. if [ -f crt0.o ] ; then \
  113. rm -f $(INSTALL_DIR)/lib/crt0.o; \
  114. cp crt0.o $(INSTALL_DIR)/lib ; \
  115. chmod 644 $(INSTALL_DIR)/lib/crt0.o; \
  116. chown -R root.root $(INSTALL_DIR)/lib/crt0.o; \
  117. fi; \
  118. chmod -R 775 `find $(INSTALL_DIR)/include -type d`; \
  119. chmod -R 644 `find $(INSTALL_DIR)/include -type f`; \
  120. chown -R root.root $(INSTALL_DIR)/include; \
  121. fi;
  122. .PHONY: dummy