7 # Include configuration rules
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 asprintf.o vasprintf.o \
14 vsscanf.o sscanf.o ctypes.o \
15 strntoumax.o strntoimax.o \
16 atoi.o atol.o atoll.o \
17 strtol.o strtoll.o strtoul.o strtoull.o \
18 strtoimax.o strtoumax.o \
19 globals.o exitc.o atexit.o onexit.o \
20 execl.o execle.o execv.o execvpe.o execvp.o execlp.o execlpe.o \
21 fork.o wait.o wait3.o waitpid.o system.o setpgrp.o getpgrp.o \
23 printf.o vprintf.o fprintf.o vfprintf.o perror.o \
24 statfs.o fstatfs.o umount.o \
25 open.o fopen.o fread.o fread2.o fgetc.o fgets.o \
26 fwrite.o fwrite2.o fputc.o fputs.o puts.o putchar.o \
27 sleep.o usleep.o strtotimespec.o strtotimeval.o \
28 raise.o abort.o assert.o alarm.o pause.o \
29 __signal.o sysv_signal.o bsd_signal.o siglist.o siglongjmp.o \
30 sigaction.o sigpending.o sigprocmask.o sigsuspend.o \
31 brk.o sbrk.o malloc.o realloc.o calloc.o mmap.o \
32 memcpy.o memcmp.o memset.o memccpy.o memmem.o memswap.o \
33 memmove.o memchr.o memrchr.o \
34 strcasecmp.o strncasecmp.o strndup.o strerror.o \
35 strcat.o strchr.o strcmp.o strcpy.o strdup.o strlen.o strnlen.o \
36 strncat.o strlcpy.o strlcat.o \
37 strstr.o strncmp.o strncpy.o strrchr.o \
38 strxspn.o strspn.o strcspn.o strpbrk.o strsep.o strtok.o \
39 gethostname.o getdomainname.o getcwd.o \
41 getenv.o setenv.o putenv.o __put_env.o unsetenv.o \
43 syslog.o closelog.o pty.o getpt.o isatty.o reboot.o \
44 time.o utime.o llseek.o nice.o getpriority.o \
46 lrand48.o jrand48.o mrand48.o nrand48.o srand48.o seed48.o \
47 inet/inet_ntoa.o inet/inet_aton.o inet/inet_addr.o \
48 inet/inet_ntop.o inet/inet_pton.o inet/bindresvport.o \
62 all: tests $(CRT0) $(LIB) $(SOLIB) $(SOHASH) $(INTERP_O)
64 # Add any architecture-specific rules
65 include arch/$(ARCH)/Makefile.inc
71 $(CC) $(CFLAGS) -c -o $@ $<
73 # This particular file uses a bunch of formats gcc don't know of, in order
74 # to test the full range of our vsnprintf() function. This outputs a bunch
75 # of useless warnings unless we tell it not to.
76 tests/testvsnp.o : tests/testvsnp.c
77 $(CC) $(CFLAGS) -Wno-format -c -o $@ $<
79 tests/% : tests/%.o $(LIB) $(CRT0)
80 $(LD) $(LDFLAGS) -o $@ $(CRT0) $< $(LIB) $(LIBGCC)
84 tests/%.shared : tests/%.o interp.o $(SOLIB)
85 $(LD) $(LDFLAGS) -o $@ $(EMAIN) interp.o tests/$*.o -R $(SOLIB) $(LIBGCC)
89 $(LIB): __static_init.o $(LIBOBJS) $(ARCHOBJS) syscalls/static.obj socketcalls/static.obj
91 $(AR) cq $(LIB) __static_init.o $(LIBOBJS) $(ARCHOBJS) \
92 $(wildcard syscalls/*.o) $(wildcard socketcalls/*.o)
95 $(SOLIB): $(CRT0) __shared_init.o $(LIBOBJS) $(ARCHOBJS) syscalls/static.obj socketcalls/static.obj
96 $(LD) $(LDFLAGS) $(SHAREDFLAGS) -o $@ \
97 $(CRT0) __shared_init.o $(LIBOBJS) $(ARCHOBJS) \
98 $(wildcard syscalls/*.o) $(wildcard socketcalls/*.o) \
102 $(HOST_CC) $(HOST_CFLAGS) $(HOST_LDFLAGS) -o $@ $<
104 $(SOLIB).hash: $(SOLIB) sha1hash
106 egrep '^[0-9a-fA-F]+ [ADRTW] ' | sort | ./sha1hash > $@
108 $(SOHASH): $(SOLIB) $(SOLIB).hash
111 rm -f klibc-??????????????????????.so
112 ln -f $@ klibc-`cat $(SOLIB).hash`.so
114 $(INTERP_O): interp.S $(SOLIB).hash
115 $(CC) $(CFLAGS) -D__ASSEMBLY__ -DLIBDIR=\"$(SHLIBDIR)\" \
116 -DSOHASH=\"`cat $(SOLIB).hash`\" \
119 crt0.o: arch/$(ARCH)/crt0.o
120 cp arch/$(ARCH)/crt0.o .
123 $(PERL) makeerrlist.pl -q $(INCLUDE) -errlist > $@ || rm -f $@
125 # We pass -ansi to keep cpp from define e.g. "i386" as well as "__i386__"
126 SYSCALLS.i: SYSCALLS.def
127 $(CC) $(CFLAGS) -D__ASSEMBLY__ -ansi -x assembler-with-cpp -E -o $@ $<
129 syscalls.nrs: ../include/sys/syscall.h
130 $(CC) $(CFLAGS) -Wp,-dM -x c -E -o $@ $<
132 syscalls.dir: SYSCALLS.i syscalls.pl arch/$(ARCH)/sysstub.ph syscommon.h syscalls.nrs
135 $(PERL) syscalls.pl SYSCALLS.i $(ARCH) $(BITSIZE) syscalls.nrs ../include/klibc/havesyscall.h
138 ../include/klibc/havesyscall.h: syscalls.dir
139 : Generated by side effect
141 socketcalls.dir: SOCKETCALLS.def socketcalls.pl socketcommon.h
144 $(PERL) socketcalls.pl SOCKETCALLS.def $(ARCH)
148 $(MAKE) objects-$(basename $(notdir $@)) DIR=$*/
150 STATIC = $(addsuffix .o,$(basename $(wildcard $(DIR)*.[cS])))
152 objects-static: $(STATIC)
153 touch $(DIR)static.obj
156 find . -type f -a \( -name \*.[isoa] -o -name \*.l[iso] \) -print0 | xargs -0rt rm -f
157 rm -f *.a *.so *.hash *.syms *.stripped
158 rm -f $(TESTS) tests/*.stripped
159 rm -rf syscalls syscalls.dir
160 rm -rf socketcalls socketcalls.dir
161 rm -f sha1hash errlist.c
164 rm -f ../include/klibc/havesyscall.h syscalls.nrs
165 find . \( -name \*~ -o -name '.*.d' \) -not -type d -print0 | \
171 ifneq ($(wildcard $(DIR).*.d),)
172 include $(wildcard $(DIR).*.d)