summaryrefslogtreecommitdiffstats
path: root/Makefile.userprog
diff options
context:
space:
mode:
authormanuel <manuel@mausz.at>2012-03-27 11:51:08 +0200
committermanuel <manuel@mausz.at>2012-03-27 11:51:08 +0200
commit4f670845ff9ab6c48bcb5f7bf4d4ef6dc3c3064b (patch)
tree868c52e06f207b5ec8a3cc141f4b8b2bdfcc165c /Makefile.userprog
parenteae0bd57f0a26314a94785061888d193d186944a (diff)
downloadprogos-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.userprog52
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.
10lib_SRC = lib/debug.c # Debug code.
11lib_SRC += lib/random.c # Pseudo-random numbers.
12lib_SRC += lib/stdio.c # I/O library.
13lib_SRC += lib/stdlib.c # Utility functions.
14lib_SRC += lib/string.c # String functions.
15lib_SRC += lib/arithmetic.c # 64-bit arithmetic for GCC.
16lib_SRC += lib/ustar.c # Unix standard tar format utilities.
17
18# User level only library code.
19lib/user_SRC = lib/user/debug.c # Debug helpers.
20lib/user_SRC += lib/user/syscall.c # System calls.
21lib/user_SRC += lib/user/console.c # Console code.
22
23LIB_OBJ = $(patsubst %.c,%.o,$(patsubst %.S,%.o,$(lib_SRC) $(lib/user_SRC)))
24LIB_DEP = $(patsubst %.o,%.d,$(LIB_OBJ))
25LIB = lib/user/entry.o libc.a
26
27PROGS_SRC = $(foreach prog,$(PROGS),$($(prog)_SRC))
28PROGS_OBJ = $(patsubst %.c,%.o,$(patsubst %.S,%.o,$(PROGS_SRC)))
29PROGS_DEP = $(patsubst %.o,%.d,$(PROGS_OBJ))
30
31all: $(PROGS)
32
33define 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 $$@
37endef
38
39$(foreach prog,$(PROGS),$(eval $(call TEMPLATE,$(prog))))
40
41libc.a: $(LIB_OBJ)
42 rm -f $@
43 ar r $@ $^
44 ranlib $@
45
46clean::
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)