SHELL = /bin/sh
-LDFLAGS = -nostdlib -static -Wl,-T,elf.x
+LDFLAGS = -nostdlib -static
LDLIBS = $(shell $(CC) -print-libgcc-file-name)
+# Uncomment the line below to round up segment sizes to full pages for
+# testing purposes only.
+#LDFLAGS += -Wl,-T,fullpage.x
+
VPATH = ../..
DEFINES = -DUSER
-CPPFLAGS = -nostdinc -I../.. -I- -I../../lib -I../../lib/user
+CPPFLAGS = -nostdinc -I../.. -I- -I../../lib -I../../lib/user \
+ -include constants.h
# C library sources linked into every test program.
LIB_SRC = lib/debug.c # Debug code.
define TEMPLATE
$(1)_OBJ = $(patsubst %.c,%.o,$(patsubst %.S,%.o,$($(1)_SRC)))
-$(1): $$($(1)_OBJ) $$(LIB)
+$(1): $$($(1)_OBJ) $$(LIB) | ./lib/user
endef
+./lib/user:
+ $(MKDIR) -p lib/user
+
$(foreach prog,$(PROGS),$(eval $(call TEMPLATE,$(prog))))
$(PROGS): $(LIB)