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
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)