3 $(PROGS): CPPFLAGS += -I$(SRCDIR)/lib/user -I.
6 $(PROGS): LDFLAGS = -nostdlib -static -Wl,-T,$(LDSCRIPT)
7 $(PROGS): LDSCRIPT = $(SRCDIR)/lib/user/user.lds
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
17 # User level only library code.
18 lib/user_SRC = lib/user/debug.c # Debug helpers.
19 lib/user_SRC += lib/user/syscall.c # System calls.
20 lib/user_SRC += lib/user/console.c # Console code.
22 LIB_OBJ = $(patsubst %.c,%.o,$(patsubst %.S,%.o,$(lib_SRC) $(lib/user_SRC)))
23 LIB_DEP = $(patsubst %.o,%.d,$(LIB_OBJ))
24 LIB = lib/user/entry.o libc.a
26 PROGS_SRC = $(foreach prog,$(PROGS),$($(prog)_SRC))
27 PROGS_OBJ = $(patsubst %.c,%.o,$(patsubst %.S,%.o,$(PROGS_SRC)))
28 PROGS_DEP = $(patsubst %.o,%.d,$(PROGS_OBJ))
33 $(1)_OBJ = $(patsubst %.c,%.o,$(patsubst %.S,%.o,$($(1)_SRC)))
34 $(1): $$($(1)_OBJ) $$(LIB) $$(LDSCRIPT)
35 $$(CC) $$(LDFLAGS) $$($(1)_OBJ) $$(LIB) -o $$@
38 $(foreach prog,$(PROGS),$(eval $(call TEMPLATE,$(prog))))
46 rm -f $(PROGS) $(PROGS_OBJ) $(PROGS_DEP)
47 rm -f $(LIB_DEP) $(LIB_OBJ) lib/user/entry.[do] libc.a
51 -include $(LIB_DEP) $(PROGS_DEP)