From c27118308f2c910289943e564d47cd8378d224e8 Mon Sep 17 00:00:00 2001 From: farisawan-2000 Date: Tue, 1 Jun 2021 18:24:46 -0400 Subject: [PATCH] Added build system --- Makefile | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..a06d890a --- /dev/null +++ b/Makefile @@ -0,0 +1,33 @@ +# Makefile for s2d_engine.a + +TARGET = s2d_engine.a + +BUILD_DIR ?= build +DUMMY != mkdir -p $(BUILD_DIR) + +C_FILES = $(wildcard ./*.c) +O_FILES = $(foreach file,$(C_FILES),$(BUILD_DIR)/$(file:.c=.o)) + +CROSS := mips-linux-gnu- +CC = $(CROSS)gcc +AR = $(CROSS)ar + +INCLUDE_BASE := ../../ +I_DIRS = src include/n64/PR include/n64 include/libc include . +FULL_I_DIRS = $(addprefix $(INCLUDE_BASE),$(I_DIRS)) +I_FLAGS = $(foreach i,$(FULL_I_DIRS),-I$(i)) + +TARGET_CFLAGS = -nostdinc -I include/libc -DTARGET_N64 -DF3DEX_GBI_2 -DNON_MATCHING -DAVOID_UB +CFLAGS := -Wall $(TARGET_CFLAGS) $(I_FLAGS) -march=vr4300 -mtune=vr4300 -mfix4300 -mabi=32 -mno-shared -G 0 -fno-PIC -mno-abicalls -fno-zero-initialized-in-bss -fno-toplevel-reorder -Wno-missing-braces + +default: all + +all: $(BUILD_DIR)/$(TARGET) + +$(BUILD_DIR)/$(TARGET): $(O_FILES) + $(AR) rcs -o $@ $(O_FILES) + +$(BUILD_DIR)/%.o: %.c + $(CC) -c $(CFLAGS) -o $@ $< + +print-% : ; $(info $* is a $(flavor $*) variable set to [$($*)]) @true