OSDN Git Service

Ok, this commit is _huge_ and its gonna change the world. I've
[uclinux-h8/uClibc.git] / libc / unistd / Makefile
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
24 TOPDIR=../../
25 include $(TOPDIR)Rules.mak
26 DIRS:=
27
28 CSRC=execl.c execlp.c execv.c execvep.c execvp.c execle.c \
29         sleep.c usleep.c getpass.c sysconf_src.c getlogin.c \
30         fpathconf.c confstr.c pathconf.c swab.c usershell.c \
31         getopt.c getsubopt.c
32 ifeq ($(strip $(UCLIBC_HAS_MMU)),y)
33     CSRC+=daemon.c
34 endif
35
36 # TESTING -- comment this out if it breaks for you
37 ifeq ($(TARGET_ARCH), $(NATIVE_ARCH))
38         SYSCONF = sysconf_native
39 else
40         SYSCONF = sysconf_$(TARGET_ARCH).c
41 endif
42
43 COBJS=$(patsubst %.c,%.o, $(CSRC))
44 OBJS=$(COBJS)
45
46 all: $(SYSCONF) $(OBJS) $(LIBC)
47
48 $(LIBC): ar-target subdirs
49
50 ar-target: $(OBJS)
51         $(AR) $(ARFLAGS) $(LIBC) $(OBJS)
52
53 # We are cross-compiling so use the generic sysconf.c.
54 sysconf_$(TARGET_ARCH).c: sysconf.c
55         @echo warning: sysconf_$(NATIVE_ARCH).c is older then sysconf.c so using generic sysconf.c
56         @echo To build sysconf_$(NATIVE_ARCH).c run gen_sysconf \> sysconf_$(NATIVE_ARCH).c on
57         @echo your target platform, place in the unistd directory, and rebuild
58         cp -f sysconf.c sysconf_$(TARGET_ARCH).c
59
60 # We are compiling for the native platform, so build an optimized sysconf.c.
61 getpagesize_tester.o:
62         $(CC) $(CFLAGS) -D_UCLIBC_GENERATE_SYSCONF_ARCH \
63             -c ../sysdeps/linux/common/getpagesize.c -o getpagesize_tester.o
64
65 sysconf_tester.o: sysconf.c
66         $(CC) $(CFLAGS) -D_UCLIBC_GENERATE_SYSCONF_ARCH -c sysconf.c \
67             -o sysconf_tester.o
68
69 gen_sysconf_tester.o: sysconf_tester.o getpagesize_tester.o
70         @ld -r -o gen_sysconf_tester.o sysconf_tester.o getpagesize_tester.o
71         @if nm -s gen_sysconf_tester.o | grep -v "U errno" | grep " U "; then \
72                 set -e -x; \
73                 echo warning: missing symbols in gen_sysconf_tester.o so using generic sysconf.c ;\
74                 cp -f sysconf.c sysconf_src.c ;\
75         else \
76                 set -e -x; \
77                 if ../extra/gcc-uClibc/gcc-uClibc-$(NATIVE_ARCH) -static \
78                         -D_UCLIBC_GENERATE_SYSCONF_MAIN sysconf.c sysconf_tester.o \
79                         -o gen_sysconf && ./gen_sysconf > sysconf_$(NATIVE_ARCH).c ;\
80                 then \
81                         echo successfully built sysconf_$(NATIVE_ARCH).c ;\
82                 else \
83                         echo warning: build of gen_sysconf failed so using generic sysconf.c ;\
84                         cp -f sysconf.c sysconf_$(NATIVE_ARCH).c ;\
85                 fi ;\
86         fi
87
88 sysconf_native: gen_sysconf_tester.o
89
90 sysconf_src.c: sysconf_$(TARGET_ARCH).c
91         cp -f sysconf_$(TARGET_ARCH).c sysconf_src.c
92
93
94 $(COBJS): %.o : %.c
95         $(CC) $(CFLAGS) -c $< -o $@
96         $(STRIPTOOL) -x -R .note -R .comment $*.o
97
98 $(OBJ): Makefile
99
100 subdirs: $(patsubst %, _dir_%, $(DIRS))
101 subdirs_clean: $(patsubst %, _dirclean_%, $(DIRS))
102
103 $(patsubst %, _dir_%, $(DIRS)) : dummy
104         $(MAKE) -C $(patsubst _dir_%, %, $@)
105
106 $(patsubst %, _dirclean_%, $(DIRS)) : dummy
107         $(MAKE) -C $(patsubst _dirclean_%, %, $@) clean
108
109 .PHONY: dummy sysconf_native
110 dummy:
111
112 clean:
113         rm -f *.[oa] *~ core gen_sysconf sysconf_*.c
114