Updated makefile

This commit is contained in:
François Autin 2023-03-08 13:02:03 +01:00
parent f1a03b96a3
commit 765f5b8328
No known key found for this signature in database
GPG Key ID: 343F5D382E1DD77C
7 changed files with 72 additions and 9 deletions

View File

@ -6,8 +6,16 @@ include $(TOPDIR)/Makefile.config
# #
dumps: dumps:
$(MAKE) dumps -C riscv_instructions/ $(MAKE) dumps -C riscv_instructions/
mkdir -p ${TOPDIR}/target mkdir -p ${TOPDIR}/target/dumps/
find . -name '*.dump' -exec mv {} ${TOPDIR}/target \; find . -name '*.dump' -exec mv {} ${TOPDIR}/target/dumps/ \;
user_lib:
$(MAKE) -C userlib/
tests: user_lib
$(MAKE) tests -C riscv_instructions/
mkdir -p ${TOPDIR}/target/guac/
find . -name '*.guac' -exec mv {} ${TOPDIR}/target/guac/ \;
clean: clean:
rm -rf $(TOPDIR)/target rm -rf $(TOPDIR)/target

View File

@ -0,0 +1,38 @@
include $(TOPDIR)/Makefile.config
USERLIB = $(TOPDIR)/userlib
INCPATH += -I$(TOPDIR) -I$(USERLIB)
LDFLAGS = $(RISCV_LDFLAGS) -T $(USERLIB)/ldscript.lds
ASFLAGS = $(RISCV_ASFLAGS) $(INCPATH)
CFLAGS = $(RISCV_CFLAGS) $(INCPATH)
# Rules
%.o: %.s
$(RISCV_AS) $(ASFLAGS) -c $<
%.o: %.c
$(RISCV_GCC) $(CFLAGS) -c $<
%.dump: %.o
$(RISCV_OBJCOPY) -j .text -O $(DUMP_FORMAT) $< $@
%.guac: %.o
$(RISCV_LD) $(LDFLAGS) $+ -o $@
# Dependencies
.%.d: %.s
@echo Generating dependencies for $<
@$(SHELL) -ec '$(GCC) -x assembler-with-cpp -M $(ASFLAGS) $< \
| sed '\''s/\($*\)\.o[ :]*/\1.o $@ : /g'\'' > $@; \
[ -s $@ ] || rm -f $@'
.%.d: %.c
@echo Generating dependencies for $<
@$(SHELL) -ec '$(GCC) -M $(CFLAGS) $< \
| sed '\''s/\($*\)\.o[ :]*/\1.o $@ : /g'\'' > $@; \
[ -s $@ ] || rm -f $@'
# Targets
#clean:
# rm -rf *.o 2> /dev/null
# rm -rf *.dump 2> /dev/null
# rm -rf *.guac 2> /dev/null

View File

@ -1,4 +1,9 @@
dumps: dumps:
make dumps -C boolean_logic/ make dumps -C boolean_logic/
make dumps -C jump_instructions/ make dumps -C jump_instructions/
make dumps -C simple_arithmetics/ make dumps -C simple_arithmetics/
tests:
make tests -C boolean_logic/
make tests -C jump_instructions/
make tests -C simple_arithmetics/

View File

@ -1,4 +1,9 @@
TOPDIR = ../.. TOPDIR = ../..
include $(TOPDIR)/Makefile.dumps include $(TOPDIR)/Makefile.tests
dumps: comparisons.dump if.dump switch.dump dumps: comparisons.dump if.dump switch.dump
tests: comparisons.guac if.guac switch.guac
# Dependances
$(PROGRAMS): % : $(USERLIB)/sys.o $(USERLIB)/libnachos.o %.o

View File

@ -1,4 +1,6 @@
TOPDIR = ../.. TOPDIR = ../..
include $(TOPDIR)/Makefile.dumps include $(TOPDIR)/Makefile.tests
dumps: jump.dump ret.dump dumps: jump.dump ret.dump
tests: jump.guac ret.guac

View File

@ -1,4 +1,6 @@
TOPDIR = ../.. TOPDIR = ../..
include $(TOPDIR)/Makefile.dumps include $(TOPDIR)/Makefile.tests
dumps: unsigned_addition.dump unsigned_division.dump unsigned_multiplication.dump unsigned_substraction.dump 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

View File

@ -1,3 +1,6 @@
#include "userlib/syscall.h"
#include "userlib/libnachos.h"
// EXPECTS TWO VARIABLES WITH A VALUE OF UNSIGNED 1 // EXPECTS TWO VARIABLES WITH A VALUE OF UNSIGNED 1
int main() { int main() {
unsigned int x = 0; unsigned int x = 0;