diff options
| author | manuel <manuel@mausz.at> | 2012-03-27 11:51:08 +0200 |
|---|---|---|
| committer | manuel <manuel@mausz.at> | 2012-03-27 11:51:08 +0200 |
| commit | 4f670845ff9ab6c48bcb5f7bf4d4ef6dc3c3064b (patch) | |
| tree | 868c52e06f207b5ec8a3cc141f4b8b2bdfcc165c /Makefile.userprog | |
| parent | eae0bd57f0a26314a94785061888d193d186944a (diff) | |
| download | progos-4f670845ff9ab6c48bcb5f7bf4d4ef6dc3c3064b.tar.gz progos-4f670845ff9ab6c48bcb5f7bf4d4ef6dc3c3064b.tar.bz2 progos-4f670845ff9ab6c48bcb5f7bf4d4ef6dc3c3064b.zip | |
reorganize file structure to match the upstream requirements
Diffstat (limited to 'Makefile.userprog')
| -rw-r--r-- | Makefile.userprog | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/Makefile.userprog b/Makefile.userprog new file mode 100644 index 0000000..0df391a --- /dev/null +++ b/Makefile.userprog | |||
| @@ -0,0 +1,52 @@ | |||
| 1 | # -*- makefile -*- | ||
| 2 | |||
| 3 | $(PROGS): CPPFLAGS += -I$(SRCDIR)/lib/user -I. | ||
| 4 | |||
| 5 | # Linker flags. | ||
| 6 | $(PROGS): LDFLAGS += -nostdlib -static -Wl,-T,$(LDSCRIPT) | ||
| 7 | $(PROGS): LDSCRIPT = $(SRCDIR)/lib/user/user.lds | ||
| 8 | |||
| 9 | # Library code shared between kernel and user programs. | ||
| 10 | lib_SRC = lib/debug.c # Debug code. | ||
| 11 | lib_SRC += lib/random.c # Pseudo-random numbers. | ||
| 12 | lib_SRC += lib/stdio.c # I/O library. | ||
| 13 | lib_SRC += lib/stdlib.c # Utility functions. | ||
| 14 | lib_SRC += lib/string.c # String functions. | ||
| 15 | lib_SRC += lib/arithmetic.c # 64-bit arithmetic for GCC. | ||
| 16 | lib_SRC += lib/ustar.c # Unix standard tar format utilities. | ||
| 17 | |||
| 18 | # User level only library code. | ||
| 19 | lib/user_SRC = lib/user/debug.c # Debug helpers. | ||
| 20 | lib/user_SRC += lib/user/syscall.c # System calls. | ||
| 21 | lib/user_SRC += lib/user/console.c # Console code. | ||
| 22 | |||
| 23 | LIB_OBJ = $(patsubst %.c,%.o,$(patsubst %.S,%.o,$(lib_SRC) $(lib/user_SRC))) | ||
| 24 | LIB_DEP = $(patsubst %.o,%.d,$(LIB_OBJ)) | ||
| 25 | LIB = lib/user/entry.o libc.a | ||
| 26 | |||
| 27 | PROGS_SRC = $(foreach prog,$(PROGS),$($(prog)_SRC)) | ||
| 28 | PROGS_OBJ = $(patsubst %.c,%.o,$(patsubst %.S,%.o,$(PROGS_SRC))) | ||
| 29 | PROGS_DEP = $(patsubst %.o,%.d,$(PROGS_OBJ)) | ||
| 30 | |||
| 31 | all: $(PROGS) | ||
| 32 | |||
| 33 | define TEMPLATE | ||
| 34 | $(1)_OBJ = $(patsubst %.c,%.o,$(patsubst %.S,%.o,$($(1)_SRC))) | ||
| 35 | $(1): $$($(1)_OBJ) $$(LIB) $$(LDSCRIPT) | ||
| 36 | $$(CC) $$(LDFLAGS) $$($(1)_OBJ) $$(LIB) -o $$@ | ||
| 37 | endef | ||
| 38 | |||
| 39 | $(foreach prog,$(PROGS),$(eval $(call TEMPLATE,$(prog)))) | ||
| 40 | |||
| 41 | libc.a: $(LIB_OBJ) | ||
| 42 | rm -f $@ | ||
| 43 | ar r $@ $^ | ||
| 44 | ranlib $@ | ||
| 45 | |||
| 46 | clean:: | ||
| 47 | rm -f $(PROGS) $(PROGS_OBJ) $(PROGS_DEP) | ||
| 48 | rm -f $(LIB_DEP) $(LIB_OBJ) lib/user/entry.[do] libc.a | ||
| 49 | |||
| 50 | .PHONY: all clean | ||
| 51 | |||
| 52 | -include $(LIB_DEP) $(PROGS_DEP) | ||
