Makefile 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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. TOPDIR=../
  23. include $(TOPDIR)Rules.mak
  24. LIBC=$(TOPDIR)libc.a
  25. CSRC=execl.c execlp.c execv.c execvep.c execvp.c getcwd.c getopt.c \
  26. sleep.c getpass.c sysconf_src.c
  27. # TESTING -- comment this out if it breaks for you
  28. ifeq ($(TARGET_ARCH), $(NATIVE_ARCH))
  29. SYSCONF = sysconf_native
  30. else
  31. SYSCONF = sysconf_$(TARGET_ARCH).c
  32. endif
  33. COBJS=$(patsubst %.c,%.o, $(CSRC))
  34. MSRC=gnu_getopt.c
  35. MOBJ=_gnu_getopt_internal.o gnu_getopt_long.o gnu_getopt_long_only.o
  36. # WARNING! MOBJ _must_ come after COBJS for link to pick getopt
  37. # over gnu_getopt when appropriate.
  38. OBJS=$(COBJS) $(MOBJ)
  39. all: $(SYSCONF) $(OBJS) $(LIBC)
  40. $(LIBC): ar-target subdirs
  41. ar-target: $(OBJS)
  42. $(AR) $(ARFLAGS) $(LIBC) $(OBJS)
  43. # We are cross-compiling so use the generic sysconf.c.
  44. sysconf_$(TARGET_ARCH).c: sysconf.c
  45. @echo warning: sysconf_$(NATIVE_ARCH).c is older then sysconf.c so using generic sysconf.c
  46. @echo To build sysconf_$(NATIVE_ARCH).c run gen_sysconf \> sysconf_$(NATIVE_ARCH).c on
  47. @echo your target platform, place in the unistd directory, and rebuild
  48. cp -f sysconf.c sysconf_src.c
  49. # We are compiling for the native platform, so build an optimized sysconf.c.
  50. sysconf_native: sysconf.c
  51. $(CC) $(CFLAGS) -D_UCLIBC_GENERATE_SYSCONF_ARCH -c sysconf.c -o sysconf_tester.o
  52. $(CC) $(CFLAGS) -D_UCLIBC_GENERATE_SYSCONF_ARCH -c ../sysdeps/linux/common/getpagesize.c -o getpagesize_tester.o
  53. @ld -r -o gen_sysconf_tester.o sysconf_tester.o getpagesize_tester.o
  54. @if nm -s gen_sysconf_tester.o | grep -v "U errno" | grep " U " ;\
  55. then \
  56. echo warning: missing symbols in gen_sysconf_tester.o so using generic sysconf.c ;\
  57. cp -f sysconf.c sysconf_src.c ;\
  58. else \
  59. if ../extra/gcc-uClibc/gcc-uClibc-$(NATIVE_ARCH) -static -D_UCLIBC_GENERATE_SYSCONF_MAIN sysconf.c sysconf_tester.o -o gen_sysconf && \
  60. ./gen_sysconf > sysconf_$(NATIVE_ARCH).c ;\
  61. then \
  62. echo successfully built sysconf_$(NATIVE_ARCH).c ;\
  63. else \
  64. echo warning: build of gen_sysconf failed so using generic sysconf.c ;\
  65. cp -f sysconf.c sysconf_$(NATIVE_ARCH).c ;\
  66. fi ;\
  67. fi
  68. sysconf_src.c: sysconf_$(TARGET_ARCH).c
  69. cp -f sysconf_$(TARGET_ARCH).c sysconf_src.c
  70. $(COBJS): %.o : %.c
  71. $(CC) $(CFLAGS) -c $< -o $@
  72. $(STRIPTOOL) -x -R .note -R .comment $*.o
  73. $(MOBJ): $(MSRC)
  74. $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o
  75. $(STRIPTOOL) -x -R .note -R .comment $*.o
  76. $(OBJ): Makefile
  77. subdirs: $(patsubst %, _dir_%, $(DIRS))
  78. subdirs_clean: $(patsubst %, _dirclean_%, $(DIRS))
  79. $(patsubst %, _dir_%, $(DIRS)) : dummy
  80. $(MAKE) -C $(patsubst _dir_%, %, $@)
  81. $(patsubst %, _dirclean_%, $(DIRS)) : dummy
  82. $(MAKE) -C $(patsubst _dirclean_%, %, $@) clean
  83. clean:
  84. rm -f *.[oa] *~ core gen_sysconf sysconf_*.c