Mineur_Tycoon/Makefile
2025-04-05 12:25:04 +02:00

72 lines
1.5 KiB
Makefile

# /!\ Warning /!\
# Parallel build doesn't work with w64devkit
OUTNAME = mtycoon
CFLAGS = -O0 -Wall -Wextra -g -I ./raylib/include -pipe
CC = gcc
LDFLAGS_UNIX = -L./raylib/lib -lraylib -lm
LDFLAGS_WIN = -static -lraylib -lgdi32 -lwinmm -lm
# ===== End of what should be edited =====
OUTPUT = "${OUTNAME}.amd64"
LDFLAGS = $(LDFLAGS_UNIX)
BUILD_DIR = build
SRC_DIR = src
OBJS = $(patsubst $(SRC_DIR)/%.c,build-tmp/%.o,$(wildcard $(SRC_DIR)/*.c))
OBJS += build-tmp/maps_out.o
all: | builddir map build builddir2
windef:
$(eval OUTPUT = "$(OUTNAME).exe")
$(eval BUILD_DIR = build-win)
$(eval LDFLAGS = $(LDFLAGS_WIN))
map/converter: map/converter.c
$(CC) map/converter.c -o map/converter $(CFLAGS)
map/maps_out.c: map/converter $(wildcard map/*.tmx)
./map/converter
$(CC) -c map/maps_out.c -o build-tmp/maps_out.o $(CFLAGS)
map: map/maps_out.c
builddir:
- mkdir $(BUILD_DIR)
mkdir build-tmp
- mv $(wildcard $(BUILD_DIR)/*.o) build-tmp/
build-tmp/%.o : $(SRC_DIR)/%.c
$(CC) -c $< -o $@ $(CFLAGS)
build: $(OBJS)
$(CC) $(CFLAGS) -o $(OUTPUT) $(OBJS) $(LDFLAGS)
builddir2:
mv $(wildcard build-tmp/*.o) $(BUILD_DIR)
rm -rf build-tmp
win: | windef all
testwin: win
./$(OUTPUT)
test: all
./${OUTPUT}
clean:
- rm -rf ${BUILD_DIR}
- rm -rf build-win
- rm -rf build-tmp
- rm "$(OUTNAME).amd64" "$(OUTNAME).exe"
- rm map/maps_out.c map/converter map/converter.exe
.NOTPARALLEL: builddir builddir2 map
.PHONY: all test clean win windef builddir builddir2 testwin map