10d2c07491002b5e33943452c2984166a168e40f
[pintos-anon] / grading / vm / Makefile.posix
1 # This makefile allows the VM tests to be compiled on a POSIX host
2 # system.  It's easier to test them on a host than under Pintos.
3 # Before and after using this Makefile, run `make clean' to ensure
4 # that Pintos and host objects don't interfere with one another.
5
6 SRCDIR = ../../src
7
8 include $(SRCDIR)/Make.config
9 include Make.progs
10
11 VPATH = $(SRCDIR)
12
13 DEFINES =
14 CPPFLAGS = -I.
15 CFLAGS = -Wall -W -Wstrict-prototypes -Wmissing-prototypes
16
17 PROGS_SRC = $(foreach prog,$(PROGS),$($(subst -,_,$(prog))_SRC))
18 PROGS_OBJ = $(patsubst %.c,%.o,$(patsubst %.S,%.o,$(PROGS_SRC)))
19 PROGS_DEP = $(patsubst %.o,%.d,$(PROGS_OBJ))
20
21 all: $(PROGS)
22
23 define TEMPLATE
24 $(2)_OBJ = $(patsubst %.c,%.o,$(patsubst %.S,%.o,$($(2)_SRC)))
25 $(1): $$($(2)_OBJ) posix-compat.o
26         $$(CC) $$(LDFLAGS) $$^ $$(LDLIBS) -o $$@
27 endef
28
29 $(foreach prog,$(PROGS),$(eval $(call TEMPLATE,$(prog),$(subst -,_,$(prog)))))
30
31 $(PROGS): $(LIB)
32
33 libc.a: $(LIB_OBJ)
34         rm -f $@
35         ar r $@ $^
36         ranlib $@
37
38 clean::
39         rm -f $(PROGS) $(PROGS_OBJ) $(PROGS_DEP)
40         rm -f $(LIB_DEP) $(LIB_OBJ) lib/user/entry.[do] libc.a 
41
42 .PHONY: all clean
43
44 -include $(LIB_DEP) $(PROGS_DEP)
45