$(PROGS): CPPFLAGS += -I$(SRCDIR)/lib/user -I.
# Linker flags.
-$(PROGS): LDFLAGS = -nostdlib -static -Wl,-T,$(LDSCRIPT)
-$(PROGS): LDLIBS = $(shell $(CC) -print-libgcc-file-name)
+$(PROGS): LDFLAGS += -nostdlib -static -Wl,-T,$(LDSCRIPT)
$(PROGS): LDSCRIPT = $(SRCDIR)/lib/user/user.lds
# Library code shared between kernel and user programs.
lib_SRC += lib/stdio.c # I/O library.
lib_SRC += lib/stdlib.c # Utility functions.
lib_SRC += lib/string.c # String functions.
+lib_SRC += lib/arithmetic.c # 64-bit arithmetic for GCC.
+lib_SRC += lib/ustar.c # Unix standard tar format utilities.
# User level only library code.
lib/user_SRC = lib/user/debug.c # Debug helpers.
define TEMPLATE
$(1)_OBJ = $(patsubst %.c,%.o,$(patsubst %.S,%.o,$($(1)_SRC)))
$(1): $$($(1)_OBJ) $$(LIB) $$(LDSCRIPT)
- $$(CC) $$(LDFLAGS) $$($(1)_OBJ) $$(LIB) $$(LDLIBS) -o $$@
+ $$(CC) $$(LDFLAGS) $$($(1)_OBJ) $$(LIB) -o $$@
endef
$(foreach prog,$(PROGS),$(eval $(call TEMPLATE,$(prog))))