X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2FMakefile.userprog;h=29bdcf8b73f1306f250123310588ad982c54dc5d;hb=538e0cc1951cc2edf253918fd83fc3c36d9a6398;hp=6b3c25027d2df1445ee00472292f17d619b044e3;hpb=9d946c0ccc9ff18bfe02e66ee6abf854f743a58e;p=pintos-anon diff --git a/src/Makefile.userprog b/src/Makefile.userprog index 6b3c250..29bdcf8 100644 --- a/src/Makefile.userprog +++ b/src/Makefile.userprog @@ -6,8 +6,8 @@ SHELL = /bin/sh VPATH = $(SRCDIR) -DEFINES = -DUSER -CPPFLAGS = -nostdinc -I$(SRCDIR) -I- -I$(SRCDIR)/lib -I$(SRCDIR)/lib/user +DEFINES = -DPINTOS -DUSER +CPPFLAGS = -nostdinc -I$(SRCDIR) -I- -I$(SRCDIR)/lib -I$(SRCDIR)/lib/user -I. # Linker flags. LDFLAGS = -nostdlib -static -s @@ -27,18 +27,19 @@ LIB_OBJ = $(patsubst %.c,%.o,$(patsubst %.S,%.o,$(LIB_SRC))) LIB_DEP = $(patsubst %.o,%.d,$(LIB_OBJ)) LIB = lib/user/entry.o libc.a -PROGS_SRC = $(foreach prog,$(PROGS),$($(prog)_SRC)) +PROGS_SRC = $(foreach prog,$(PROGS),$($(subst -,_,$(prog))_SRC)) PROGS_OBJ = $(patsubst %.c,%.o,$(patsubst %.S,%.o,$(PROGS_SRC))) PROGS_DEP = $(patsubst %.o,%.d,$(PROGS_OBJ)) all: $(PROGS) define TEMPLATE -$(1)_OBJ = $(patsubst %.c,%.o,$(patsubst %.S,%.o,$($(1)_SRC))) -$(1): $$($(1)_OBJ) $$(LIB) +$(2)_OBJ = $(patsubst %.c,%.o,$(patsubst %.S,%.o,$($(2)_SRC))) +$(1): $$($(2)_OBJ) $$(LIB) + $$(CC) $$(LDFLAGS) $$^ $$(LDLIBS) -o $$@ endef -$(foreach prog,$(PROGS),$(eval $(call TEMPLATE,$(prog)))) +$(foreach prog,$(PROGS),$(eval $(call TEMPLATE,$(prog),$(subst -,_,$(prog))))) $(PROGS): $(LIB)