Work on userprog tests.
[pintos-anon] / src / Makefile.userprog
1 # -*- makefile -*-
2
3 include $(SRCDIR)/Make.config
4
5 SHELL = /bin/sh
6
7 VPATH = $(SRCDIR)
8
9 DEFINES = -DUSER
10 CPPFLAGS = -nostdinc -I$(SRCDIR) -I- -I$(SRCDIR)/lib -I$(SRCDIR)/lib/user
11
12 # Linker flags.
13 LDFLAGS = -nostdlib -static -s
14 LDLIBS = $(shell $(CC) -print-libgcc-file-name)
15
16 # Uncomment the line below to round up segment sizes to full pages for
17 # testing purposes only.
18 #LDFLAGS += -Wl,-T,fullpage.x
19
20 # C library sources linked into every test program.
21 LIB_SRC  = lib/debug.c                  # Debug code.
22 LIB_SRC += lib/random.c                 # Pseudo-random numbers.
23 LIB_SRC += lib/stdio.c                  # I/O library.
24 LIB_SRC += lib/stdlib.c                 # atoi()
25 LIB_SRC += lib/string.c                 # String functions.
26 LIB_SRC += lib/user/syscall.c           # System calls.
27 LIB_SRC += lib/user/syscall-stub.S      # System call stub.
28 LIB_SRC += lib/user/console.c           # Console code.
29
30 LIB_OBJ = $(patsubst %.c,%.o,$(patsubst %.S,%.o,$(LIB_SRC)))
31 LIB_DEP = $(patsubst %.o,%.d,$(LIB_OBJ))
32 LIB = lib/user/entry.o libc.a
33
34 PROGS_SRC = $(foreach prog,$(PROGS),$($(prog)_SRC))
35 PROGS_OBJ = $(patsubst %.c,%.o,$(patsubst %.S,%.o,$(PROGS_SRC)))
36 PROGS_DEP = $(patsubst %.o,%.d,$(PROGS_OBJ))
37
38 all: $(PROGS)
39
40 define TEMPLATE
41 $(1)_OBJ = $(patsubst %.c,%.o,$(patsubst %.S,%.o,$($(1)_SRC)))
42 $(1): $$($(1)_OBJ) $$(LIB)
43 endef
44
45 $(foreach prog,$(PROGS),$(eval $(call TEMPLATE,$(prog))))
46
47 $(PROGS): $(LIB)
48
49 libc.a: $(LIB_OBJ)
50         rm -f $@
51         ar r $@ $^
52         ranlib $@
53
54 clean::
55         rm -f $(PROGS) $(PROGS_OBJ) $(PROGS_DEP)
56         rm -f $(LIB_DEP) $(LIB_OBJ) lib/user/entry.[do] libc.a 
57
58 .PHONY: all clean
59
60 -include $(LIB_DEP) $(PROGS_DEP)