OSDN Git Service

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