From e170256c9b9f75cb144f213edda05af0f5c8b0f4 Mon Sep 17 00:00:00 2001 From: Quentin Legot Date: Tue, 28 Mar 2023 19:35:24 +0200 Subject: [PATCH] Fix build makefiles --- test/Makefile.tests | 15 ++++++++++++--- test/riscv_instructions/.gitignore | 5 +++++ test/riscv_instructions/Makefile | 4 ++-- test/riscv_instructions/boolean_logic/Makefile | 12 +++++++++--- .../jump_instructions/Makefile | 15 ++++++++++++--- .../simple_arithmetics/Makefile | 16 +++++++++++++--- 6 files changed, 53 insertions(+), 14 deletions(-) create mode 100644 test/riscv_instructions/.gitignore diff --git a/test/Makefile.tests b/test/Makefile.tests index 681d31f..14dba3d 100644 --- a/test/Makefile.tests +++ b/test/Makefile.tests @@ -1,5 +1,11 @@ include $(TOPDIR)/Makefile.config + USERLIB = $(TOPDIR)/userlib + +AS = $(RISCV_AS) -c +GCC = $(RISCV_GCC) +LD = $(RISCV_LD) + INCPATH += -I$(TOPDIR) -I$(USERLIB) LDFLAGS = $(RISCV_LDFLAGS) -T $(USERLIB)/ldscript.lds ASFLAGS = $(RISCV_ASFLAGS) $(INCPATH) @@ -7,16 +13,16 @@ CFLAGS = $(RISCV_CFLAGS) $(INCPATH) # Rules %.o: %.s - $(RISCV_AS) $(ASFLAGS) -c $< + $(AS) $(ASFLAGS) -c $< %.o: %.c - $(RISCV_GCC) $(CFLAGS) -c $< + $(GCC) $(CFLAGS) -c $< %.dump: %.o $(RISCV_OBJCOPY) -j .text -O $(DUMP_FORMAT) $< $@ %.guac: %.o - $(RISCV_LD) $(LDFLAGS) $+ -o $@ + $(LD) $(LDFLAGS) $+ -o $@ # Dependencies .%.d: %.s @@ -31,6 +37,9 @@ CFLAGS = $(RISCV_CFLAGS) $(INCPATH) | sed '\''s/\($*\)\.o[ :]*/\1.o $@ : /g'\'' > $@; \ [ -s $@ ] || rm -f $@' +$(PROGRAMS): + $(LD) $(LDFLAGS) $+ -o $@ + # Targets #clean: # rm -rf *.o 2> /dev/null diff --git a/test/riscv_instructions/.gitignore b/test/riscv_instructions/.gitignore new file mode 100644 index 0000000..140fad6 --- /dev/null +++ b/test/riscv_instructions/.gitignore @@ -0,0 +1,5 @@ +* +!.gitignore +!*.c +!*.md +!**/Makefile \ No newline at end of file diff --git a/test/riscv_instructions/Makefile b/test/riscv_instructions/Makefile index cabd3bb..7c9a691 100644 --- a/test/riscv_instructions/Makefile +++ b/test/riscv_instructions/Makefile @@ -1,7 +1,7 @@ build: make build -C boolean_logic/ -# make build -C jump_instructions/ -# make build -C simple_arithmetics/ + make build -C jump_instructions/ + make build -C simple_arithmetics/ dumps: make dumps -C boolean_logic/ diff --git a/test/riscv_instructions/boolean_logic/Makefile b/test/riscv_instructions/boolean_logic/Makefile index b1f6312..e9b0a52 100644 --- a/test/riscv_instructions/boolean_logic/Makefile +++ b/test/riscv_instructions/boolean_logic/Makefile @@ -1,11 +1,17 @@ -TOPDIR = ../.. -include $(TOPDIR)/Makefile.tests -build: comparisons if switch +PROGRAMS = comparisons if switch + +build: $(PROGRAMS) dumps: comparisons.dump if.dump switch.dump tests: comparisons.guac if.guac switch.guac +TOPDIR = ../.. +include $(TOPDIR)/Makefile.tests + +clean: + $(RM) comparisons comparisons.o if if.o + # Dependances $(PROGRAMS): % : $(USERLIB)/sys.o $(USERLIB)/libnachos.o %.o \ No newline at end of file diff --git a/test/riscv_instructions/jump_instructions/Makefile b/test/riscv_instructions/jump_instructions/Makefile index ce69447..71ce3c0 100644 --- a/test/riscv_instructions/jump_instructions/Makefile +++ b/test/riscv_instructions/jump_instructions/Makefile @@ -1,6 +1,15 @@ -TOPDIR = ../.. -include $(TOPDIR)/Makefile.tests +PROGRAMS = jump ret + +build: $(PROGRAMS) dumps: jump.dump ret.dump -tests: jump.guac ret.guac \ No newline at end of file +tests: jump.guac ret.guac + +clean: + $(RM) jump jump.o ret ret.o + +TOPDIR = ../.. +include $(TOPDIR)/Makefile.tests + +$(PROGRAMS): % : $(USERLIB)/sys.o $(USERLIB)/libnachos.o %.o \ No newline at end of file diff --git a/test/riscv_instructions/simple_arithmetics/Makefile b/test/riscv_instructions/simple_arithmetics/Makefile index 623b297..9b42a4b 100644 --- a/test/riscv_instructions/simple_arithmetics/Makefile +++ b/test/riscv_instructions/simple_arithmetics/Makefile @@ -1,6 +1,16 @@ -TOPDIR = ../.. -include $(TOPDIR)/Makefile.tests + +PROGRAMS = unsigned_addition unsigned_division unsigned_multiplication unsigned_substraction + +build: $(PROGRAMS) dumps: unsigned_addition.dump unsigned_division.dump unsigned_multiplication.dump unsigned_substraction.dump -tests: unsigned_addition.guac unsigned_division.guac unsigned_multiplication.guac unsigned_substraction.guac \ No newline at end of file +tests: unsigned_addition.guac unsigned_division.guac unsigned_multiplication.guac unsigned_substraction.guac + +clean: + $(RM) unsigned_addition unsigned_addition.o unsigned_division unsigned_division.o unsigned_multiplication unsigned_multiplication.o unsigned_substraction unsigned_substraction.o + +TOPDIR = ../.. +include $(TOPDIR)/Makefile.tests + +$(PROGRAMS): % : $(USERLIB)/sys.o $(USERLIB)/libnachos.o %.o \ No newline at end of file