diff --git a/.forgejo/workflows/build.yml b/.forgejo/workflows/build.yml index fe3c9f4..e3cefbb 100644 --- a/.forgejo/workflows/build.yml +++ b/.forgejo/workflows/build.yml @@ -10,7 +10,7 @@ jobs: - name: Install toolchain run: apt install -y gcc-x86-64-linux-gnu gcc-aarch64-linux-gnu make - name: Install dependencies - run: apt install -y elfutils + run: apt install -y libelf-dev - name: Clone repository run: git clone https://git.m724.eu/Minecon724/criscv.git . - name: Package for x86_64 diff --git a/Makefile b/Makefile index 7e37940..13c758b 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,8 @@ # Compiler to use CC ?= gcc -BASE_CFLAGS := -Wall -Wextra -std=gnu23 -I include +CFLAGS = -Wall -Wextra -std=gnu23 -I include +LDFLAGS = -lelf # Directory for build outputs BUILD_DIR := build @@ -20,20 +21,19 @@ TARGET := $(BUILD_DIR)/$(PROGRAM_NAME) # Default target: build the executable -all: CFLAGS := $(BASE_CFLAGS) -O3 -lelf +all: CFLAGS += -O3 all: $(TARGET) # Debug target -debug: CFLAGS := $(BASE_CFLAGS) -O0 -g -lelf +debug: CFLAGS += -O0 -g debug: $(TARGET) # Declare 'all' and 'clean' as phony targets (not files) -.PHONY: all debug static clean - +.PHONY: all debug clean # Rule to link object files into the final executable $(TARGET): $(OBJS) | $(BUILD_DIR) - $(CC) $(CFLAGS) $^ -o $@ + $(CC) $(CFLAGS) $^ $(LDFLAGS) -o $@ du -b $(TARGET) # Size of the executable in bytes # Rule to compile source files into object files