3dtoys/Makefile

59 lines
1.4 KiB
Makefile
Raw Normal View History

2024-08-18 08:33:01 +00:00
# Compiler and other things.
2024-08-13 01:28:24 +00:00
CC = gcc
2024-09-14 07:42:59 +00:00
CFLAGS = -std=c99 -Wall -Wextra
2024-08-13 01:28:24 +00:00
BUILDD = build
2024-08-18 08:33:01 +00:00
# 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
2024-08-15 07:58:22 +00:00
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
2024-08-13 01:28:24 +00:00
HALOOLIB = haloo3d/build/haloo3d_full.a
2024-09-12 07:13:52 +00:00
UNIGIPLAT = $(BUILDD)/unigi.platform.sdl2.o
2024-09-11 07:17:57 +00:00
UNIGILIB = $(BUILDD)/unigi.a
2024-08-13 01:28:24 +00:00
.PHONY: clean
2024-09-11 07:17:57 +00:00
.PHONY: libs
2024-08-13 01:28:24 +00:00
2024-09-11 07:17:57 +00:00
libs: $(UNIGILIB) $(HALOOLIB)
@echo "Built libs!"
2024-08-13 01:28:24 +00:00
$(HALOOLIB):
2024-08-13 02:03:55 +00:00
cd haloo3d && $(MAKE) full
2024-08-13 01:28:24 +00:00
2024-09-12 07:13:52 +00:00
$(UNIGIPLAT): unigi.platform.sdl2/main.c
2024-09-11 07:17:57 +00:00
mkdir -p $(BUILDD)
$(CC) $(CFLAGS) -I. -c $< -o $@
2024-09-11 05:15:19 +00:00
2024-09-11 07:17:57 +00:00
$(UNIGILIB): $(UNIGIPLAT)
ar -vr $@ $^
2024-09-11 05:15:19 +00:00
2024-08-13 01:28:24 +00:00
# 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
2024-09-11 07:17:57 +00:00
%.exe: %.o $(UNIGILIB) $(HALOOLIB)
$(CC) $(CFLAGS) $^ -o $@ -lm -lSDL2
2024-08-13 01:28:24 +00:00
# Rule to clean the build files
clean:
rm -rf $(BUILDD)
rm -f *.o *.elf
2024-08-13 01:28:24 +00:00
find . -name "*.exe" -type f -delete
2024-08-13 02:17:14 +00:00
cd haloo3d && $(MAKE) clean
2024-08-13 01:28:24 +00:00