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