-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
65 lines (54 loc) · 1.98 KB
/
Makefile
File metadata and controls
65 lines (54 loc) · 1.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# --------------------------------------------------
# haloopdy 2024
# --------------------------------------------------
# - This makefile is designed to work on linux
# - By default it builds a static library haloo3d.a with everything you need
# - You can build individual examples with this makefile too
# - The library doesn't have to be built in the way specified here
# --------------------------------------------------
# Compiler and other things
LIBD = lib
BUILDD = build
CC = gcc
DEFINES =
CFLAGS = $(DEFINES) -std=c99 -Wall -Wextra # -DH3DEBUG_SKIPWHOLETRI
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
# Define the object files for the static library
FULLOBJS = $(BUILDD)/haloo3d_unigi.o $(BUILDD)/haloo3d_3d.o \
$(BUILDD)/haloo3d_ex.o
FULLOUT = $(BUILDD)/haloo3d.a
CORE = haloo3d.h
.PHONY: clean
# Build the main lib. Since this is first, this is what the makefile will
# do by default. We create a static archive with all deps added
$(FULLOUT): $(FULLOBJS) $(CORE)
ar -cvr $@ $(FULLOBJS)
# Rule to build lib .o files
$(BUILDD)/$(LIBD)/%.o: $(LIBD)/%.c $(LIBD)/%.h
mkdir -p $(BUILDD)/$(LIBD)
$(CC) $(CFLAGS) -c $< -o $@
# Rule to build .o files in main folder
$(BUILDD)/%.o: %.c %.h $(CORE)
mkdir -p $(BUILDD)
$(CC) $(CFLAGS) -c $< -o $@
# Rule to build any example file. We ALWAYS need math so... link it
examples/%.exe: examples/%.o $(FULLOUT)
$(CC) $(CFLAGS) $< $(FULLOUT) -o $@ -lm
# Rule to build any example file. We ALWAYS need math so... link it
tests/%.exe: tests/%.o $(FULLOUT)
$(CC) $(CFLAGS) $< $(FULLOUT) -o $@ -lm
# Rule to clean the build files
clean:
rm -rf $(BUILDD)
find tests/ -name "*.exe" -type f -delete
# test -d examples/ && find examples/ -name "*.exe" -type f -delete