diff options
author | H. Peter Anvin <hpa@zytor.com> | 2004-02-21 08:44:07 +0000 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2004-02-21 08:44:07 +0000 |
commit | 3f2eeb9d2bb1dccc272a3edc7808cf53ac1a72e4 (patch) | |
tree | 58956c66a704b1e86d511d8e61190ad4cc814ae0 | |
parent | 400b285b76c2752ded710861268620058084d7ee (diff) | |
download | klibc-3f2eeb9d2bb1dccc272a3edc7808cf53ac1a72e4.tar.gz |
Add sleep utility (from Olaf); build both shared and static versionsklibc-0.112
of the utilities.
-rw-r--r-- | MCONFIG | 11 | ||||
-rw-r--r-- | MRULES | 4 | ||||
-rw-r--r-- | ash/Makefile | 4 | ||||
-rw-r--r-- | klibc/__static_init.c | 2 | ||||
-rw-r--r-- | klibc/arch/i386/MCONFIG | 9 | ||||
-rw-r--r-- | utils/Makefile | 69 | ||||
-rw-r--r-- | utils/mount_main.c (renamed from utils/mount.c) | 0 | ||||
-rw-r--r-- | utils/sleep.c | 23 |
8 files changed, 73 insertions, 49 deletions
@@ -25,9 +25,14 @@ HOST_CFLAGS = -g -O HOST_LDFLAGS = HOST_LIBS = -CRT0 = $(KLIBSRC)/crt0.o -KLIBC = $(KLIBSRC)/libc.a -LIBGCC = $(shell $(CC) --print-libgcc) +# Static library paths +CRT0 = $(KLIBSRC)/crt0.o +KLIBC = $(KLIBSRC)/libc.a +LIBGCC = $(shell $(CC) --print-libgcc) + +# Shared library paths +CRTSHARED = $(KLIBSRC)/interp.o +LIBSHARED = $(KLIBSRC)/libc.so # # This indicates the location of the final version of the shared library. @@ -5,6 +5,10 @@ .SUFFIXES: .c .o .a .so .lo .i .S .s .ls .ss .lss +% : %.c # Cancel default rule + +% : %.S + .c.o: $(CC) $(CFLAGS) -c -o $@ $< diff --git a/ash/Makefile b/ash/Makefile index 4f25b000151cc..9c477383994fb 100644 --- a/ash/Makefile +++ b/ash/Makefile @@ -37,8 +37,8 @@ $(PROG): $(OBJS) $(LIBS) $(CRT0) $(LD) $(LDFLAGS) -o $(PROG) $(CRT0) $(OBJS) $(LIBS) $(STRIP) $(PROG) -$(PROG).shared: $(OBJS) $(LIBS) $(KLIBSRC)/interp.o $(KLIBSRC)/libc.so - $(LD) $(LDFLAGS) -o $(PROG).shared -e main $(KLIBSRC)/interp.o $(OBJS) -R $(KLIBSRC)/libc.so $(LIBGCC) +$(PROG).shared: $(OBJS) $(CRTSHARED) $(LIBSHARED) $(LIBGCC) + $(LD) $(LDFLAGS) -o $(PROG).shared -e main $(CRTSHARED) $(OBJS) -R $(LIBSHARED) $(LIBGCC) $(STRIP) $(PROG).shared $(CRT0) $(LIBS): diff --git a/klibc/__static_init.c b/klibc/__static_init.c index dcb8d01856418..5a90b5cd88a95 100644 --- a/klibc/__static_init.c +++ b/klibc/__static_init.c @@ -36,5 +36,3 @@ __noreturn __libc_init(uintptr_t *elfdata, void (*onexit)(void)) environ = envp; exit(main(argc, argv, envp)); } - - diff --git a/klibc/arch/i386/MCONFIG b/klibc/arch/i386/MCONFIG index 367ee8977313f..516b1b6738148 100644 --- a/klibc/arch/i386/MCONFIG +++ b/klibc/arch/i386/MCONFIG @@ -7,17 +7,16 @@ # accordingly. # -# Comment this out to compile with register parameter passing -# This doesn't work right now because gcc 3.2 (at least) calls -# libgcc with the default calling convention instead of forcing -# them to be cdecl -# REGPARM = -mregparm=3 -DREGPARM +# Enable this to compile with register parameters; only safe for +# gcc > 3 +REGPARM_OPT := -mregparm=3 -DREGPARM gcc_major := $(shell $(CC) -v 2>&1 | awk '/gcc version/{print int($$3)}') OPTFLAGS = $(REGPARM) -march=i386 -Os ifeq ($(gcc_major),3) +REGPARM := $(REGPARM_OPT) OPTFLAGS += -falign-functions=0 -falign-jumps=0 -falign-loops=0 else OPTFLAGS += -malign-functions=0 -malign-jumps=0 -malign-loops=0 diff --git a/utils/Makefile b/utils/Makefile index c92e766dd3e3d..ea49ad28a1f10 100644 --- a/utils/Makefile +++ b/utils/Makefile @@ -2,48 +2,43 @@ SRCROOT = .. include ../MCONFIG include ../MRULES -MAKEDEPS = -Wp,-MD,.$(subst /,-,$*).d -CFLAGS = $(MAKEDEPS) $(OPTFLAGS) $(REQFLAGS) -W -Wall -LIBS = $(KLIBC) $(LIBGCC) -PROGS = chroot dd fstype mkdir mkfifo mount pivot_root umount true false - -all: $(PROGS) - -chroot: chroot.o $(CRT0) $(LIBS) - $(LD) $(LDFLAGS) -o $@ $(CRT0) chroot.o $(LIBS) - -dd: dd.o $(CRT0) $(LIBS) - $(LD) $(LDFLAGS) -o $@ $(CRT0) dd.o $(LIBS) - -fstype: fstype.o $(CRT0) $(LIBS) - $(LD) $(LDFLAGS) -o $@ $(CRT0) fstype.o $(LIBS) - -mkdir: mkdir.o file_mode.o $(CRT0) $(LIBS) - $(LD) $(LDFLAGS) -o $@ $(CRT0) mkdir.o file_mode.o $(LIBS) - -mkfifo: mkfifo.o file_mode.o $(CRT0) $(LIBS) - $(LD) $(LDFLAGS) -o $@ $(CRT0) mkfifo.o file_mode.o $(LIBS) - -mount: mount.o mount_opts.o $(CRT0) $(LIBS) - $(LD) $(LDFLAGS) -o $@ $(CRT0) mount.o mount_opts.o $(LIBS) - -pivot_root: pivot_root.o $(CRT0) $(LIBS) - $(LD) $(LDFLAGS) -o $@ $(CRT0) pivot_root.o $(LIBS) - -umount: umount.o $(CRT0) $(LIBS) - $(LD) $(LDFLAGS) -o $@ $(CRT0) umount.o $(LIBS) - -true: true.o $(CRT0) $(LIBS) - $(LD) $(LDFLAGS) -o $@ $(CRT0) true.o $(LIBS) - -false: false.o $(CRT0) $(LIBS) - $(LD) $(LDFLAGS) -o $@ $(CRT0) false.o $(LIBS) +MAKEDEPS = -Wp,-MD,.$(subst /,-,$*).d +CFLAGS = $(MAKEDEPS) $(OPTFLAGS) $(REQFLAGS) -W -Wall +LIBS = $(KLIBC) $(LIBGCC) +PROGS := chroot dd fstype mkdir mkfifo mount pivot_root umount \ + true false sleep +STATICPROGS := $(patsubst %,static/%,$(PROGS)) +SHAREDPROGS := $(patsubst %,shared/%,$(PROGS)) +LIBOBJS = file_mode.o +LIBUTILS = libutils.a + +all: $(STATICPROGS) $(SHAREDPROGS) + +static/%: %.o $(CRT0) $(LIBS) $(LIBUTILS) + mkdir -p static + $(LD) $(LDFLAGS) -o $@ $(CRT0) $< $(LIBUTILS) $(LIBS) + $(STRIP) $@ + +shared/%: %.o $(CRTSHARED) $(LIBSHARED) $(LIBUTILS) + mkdir -p shared + $(LD) $(LDFLAGS) -o $@ -e main $(CRTSHARED) $< $(LIBUTILS) \ + -R $(LIBSHARED) $(LIBGCC) + $(STRIP) $@ + +# Programs that consist of more than one file +mount.o: mount_main.o mount_opts.o + $(LD) -r -o $@ $^ + +$(LIBUTILS): $(LIBOBJS) + -rm -f $@ + $(AR) cq $@ $^ + $(RANLIB) $@ $(CRT0) $(LIBS): @echo '*** error: $@ not up to date' || exit 1 clean: - $(RM) *.o $(PROGS) core .*.d + $(RM) *.o core $(PROGS) .*.d shared/* static/* spotless: clean $(RM) *~ diff --git a/utils/mount.c b/utils/mount_main.c index b6a6bb0a4525e..b6a6bb0a4525e 100644 --- a/utils/mount.c +++ b/utils/mount_main.c diff --git a/utils/sleep.c b/utils/sleep.c new file mode 100644 index 0000000000000..769b456e652ac --- /dev/null +++ b/utils/sleep.c @@ -0,0 +1,23 @@ +#include <stdio.h> +#include <stdlib.h> + +int main(int argc, char *argv[]) +{ + unsigned long s; + char *p; + + if (argc != 2) + goto err; + + s = strtoul(argv[1], &p, 10); + if ( *p ) + goto err; + + sleep(s); + + return 0; + +err: + fprintf(stderr, "Usage: %s seconds\n", argv[0]); + return 1; +} |