Files

93 lines
2.9 KiB
Makefile
Raw Permalink Normal View History

2024-04-11 13:10:18 -04:00
# Make `OPT` -g for better debugging info.
2024-04-03 19:16:44 -04:00
OPT := -O2
# If -g option was set, then add some debugging flags for the stack tracer.
ifneq (,$(findstring -g,$(OPT)))
2025-07-04 14:43:05 -04:00
OPT += -rdynamic -ldl -lelf -ldwarf -DDEBUG -I/usr/include/libdwarf
endif
2020-05-27 19:14:56 -05:00
CC := gcc
CXX := g++
2024-04-03 19:16:44 -04:00
CFLAGS := -I . -Wall -Wextra -Wno-unused-parameter -pedantic -std=c99 $(OPT) -s
# List of specific errors to ignore
IGNORE_W_ERRORS := -Wno-unused-parameter -Wno-misleading-indentation -Wno-extra
2025-02-11 19:44:41 +00:00
CXXFLAGS := -I . -I dkr_assets_tool_src/ -std=c++17 $(OPT)
2020-05-27 19:14:56 -05:00
LDFLAGS := -lm
2022-10-30 00:33:21 +00:00
PROGRAMS := n64crc dkr_assets_tool
2022-03-18 18:35:32 -04:00
2025-03-25 09:07:00 -04:00
UNAME_S := $(shell uname -s)
2025-02-11 19:44:41 +00:00
# MacOS has a slightly different name for grep, so check to see if it needs to be used.
2025-03-25 09:07:00 -04:00
ifeq ($(UNAME_S),Windows_NT)
$(error Native Windows is currently unsupported for building this repository, use WSL instead c:)
else ifeq ($(UNAME_S),Darwin)
DETECTED_OS := macos
2025-02-11 19:44:41 +00:00
CXXFLAGS += -I/opt/homebrew/include
LDFLAGS += -I/opt/homebrew/lib -lpcre2-8
2025-03-25 09:07:00 -04:00
else ifeq ($(UNAME_S),Linux)
DETECTED_OS := linux
2025-02-11 19:44:41 +00:00
CXXFLAGS += -Werror -Wall $(IGNORE_W_ERRORS) -lpcre2-8
2025-04-03 19:07:38 -04:00
UNAME_M := $(shell uname -m)
2025-03-25 09:07:00 -04:00
# If we detect arm as a platform for linux, but not mac, we'll make this -arm to download that version (Mostly used for raspi)
2025-04-03 19:07:38 -04:00
ifneq ($(filter aarch%,$(UNAME_M)),)
2025-03-25 09:07:00 -04:00
DETECTED_OS := linux-arm
endif
2025-02-11 19:44:41 +00:00
endif
2024-04-03 19:16:44 -04:00
BUILD_DIR := dkr_assets_tool_src/_build
2022-03-18 18:35:32 -04:00
ENUMS_HEADER := ../include/enums.h
# From: https://stackoverflow.com/questions/2483182/recursive-wildcards-in-gnu-make/18258352#18258352
rwildcard=$(foreach d,$(wildcard $(1:=/*)),$(call rwildcard,$d,$2) $(filter $(subst *,%,$2),$d))
2020-05-27 19:14:56 -05:00
2025-03-25 09:07:00 -04:00
RECOMP_DIR := ido-recomp/$(DETECTED_OS)
2020-05-27 19:14:56 -05:00
default: all
n64crc_SOURCES := n64crc.c
all: $(PROGRAMS) recomp flips
2020-05-27 19:14:56 -05:00
# make clean for flips doesn't work, so just manually delete it on a clean.
2020-05-27 19:14:56 -05:00
clean:
2025-03-25 09:07:00 -04:00
$(RM) -Rf $(PROGRAMS) $(BUILD_DIR)
$(RM) -rf $(RECOMP_DIR)
$(RM) -f Flips/flips
2020-05-27 19:14:56 -05:00
2022-03-26 17:20:19 -04:00
distclean: clean
2022-03-18 18:35:32 -04:00
n64crc: n64crc.c
$(CC) $(CFLAGS) -o $@ $< $(LDFLAGS)
2020-05-27 19:14:56 -05:00
2024-04-03 19:16:44 -04:00
dkr_assets_tool_CPP_FILES := $(call rwildcard,dkr_assets_tool_src,*.cpp)
2024-04-03 19:16:44 -04:00
dkr_assets_tool_C_FILES := $(call rwildcard,dkr_assets_tool_src,*.c)
2022-10-30 00:33:21 +00:00
2022-03-18 18:35:32 -04:00
dkr_assets_tool_OBJ_FILES := $(foreach file,$(dkr_assets_tool_C_FILES),$(BUILD_DIR)/$(file:.c=.o)) \
$(foreach file,$(dkr_assets_tool_CPP_FILES),$(BUILD_DIR)/$(file:.cpp=.o))
DUMMY != mkdir -p $(sort $(dir $(dkr_assets_tool_OBJ_FILES)))
$(BUILD_DIR)/%.o: %.c
2022-10-30 00:33:21 +00:00
$(CC) -c $^ -o $@ $(CFLAGS)
2022-03-18 18:35:32 -04:00
$(BUILD_DIR)/%.o: %.cpp
2022-10-30 00:33:21 +00:00
$(CXX) -c $< -o $@ $(CXXFLAGS)
2022-03-18 18:35:32 -04:00
dkr_assets_tool: $(dkr_assets_tool_OBJ_FILES)
2022-10-30 03:32:57 +00:00
$(CXX) $^ -o $@ $(CXXFLAGS) $(LDFLAGS) -lpthread
2020-05-27 19:14:56 -05:00
recomp:
2025-03-25 09:07:00 -04:00
@echo "Fetching Recomp..."
wget https://github.com/decompals/ido-static-recomp/releases/download/v1.2/ido-5.3-recomp-${DETECTED_OS}.tar.gz
mkdir -p $(RECOMP_DIR)
tar xf ido-5.3-recomp-${DETECTED_OS}.tar.gz -C $(RECOMP_DIR)
$(RM) ido-5.3-recomp-${DETECTED_OS}.tar.gz
#Builds the CLI only version of flips. It will complain about it being debug, but this makes it much faster compile.
flips:
@make -s -C Flips TARGET=cli
2022-03-26 17:20:19 -04:00
.PHONY: all clean distclean default
2022-03-18 18:35:32 -04:00