diff --git a/Makefile b/Makefile index 3574f92..b54efad 100644 --- a/Makefile +++ b/Makefile @@ -1,23 +1,10 @@ # Compiler to use CC ?= gcc -# Add debugging output -$(info CC is set to $(CC)) - -# Separate CFLAGS and LDFLAGS -CFLAGS = -Wall -Wextra -std=gnu17 -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)) +CFLAGS = -Wall -Wextra -std=gnu17 -I include -lelf # Directory for build outputs -BUILD_DIR := build +BUILD_DIR := build-$(uname -i) # Name of the output program PROGRAM_NAME ?= criscv @@ -31,6 +18,7 @@ OBJS := $(patsubst src/%.c,$(BUILD_DIR)/obj/%.o,$(SRCS)) # Name of the final executable TARGET := $(BUILD_DIR)/$(PROGRAM_NAME) + # Default target: build the executable all: CFLAGS += -O3 all: $(TARGET) @@ -44,18 +32,12 @@ debug: $(TARGET) # Rule to link object files into the final executable $(TARGET): $(OBJS) | $(BUILD_DIR) - @echo "Linking $(TARGET)" - @echo "Command: $(CC) $(CFLAGS) $^ -o $@ $(LDFLAGS)" - $(CC) $(CFLAGS) $^ -o $@ $(LDFLAGS) - @echo "Linking complete" + $(CC) $(CFLAGS) $^ -o $@ du -b $(TARGET) # Size of the executable in bytes # Rule to compile source files into object files $(BUILD_DIR)/obj/%.o: src/%.c | $(BUILD_DIR)/obj - @echo "Compiling $<" - @echo "Command: $(CC) $(CFLAGS) -c $< -o $@" $(CC) $(CFLAGS) -c $< -o $@ - @echo "Compilation complete" # Create build directories if they don't exist $(BUILD_DIR) $(BUILD_DIR)/obj: @@ -63,14 +45,4 @@ $(BUILD_DIR) $(BUILD_DIR)/obj: # Clean target: remove the build directory clean: - 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 \ No newline at end of file + rm -rf $(BUILD_DIR) \ No newline at end of file