3 include $(SRCDIR)/Make.config
5 $(PROGS): CPPFLAGS += -I$(SRCDIR)/lib/user -I.
8 $(PROGS): LDFLAGS = -nostdlib -static -Wl,-T,$(LDSCRIPT)
9 $(PROGS): LDLIBS = $(shell $(CC) -print-libgcc-file-name)
10 $(PROGS): LDSCRIPT = $(SRCDIR)/lib/user/normal.lds
11 # Uncomment the following line to round up section sizes
12 # to full pages (for debugging only).
13 #$(PROGS): LDSCRIPT = $(SRCDIR)/lib/user/fullpage.lds
15 # Library code shared between kernel and user programs.
16 lib_SRC = lib/debug.c # Debug code.
17 lib_SRC += lib/random.c # Pseudo-random numbers.
18 lib_SRC += lib/stdio.c # I/O library.
19 lib_SRC += lib/stdlib.c # Utility functions.
20 lib_SRC += lib/string.c # String functions.
22 # User level only library code.
23 lib/user_SRC = lib/user/debug.c # Debug helpers.
24 lib/user_SRC += lib/user/syscall.c # System calls.
25 lib/user_SRC += lib/user/console.c # Console code.
27 LIB_OBJ = $(patsubst %.c,%.o,$(patsubst %.S,%.o,$(lib_SRC) $(lib/user_SRC)))
28 LIB_DEP = $(patsubst %.o,%.d,$(LIB_OBJ))
29 LIB = lib/user/entry.o libc.a
31 PROGS_SRC = $(foreach prog,$(PROGS),$($(prog)_SRC))
32 PROGS_OBJ = $(patsubst %.c,%.o,$(patsubst %.S,%.o,$(PROGS_SRC)))
33 PROGS_DEP = $(patsubst %.o,%.d,$(PROGS_OBJ))
38 $(1)_OBJ = $(patsubst %.c,%.o,$(patsubst %.S,%.o,$($(1)_SRC)))
39 $(1): $$($(1)_OBJ) $$(LIB) $$(LDSCRIPT)
40 $$(CC) $$(LDFLAGS) $$($(1)_OBJ) $$(LIB) $$(LDLIBS) -o $$@
43 $(foreach prog,$(PROGS),$(eval $(call TEMPLATE,$(prog))))
51 rm -f $(PROGS) $(PROGS_OBJ) $(PROGS_DEP)
52 rm -f $(LIB_DEP) $(LIB_OBJ) lib/user/entry.[do] libc.a
56 -include $(LIB_DEP) $(PROGS_DEP)