3dtoys/Makefile
2024-09-11 03:17:57 -04:00

58 lines
1.4 KiB
Makefile

# Compiler and other things.
CC = gcc
CFLAGS = -std=c99 -Wall -Wextra
BUILDD = build
# NOTE: there is a gcc bug (?) which is making some of the code produce spurrious warnings
# for "stringop-overflow" even though no string operations are taking place
# ifeq ($(CC),gcc)
# CFLAGS += -Wno-error=stringop-overflow
# endif
ifdef MARCH # Allows you to define the architecture (usually not required)
CFLAGS += -march=$(MARCH)
endif
ifndef FORCE # Force the build to move past warnings (disable warnings as errors)
CFLAGS += -Werror
endif
ifdef DEBUG # Build in debug mode, usable in gdb/valgrind/etc
CFLAGS += -O2 -g
else
CFLAGS += -O3 -flto
endif
HALOOLIB = haloo3d/build/haloo3d_full.a
UNIGIPLAT = $(BUILDD)/unigi.platform.sdl1.o
UNIGILIB = $(BUILDD)/unigi.a
.PHONY: clean
.PHONY: libs
libs: $(UNIGILIB) $(HALOOLIB)
@echo "Built libs!"
$(HALOOLIB):
cd haloo3d && $(MAKE) full
$(UNIGIPLAT): unigi.platform.sdl1/main.c
mkdir -p $(BUILDD)
$(CC) $(CFLAGS) -I. -c $< -o $@
$(UNIGILIB): $(UNIGIPLAT)
ar -vr $@ $^
# Rule to build .o files in main folder
$(BUILDD)/%.o: %.c %.h
mkdir -p $(BUILDD)
$(CC) $(CFLAGS) -c $< -o $@
# Rule to build any sample. We ALWAYS need math so... link it
%.exe: %.o $(UNIGILIB) $(HALOOLIB)
$(CC) $(CFLAGS) $^ -o $@ -lm -lSDL
# Rule to clean the build files
clean:
rm -rf $(BUILDD)
find . -name "*.exe" -type f -delete
cd haloo3d && $(MAKE) clean