From 0a399b1135a9af3b488953b934b25687ab87018d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustav=20S=C3=B6rn=C3=A4s?= Date: Mon, 23 Nov 2020 15:18:13 +0100 Subject: only link librust when needed --- src/Makefile.userprog | 10 ++++++---- src/examples/Makefile | 17 ++++++++++------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/Makefile.userprog b/src/Makefile.userprog index 165d7ed..9700775 100644 --- a/src/Makefile.userprog +++ b/src/Makefile.userprog @@ -23,7 +23,8 @@ lib/user_SRC += lib/user/console.c # Console code. LIB_OBJ = $(patsubst %.c,%.o,$(patsubst %.S,%.o,$(lib_SRC) $(lib/user_SRC))) LIB_DEP = $(patsubst %.o,%.d,$(LIB_OBJ)) -LIB = lib/user/entry.o libc.a librust.a +LIB = lib/user/entry.o libc.a +LIB_RUST = $(LIB) librust.a LIBDIR_RUST = $(SRCDIR)/../rust @@ -39,11 +40,12 @@ lib/user/syscall.o: CPPFLAGS += -fno-omit-frame-pointer define TEMPLATE $(1)_OBJ = $(patsubst %.c,%.o,$(patsubst %.S,%.o,$($(1)_SRC))) -$(1): $$($(1)_OBJ) $$(LIB) $$(LDSCRIPT) - $$(CC) $$(LDFLAGS) $$($(1)_OBJ) $$(LIB) -o $$@ +$(1): $$($(1)_OBJ) $(2) $$(LDSCRIPT) + $$(CC) $$(LDFLAGS) $$($(1)_OBJ) $(2) -o $$@ endef -$(foreach prog,$(PROGS),$(eval $(call TEMPLATE,$(prog)))) +$(foreach prog,$(PROGS),$(eval $(call TEMPLATE,$(prog),$(LIB)))) +$(foreach prog,$(PROGS_RUST),$(eval $(call TEMPLATE,$(prog),$(LIB_RUST)))) libc.a: $(LIB_OBJ) rm -f $@ diff --git a/src/examples/Makefile b/src/examples/Makefile index d8c4a90..dba72c9 100644 --- a/src/examples/Makefile +++ b/src/examples/Makefile @@ -3,13 +3,16 @@ SRCDIR = .. # Test programs to compile, and a list of sources for each. # To add a new test, put its name on the PROGS list # and then add a name_SRC line that lists its source files. -PROGS = cat cmp cp echo halt hex-dump ls mcat mcp mkdir pwd rm shell \ - bubsort insult lineup matmult recursor \ - sumargv pfs pfs_reader pfs_writer dummy longrun \ - child parent generic_parent longrun_interactive busy \ - line_echo file_syscall_tests longrun_nowait shellcode \ - crack overflow dir_stress create_file create_remove_file \ - rust +PROGS_C = cat cmp cp echo halt hex-dump ls mcat mcp mkdir pwd rm shell \ + bubsort insult lineup matmult recursor \ + sumargv pfs pfs_reader pfs_writer dummy longrun \ + child parent generic_parent longrun_interactive busy \ + line_echo file_syscall_tests longrun_nowait shellcode \ + crack overflow dir_stress create_file create_remove_file + +PROGS_RUST = rust + +PROGS = $(PROGS_C) $(PROGS_RUST) rust_SRC = rust.c -- cgit v1.2.1