update makefile to add asset copying

This commit is contained in:
2025-01-25 15:47:25 +01:00
parent 15d314127b
commit 595c76a3e6

View File

@@ -13,10 +13,14 @@ DIR_OBJ := obj
DIR := $(DIR_BIN)/$(ARCH) $(DIR_OBJ)/$(ARCH) DIR := $(DIR_BIN)/$(ARCH) $(DIR_OBJ)/$(ARCH)
SRC := $(wildcard src/*.c) $(wildcard src/**/*.c) $(wildcard src/**/**/*.c) $(wildcard src/**/**/**/*.c) $(wildcard src/**/**/**/**/*.c) SRC := $(wildcard src/*.c) $(wildcard src/**/*.c) $(wildcard src/**/**/*.c) $(wildcard src/**/**/**/*.c) $(wildcard src/**/**/**/**/*.c)
SRC_ASSETS := $(wildcard assets/*)
OBJ := $(patsubst src/%,$(DIR_OBJ)/$(ARCH)/%,$(SRC:.c=.o)) OBJ := $(patsubst src/%,$(DIR_OBJ)/$(ARCH)/%,$(SRC:.c=.o))
DEP := $(OBJ:.o=.d) DEP := $(OBJ:.o=.d)
ASSETS := $(patsubst assets/%,$(DIR_BIN)/$(ARCH)/%,$(SRC_ASSETS))
TARGET := $(DIR_BIN)/$(ARCH)/$(NAME)$(EXT) TARGET := $(DIR_BIN)/$(ARCH)/$(NAME)$(EXT)
# sets the variables for the different targets # sets the variables for the different targets
linux-x86_64: linux-x86_64:
$(MAKE) build ARCH=linux-x86_64 CFLAGS="$(CFLAGS) -target x86_64-pc-linux-gnu" $(MAKE) build ARCH=linux-x86_64 CFLAGS="$(CFLAGS) -target x86_64-pc-linux-gnu"
@@ -26,7 +30,7 @@ web:
$(MAKE) build ARCH=web CC=emcc EXT=".html" $(MAKE) build ARCH=web CC=emcc EXT=".html"
all: linux-x86_64 win-x86_64 web all: linux-x86_64 win-x86_64 web
build: $(DIR) $(TARGET) compile_commands.json build: $(DIR) $(TARGET) $(ASSETS) compile_commands.json
clean: clean:
rm -rf $(DIR_BIN) $(DIR_OBJ) rm -rf $(DIR_BIN) $(DIR_OBJ)
@@ -39,6 +43,11 @@ $(DIR_OBJ)/$(ARCH)/%.o: src/%.c
@mkdir -p $(dir $@) @mkdir -p $(dir $@)
$(CC) -o $@ -MD -MP -c $< $(CFLAGS) -std=$(STD) -x $(LANG) -Wno-unused-command-line-argument $(CC) -o $@ -MD -MP -c $< $(CFLAGS) -std=$(STD) -x $(LANG) -Wno-unused-command-line-argument
# copy the assets
$(DIR_BIN)/$(ARCH)/%: assets/%
@mkdir -p $(dir $@)
cp $< $@
$(DIR): $(DIR):
@mkdir -p $@ @mkdir -p $@