Makefile 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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. #
  20. # Derived in part from the Linux-8086 C library, the GNU C Library, and several
  21. # other sundry sources. Files within this library are copyright by their
  22. # respective copyright holders.
  23. TOPDIR=../../
  24. include $(TOPDIR)Rules.mak
  25. DIRS:=
  26. CSRC=execl.c execlp.c execv.c execvep.c execvp.c execle.c \
  27. sleep.c usleep.c getpass.c sysconf_src.c getlogin.c \
  28. fpathconf.c confstr.c pathconf.c swab.c usershell.c \
  29. getsubopt.c
  30. ifeq ($(strip $(UCLIBC_HAS_MMU)),y)
  31. CSRC+=daemon.c
  32. endif
  33. ifeq ($(strip $(UCLIBC_HAS_GNU_GETOPT)),y)
  34. CSRC += getopt.c
  35. else
  36. CSRC += getopt-susv3.c
  37. endif
  38. # TESTING -- comment this out if it breaks for you
  39. ifeq ($(TARGET_ARCH), $(HOST_ARCH))
  40. SYSCONF = sysconf_native
  41. else
  42. SYSCONF = sysconf_$(TARGET_ARCH).c
  43. endif
  44. COBJS=$(patsubst %.c,%.o, $(CSRC))
  45. OBJS=$(COBJS)
  46. all: $(SYSCONF) $(OBJS) $(LIBC)
  47. $(LIBC): ar-target subdirs
  48. ar-target: $(OBJS)
  49. $(AR) $(ARFLAGS) $(LIBC) $(OBJS)
  50. # We are cross-compiling so use the generic sysconf.c.
  51. sysconf_$(TARGET_ARCH).c: sysconf.c
  52. @echo warning: sysconf_$(HOST_ARCH).c is older then sysconf.c so using generic sysconf.c
  53. @echo To build sysconf_$(HOST_ARCH).c run gen_sysconf \> sysconf_$(HOST_ARCH).c on
  54. @echo your target platform, place in the unistd directory, and rebuild
  55. cp -f sysconf.c sysconf_$(TARGET_ARCH).c
  56. # We are compiling for the native platform, so build an optimized sysconf.c.
  57. getpagesize_tester.o:
  58. $(CC) $(CFLAGS) -D_UCLIBC_GENERATE_SYSCONF_ARCH \
  59. -c ../sysdeps/linux/common/getpagesize.c -o getpagesize_tester.o
  60. sysconf_tester.o: sysconf.c
  61. $(CC) $(CFLAGS) -D_UCLIBC_GENERATE_SYSCONF_ARCH -c sysconf.c \
  62. -o sysconf_tester.o
  63. gen_sysconf_tester.o: sysconf_tester.o getpagesize_tester.o
  64. @ld -r -o gen_sysconf_tester.o sysconf_tester.o getpagesize_tester.o
  65. @if nm -s gen_sysconf_tester.o | grep -v "U errno" | grep " U "; then \
  66. set -e -x; \
  67. echo warning: missing symbols in gen_sysconf_tester.o so using generic sysconf.c ;\
  68. cp -f sysconf.c sysconf_src.c ;\
  69. else \
  70. set -e -x; \
  71. if ../extra/gcc-uClibc/gcc-uClibc-$(HOST_ARCH) -static \
  72. -D_UCLIBC_GENERATE_SYSCONF_MAIN sysconf.c sysconf_tester.o \
  73. -o gen_sysconf && ./gen_sysconf > sysconf_$(HOST_ARCH).c ;\
  74. then \
  75. echo successfully built sysconf_$(HOST_ARCH).c ;\
  76. else \
  77. echo warning: build of gen_sysconf failed so using generic sysconf.c ;\
  78. cp -f sysconf.c sysconf_$(HOST_ARCH).c ;\
  79. fi ;\
  80. fi
  81. sysconf_native: gen_sysconf_tester.o
  82. sysconf_src.c: sysconf_$(TARGET_ARCH).c
  83. cp -f sysconf_$(TARGET_ARCH).c sysconf_src.c
  84. $(COBJS): %.o : %.c
  85. $(CC) $(CFLAGS) -c $< -o $@
  86. $(STRIPTOOL) -x -R .note -R .comment $*.o
  87. $(OBJ): Makefile
  88. subdirs: $(patsubst %, _dir_%, $(DIRS))
  89. subdirs_clean: $(patsubst %, _dirclean_%, $(DIRS))
  90. $(patsubst %, _dir_%, $(DIRS)) : dummy
  91. $(MAKE) -C $(patsubst _dir_%, %, $@)
  92. $(patsubst %, _dirclean_%, $(DIRS)) : dummy
  93. $(MAKE) -C $(patsubst _dirclean_%, %, $@) clean
  94. .PHONY: dummy sysconf_native
  95. dummy:
  96. clean:
  97. $(RM) *.[oa] *~ core gen_sysconf sysconf_*.c