chiark / gitweb /
[PATCH] added klibc version 0.82 (cvs tree) to the udev tree.
[elogind.git] / klibc / klibc / Makefile
1 #
2 # Makefile
3 #
4 # Main makefile
5 #
6
7 # Include configuration rules
8 include MCONFIG
9
10 TESTS   = $(patsubst %.c,%,$(wildcard tests/*.c)) \
11           $(patsubst %.c,%.shared,$(wildcard tests/*.c))
12 LIBOBJS = vsnprintf.o snprintf.o vsprintf.o sprintf.o \
13           vsscanf.o sscanf.o ctypes.o \
14           strntoumax.o strntoimax.o \
15           atoi.o atol.o atoll.o \
16           strtol.o strtoll.o strtoul.o strtoull.o \
17           strtoimax.o strtoumax.o \
18           globals.o exitc.o atexit.o onexit.o \
19           execl.o execle.o execv.o execvpe.o execvp.o execlp.o execlpe.o \
20           fork.o wait.o wait3.o waitpid.o system.o setpgrp.o \
21           printf.o vprintf.o fprintf.o vfprintf.o perror.o \
22           fopen.o fread.o fread2.o fgetc.o fgets.o \
23           fwrite.o fwrite2.o fputc.o fputs.o puts.o \
24           sleep.o usleep.o raise.o abort.o assert.o alarm.o pause.o \
25           __signal.o signal.o bsd_signal.o siglist.o siglongjmp.o \
26           sigaction.o sigpending.o sigprocmask.o sigsuspend.o \
27           brk.o sbrk.o malloc.o realloc.o calloc.o mmap.o \
28           memcpy.o memcmp.o memset.o memccpy.o memmem.o memswap.o \
29           memmove.o \
30           strcat.o strchr.o strcmp.o strcpy.o strdup.o strlen.o \
31           strncat.o strstr.o strncmp.o strncpy.o strrchr.o strspn.o \
32           strsep.o strtok.o \
33           gethostname.o getdomainname.o getcwd.o \
34           seteuid.o setegid.o setresuid.o setresgid.o \
35           getenv.o setenv.o unsetenv.o getopt.o readdir.o \
36           syslog.o closelog.o pty.o isatty.o reboot.o \
37           time.o utime.o fdatasync.o llseek.o select.o nice.o getpriority.o \
38           qsort.o lrand48.o srand48.o seed48.o \
39           inet/inet_ntoa.o inet/inet_aton.o inet/inet_addr.o \
40           inet/inet_ntop.o inet/inet_pton.o inet/bindresvport.o \
41           send.o recv.o
42 SOLIB   = libc.so
43 SOHASH  = klibc.so
44
45 CRT0    = crt0.o
46 LIB     = libc.a
47
48 #all: tests $(CRT0) $(LIB) $(SOLIB) klibc.so
49 all:  $(CRT0) $(LIB) $(SOLIB) klibc.so
50
51 # Add any architecture-specific rules
52 include arch/$(ARCH)/Makefile.inc
53
54 tests: $(TESTS)
55
56 tests/%.o : tests/%.c
57         $(CC) $(CFLAGS) -c -o $@ $<
58
59 tests/% : tests/%.o $(LIB) $(CRT0)
60         $(LD) $(LDFLAGS) -o $@ $(CRT0) $< $(LIB) $(LIBGCC)
61         cp $@ $@.stripped
62         $(STRIP) $@.stripped
63
64 tests/%.shared : tests/%.o interp.o $(SOLIB)
65         $(LD) $(LDFLAGS) -o $@ -e main interp.o tests/$*.o -R $(SOLIB) $(LIBGCC)
66         cp $@ $@.stripped
67         $(STRIP) $@.stripped
68
69 $(LIB): __static_init.o $(LIBOBJS) $(ARCHOBJS) syscalls/static.obj socketcalls/static.obj
70         rm -f $(LIB)
71         $(AR) cq $(LIB) __static_init.o $(LIBOBJS) $(ARCHOBJS) syscalls/*.o socketcalls/*.o
72         $(RANLIB) $(LIB)
73
74 $(SOLIB): $(CRT0) __shared_init.o $(LIBOBJS) $(ARCHOBJS) syscalls/static.obj socketcalls/static.obj
75         $(LD) $(LDFLAGS) $(SHAREDFLAGS) -o $@ \
76                 $(CRT0) __shared_init.o $(LIBOBJS) $(ARCHOBJS) \
77                 syscalls/*.o socketcalls/*.o \
78                 $(LIBGCC)
79
80 sha1hash: sha1hash.c
81         $(HOST_CC) $(HOST_CFLAGS) $(HOST_LDFLAGS) -o $@ $<
82
83 $(SOLIB).hash: $(SOLIB) sha1hash
84         $(NM) $(SOLIB) | \
85                 egrep '^[0-9a-fA-F]+ [ADRTW] ' | sort | ./sha1hash > $@
86
87 $(SOHASH): $(SOLIB) $(SOLIB).hash
88         cp -f $(SOLIB) $@
89         $(STRIP) $@
90         rm -f klibc-??????????????????????.so
91         ln -f $@ klibc-`cat $(SOLIB).hash`.so
92
93 interp.o: interp.S $(SOLIB).hash
94         $(CC) $(CFLAGS) -D__ASSEMBLY__ -DLIBDIR=\"$(SHLIBDIR)\" \
95                 -DSOHASH=\"`cat $(SOLIB).hash`\" \
96                 -c -o $@ $<
97
98 crt0.o: arch/$(ARCH)/crt0.o
99         cp arch/$(ARCH)/crt0.o .
100
101 syscalls.dir: SYSCALLS syscalls.pl syscommon.h
102         rm -rf syscalls
103         mkdir syscalls
104         $(PERL) syscalls.pl $(ARCH) SYSCALLS
105         touch $@
106
107 socketcalls.dir: SOCKETCALLS socketcalls.pl socketcommon.h
108         rm -rf socketcalls
109         mkdir socketcalls
110         $(PERL) socketcalls.pl $(ARCH) SOCKETCALLS
111         touch $@
112
113 %/static.obj: %.dir
114         $(MAKE) objects-$(basename $(notdir $@)) DIR=$*
115
116 STATIC = $(addsuffix .o,$(basename $(wildcard $(DIR)/*.[cS])))
117
118 objects-static: $(STATIC)
119         touch $(DIR)/static.obj
120
121 clean: archclean
122         find . -type f -a \( -name \*.[isoa] -o -name \*.l[iso] \) -print0 | xargs -0rt rm -f
123         rm -f *.a *.so *.hash *.syms *.stripped
124         rm -f $(TESTS) tests/*.stripped
125         rm -rf syscalls syscalls.dir
126         rm -rf socketcalls socketcalls.dir
127         rm -f sha1hash
128
129 spotless: clean
130         find . \( -name \*~ -o -name '.*.d' \) -not -type d -print0 | \
131                 xargs -0rt rm -f
132
133 ifneq ($(wildcard $(DIR)/.*.d),)
134 include $(wildcard $(DIR)/.*.d)
135 endif