parent
bf59ce8dcd
commit
bcddbcbea4
3 changed files with 33 additions and 5 deletions
|
@ -13,6 +13,7 @@ jobs:
|
||||||
run: apt install -y libelf-dev
|
run: apt install -y libelf-dev
|
||||||
- name: Clone repository
|
- name: Clone repository
|
||||||
run: git clone https://git.m724.eu/Minecon724/criscv.git .
|
run: git clone https://git.m724.eu/Minecon724/criscv.git .
|
||||||
|
- run: make libinfo
|
||||||
- name: Package for x86_64
|
- name: Package for x86_64
|
||||||
run: LD_LIBRARY_PATH=/usr/include CC=x86_64-linux-gnu-gcc PROGRAM_NAME=crisc-x86_64 make
|
run: LD_LIBRARY_PATH=/usr/include CC=x86_64-linux-gnu-gcc PROGRAM_NAME=crisc-x86_64 make
|
||||||
- name: Package for aarch64
|
- name: Package for aarch64
|
||||||
|
|
34
Makefile
34
Makefile
|
@ -1,7 +1,20 @@
|
||||||
# Compiler to use
|
# Compiler to use
|
||||||
CC ?= gcc
|
CC ?= gcc
|
||||||
|
|
||||||
CFLAGS = -Wall -Wextra -std=gnu23 -I include -lelf
|
# Add debugging output
|
||||||
|
$(info CC is set to $(CC))
|
||||||
|
|
||||||
|
# Separate CFLAGS and LDFLAGS
|
||||||
|
CFLAGS = -Wall -Wextra -std=gnu23 -I include
|
||||||
|
LDFLAGS = -lelf
|
||||||
|
|
||||||
|
# Add potential additional library path (update this path if needed)
|
||||||
|
LIBRARY_PATH := /usr/lib/x86_64-linux-gnu
|
||||||
|
LDFLAGS += -L$(LIBRARY_PATH)
|
||||||
|
|
||||||
|
# Add debugging output
|
||||||
|
$(info CFLAGS is set to $(CFLAGS))
|
||||||
|
$(info LDFLAGS is set to $(LDFLAGS))
|
||||||
|
|
||||||
# Directory for build outputs
|
# Directory for build outputs
|
||||||
BUILD_DIR := build
|
BUILD_DIR := build
|
||||||
|
@ -18,7 +31,6 @@ OBJS := $(patsubst src/%.c,$(BUILD_DIR)/obj/%.o,$(SRCS))
|
||||||
# Name of the final executable
|
# Name of the final executable
|
||||||
TARGET := $(BUILD_DIR)/$(PROGRAM_NAME)
|
TARGET := $(BUILD_DIR)/$(PROGRAM_NAME)
|
||||||
|
|
||||||
|
|
||||||
# Default target: build the executable
|
# Default target: build the executable
|
||||||
all: CFLAGS += -O3
|
all: CFLAGS += -O3
|
||||||
all: $(TARGET)
|
all: $(TARGET)
|
||||||
|
@ -32,12 +44,18 @@ debug: $(TARGET)
|
||||||
|
|
||||||
# Rule to link object files into the final executable
|
# Rule to link object files into the final executable
|
||||||
$(TARGET): $(OBJS) | $(BUILD_DIR)
|
$(TARGET): $(OBJS) | $(BUILD_DIR)
|
||||||
$(CC) $(CFLAGS) $^ -o $@
|
@echo "Linking $(TARGET)"
|
||||||
|
@echo "Command: $(CC) $(CFLAGS) $^ -o $@ $(LDFLAGS)"
|
||||||
|
$(CC) $(CFLAGS) $^ -o $@ $(LDFLAGS)
|
||||||
|
@echo "Linking complete"
|
||||||
du -b $(TARGET) # Size of the executable in bytes
|
du -b $(TARGET) # Size of the executable in bytes
|
||||||
|
|
||||||
# Rule to compile source files into object files
|
# Rule to compile source files into object files
|
||||||
$(BUILD_DIR)/obj/%.o: src/%.c | $(BUILD_DIR)/obj
|
$(BUILD_DIR)/obj/%.o: src/%.c | $(BUILD_DIR)/obj
|
||||||
|
@echo "Compiling $<"
|
||||||
|
@echo "Command: $(CC) $(CFLAGS) -c $< -o $@"
|
||||||
$(CC) $(CFLAGS) -c $< -o $@
|
$(CC) $(CFLAGS) -c $< -o $@
|
||||||
|
@echo "Compilation complete"
|
||||||
|
|
||||||
# Create build directories if they don't exist
|
# Create build directories if they don't exist
|
||||||
$(BUILD_DIR) $(BUILD_DIR)/obj:
|
$(BUILD_DIR) $(BUILD_DIR)/obj:
|
||||||
|
@ -46,3 +64,13 @@ $(BUILD_DIR) $(BUILD_DIR)/obj:
|
||||||
# Clean target: remove the build directory
|
# Clean target: remove the build directory
|
||||||
clean:
|
clean:
|
||||||
rm -rf $(BUILD_DIR)
|
rm -rf $(BUILD_DIR)
|
||||||
|
|
||||||
|
# Add a new target to print library information
|
||||||
|
.PHONY: libinfo
|
||||||
|
libinfo:
|
||||||
|
@echo "Searching for libelf..."
|
||||||
|
@find /usr -name "libelf.so*" 2>/dev/null || echo "libelf not found in /usr"
|
||||||
|
@echo "Library search path:"
|
||||||
|
@echo $(LD_LIBRARY_PATH)
|
||||||
|
@echo "Compiler search path:"
|
||||||
|
$(CC) -print-search-dirs
|
|
@ -1,7 +1,6 @@
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "cpu.h" // for structs
|
|
||||||
#include "address_space.h"
|
#include "address_space.h"
|
||||||
#include "instruction_executor.h"
|
#include "instruction_executor.h"
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue