| # |
| # Makefile |
| # |
| # Main makefile |
| # |
| |
| # Include configuration rules |
| include MCONFIG |
| |
| INCLUDE += -I./zlib |
| |
| TESTS = $(patsubst %.c,%,$(wildcard tests/*.c)) \ |
| $(patsubst %.c,%.shared,$(wildcard tests/*.c)) |
| LIBOBJS = vsnprintf.o snprintf.o vsprintf.o sprintf.o \ |
| asprintf.o vasprintf.o \ |
| vsscanf.o sscanf.o ctypes.o \ |
| strntoumax.o strntoimax.o \ |
| atoi.o atol.o atoll.o \ |
| strtol.o strtoll.o strtoul.o strtoull.o \ |
| strtoimax.o strtoumax.o \ |
| globals.o exitc.o atexit.o onexit.o \ |
| execl.o execle.o execv.o execvpe.o execvp.o execlp.o execlpe.o \ |
| fork.o wait.o wait3.o waitpid.o system.o setpgrp.o getpgrp.o \ |
| daemon.o \ |
| printf.o vprintf.o fprintf.o vfprintf.o perror.o \ |
| statfs.o fstatfs.o umount.o \ |
| open.o fopen.o fread.o fread2.o fgetc.o fgets.o \ |
| fwrite.o fwrite2.o fputc.o fputs.o puts.o putchar.o \ |
| sleep.o usleep.o strtotimespec.o strtotimeval.o \ |
| raise.o abort.o assert.o alarm.o pause.o \ |
| __signal.o sysv_signal.o bsd_signal.o siglist.o siglongjmp.o \ |
| sigaction.o sigpending.o sigprocmask.o sigsuspend.o \ |
| brk.o sbrk.o malloc.o realloc.o calloc.o mmap.o \ |
| memcpy.o memcmp.o memset.o memccpy.o memmem.o memswap.o \ |
| memmove.o memchr.o memrchr.o \ |
| strcasecmp.o strncasecmp.o strndup.o strerror.o \ |
| strcat.o strchr.o strcmp.o strcpy.o strdup.o strlen.o strnlen.o \ |
| strncat.o strlcpy.o strlcat.o \ |
| strstr.o strncmp.o strncpy.o strrchr.o \ |
| strxspn.o strspn.o strcspn.o strpbrk.o strsep.o strtok.o \ |
| gethostname.o getdomainname.o getcwd.o \ |
| seteuid.o setegid.o \ |
| getenv.o setenv.o putenv.o __put_env.o unsetenv.o \ |
| getopt.o readdir.o \ |
| syslog.o closelog.o pty.o getpt.o isatty.o reboot.o \ |
| time.o utime.o llseek.o nice.o getpriority.o \ |
| qsort.o \ |
| lrand48.o jrand48.o mrand48.o nrand48.o srand48.o seed48.o \ |
| inet/inet_ntoa.o inet/inet_aton.o inet/inet_addr.o \ |
| inet/inet_ntop.o inet/inet_pton.o inet/bindresvport.o \ |
| send.o recv.o |
| |
| ifeq ($(ERRLIST),1) |
| LIBOBJS += errlist.o |
| endif |
| |
| ifeq ($(ZLIB),1) |
| LIBOBJS += zlib/adler32.o zlib/compress.o zlib/crc32.o zlib/gzio.o \ |
| zlib/uncompr.o zlib/deflate.o zlib/trees.o zlib/zutil.o \ |
| zlib/inflate.o zlib/infback.o zlib/inftrees.o zlib/inffast.o |
| endif |
| |
| SOLIB = libc.so |
| SOHASH = klibc.so |
| |
| CRT0 = crt0.o |
| LIB = libc.a |
| |
| INTERP_O = interp.o |
| |
| all: tests $(CRT0) $(LIB) $(SOLIB) $(SOHASH) $(INTERP_O) |
| |
| # Add any architecture-specific rules |
| include arch/$(ARCH)/Makefile.inc |
| EMAIN ?= -e main |
| |
| tests: $(TESTS) |
| |
| tests/%.o : tests/%.c |
| $(CC) $(CFLAGS) -c -o $@ $< |
| |
| # This particular file uses a bunch of formats gcc don't know of, in order |
| # to test the full range of our vsnprintf() function. This outputs a bunch |
| # of useless warnings unless we tell it not to. |
| tests/testvsnp.o : tests/testvsnp.c |
| $(CC) $(CFLAGS) -Wno-format -c -o $@ $< |
| |
| tests/% : tests/%.o $(LIB) $(CRT0) |
| $(LD) $(LDFLAGS) -o $@ $(CRT0) $< $(LIB) $(LIBGCC) |
| cp $@ $@.stripped |
| $(STRIPCMD) $@.stripped |
| |
| tests/%.shared : tests/%.o interp.o $(SOLIB) |
| $(LD) $(LDFLAGS) -o $@ $(EMAIN) interp.o tests/$*.o -R $(SOLIB) $(LIBGCC) |
| cp $@ $@.stripped |
| $(STRIPCMD) $@.stripped |
| |
| $(LIB): __static_init.o $(LIBOBJS) $(ARCHOBJS) syscalls/static.obj socketcalls/static.obj |
| rm -f $(LIB) |
| $(AR) cq $(LIB) __static_init.o $(LIBOBJS) $(ARCHOBJS) \ |
| $(wildcard syscalls/*.o) $(wildcard socketcalls/*.o) |
| $(RANLIB) $(LIB) |
| |
| $(SOLIB): $(CRT0) __shared_init.o $(LIBOBJS) $(ARCHOBJS) syscalls/static.obj socketcalls/static.obj |
| $(LD) $(LDFLAGS) $(SHAREDFLAGS) -o $@ \ |
| $(CRT0) __shared_init.o $(LIBOBJS) $(ARCHOBJS) \ |
| $(wildcard syscalls/*.o) $(wildcard socketcalls/*.o) \ |
| $(LIBGCC) |
| |
| sha1hash: sha1hash.c |
| $(HOST_CC) $(HOST_CFLAGS) $(HOST_LDFLAGS) -o $@ $< |
| |
| $(SOLIB).hash: $(SOLIB) sha1hash |
| $(NM) $(SOLIB) | \ |
| egrep '^[0-9a-fA-F]+ [ADRTW] ' | sort | ./sha1hash > $@ |
| |
| $(SOHASH): $(SOLIB) $(SOLIB).hash |
| cp -f $(SOLIB) $@ |
| $(STRIPCMD) $@ |
| rm -f klibc-??????????????????????.so |
| ln -f $@ klibc-`cat $(SOLIB).hash`.so |
| |
| $(INTERP_O): interp.S $(SOLIB).hash |
| $(CC) $(CFLAGS) -D__ASSEMBLY__ -DLIBDIR=\"$(SHLIBDIR)\" \ |
| -DSOHASH=\"`cat $(SOLIB).hash`\" \ |
| -c -o $@ $< |
| |
| crt0.o: arch/$(ARCH)/crt0.o |
| cp arch/$(ARCH)/crt0.o . |
| |
| errlist.c: |
| $(PERL) makeerrlist.pl -q $(INCLUDE) -errlist > $@ || rm -f $@ |
| |
| # We pass -ansi to keep cpp from define e.g. "i386" as well as "__i386__" |
| SYSCALLS.i: SYSCALLS.def |
| $(CC) $(CFLAGS) -D__ASSEMBLY__ -ansi -x assembler-with-cpp -E -o $@ $< |
| |
| syscalls.nrs: ../include/sys/syscall.h |
| $(CC) $(CFLAGS) -Wp,-dM -x c -E -o $@ $< |
| |
| syscalls.dir: SYSCALLS.i syscalls.pl arch/$(ARCH)/sysstub.ph syscommon.h syscalls.nrs |
| rm -rf syscalls |
| mkdir syscalls |
| $(PERL) syscalls.pl SYSCALLS.i $(ARCH) $(BITSIZE) syscalls.nrs ../include/klibc/havesyscall.h |
| touch $@ |
| |
| ../include/klibc/havesyscall.h: syscalls.dir |
| : Generated by side effect |
| |
| socketcalls.dir: SOCKETCALLS.def socketcalls.pl socketcommon.h |
| rm -rf socketcalls |
| mkdir socketcalls |
| $(PERL) socketcalls.pl SOCKETCALLS.def $(ARCH) |
| touch $@ |
| |
| %/static.obj: %.dir |
| $(MAKE) objects-$(basename $(notdir $@)) DIR=$*/ |
| |
| STATIC = $(addsuffix .o,$(basename $(wildcard $(DIR)*.[cS]))) |
| |
| objects-static: $(STATIC) |
| touch $(DIR)static.obj |
| |
| clean: archclean |
| find . -type f -a \( -name \*.[isoa] -o -name \*.l[iso] \) -print0 | xargs -0rt rm -f |
| rm -f *.a *.so *.hash *.syms *.stripped |
| rm -f $(TESTS) tests/*.stripped |
| rm -rf syscalls syscalls.dir |
| rm -rf socketcalls socketcalls.dir |
| rm -f sha1hash errlist.c |
| |
| spotless: clean |
| rm -f ../include/klibc/havesyscall.h syscalls.nrs |
| find . \( -name \*~ -o -name '.*.d' \) -not -type d -print0 | \ |
| xargs -0rt rm -f |
| |
| bitsize: |
| @echo $(BITSIZE) |
| |
| install: all |
| $(INSTALL_DATA) $(LIB) $(SOLIB) $(CRT0) $(INTERP_O) \ |
| $(INSTALLROOT)$(INSTALLDIR)/$(CROSS)lib |
| $(INSTALL_EXEC) klibc-`cat $(SOLIB).hash`.so \ |
| $(INSTALLROOT)$(INSTALLDIR)/$(CROSS)lib |
| $(INSTALL_EXEC) klibc-`cat $(SOLIB).hash`.so \ |
| $(INSTALLROOT)/$(SHLIBDIR) |
| |
| ifneq ($(wildcard $(DIR).*.d),) |
| include $(wildcard $(DIR).*.d) |
| endif |