Mineur_Tycoon/Makefile
2025-03-20 22:03:30 +01:00

70 lines
1.4 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))
all: | builddir map build builddir2
windef:
$(eval OUTPUT = "$(OUTNAME).exe")
$(eval BUILD_DIR = build-win)
$(eval LDFLAGS = $(LDFLAGS_WIN))
converter: map/converter.c
$(CC) map/converter.c -o map/converter $(CFLAGS)
map: converter
./map/converter
$(CC) -c map/maps_out.c -o build-tmp/maps_out.o $(CFLAGS)
$(eval OBJS += build-tmp/maps_out.o)
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 converter map
.PHONY: all test clean win windef builddir builddir2 testwin converter map