-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
58 lines (45 loc) · 1.47 KB
/
Makefile
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
ifndef SRCROOT
SRCROOT := $(shell pwd)
endif
ifndef OBJROOT
OBJROOT := $(SRCROOT)/obj
endif
CC := clang
LD := clang
# Default compile options
ifndef CFLAGS
CFLAGS := -arch x86_64 -O3 -fstrict-aliasing
endif
# Compiler
ExtraFlags := \
-pedantic -Wall -Wextra \
-Wno-unused-parameter -Wno-missing-field-initializers
CommonFlags := $(CFLAGS) $(OPTFLAGS) $(ExtraFlags)
CompileOnlyFlags := -std=c99 -I$(SRCROOT)/src
CompileFlags := $(CompileOnlyFlags) $(CommonFlags)
LinkFlags := $(CommonFlags)
LinkFlags.glutTest := $(LinkFlags) \
-framework OpenGL -framework GLUT
LinkFlags.perfTest := $(LinkFlags)
# Source files
Headers := $(wildcard $(SRCROOT)/*.h)
Sources.Lib := CCGSubSurf.c
Sources.Tests := $(Sources.Lib) QMesh.c
Sources.glutTest := $(Sources.Tests) glutTest.c
Objects.glutTest := $(Sources.glutTest:%.c=$(OBJROOT)/%.o)
Sources.perfTest := $(Sources.Tests) perfTest.c
Objects.perfTest := $(Sources.perfTest:%.c=$(OBJROOT)/%.o)
all: $(OBJROOT)/glutTest $(OBJROOT)/perfTest
glutTest: $(OBJROOT)/glutTest
perfTest: $(OBJROOT)/perfTest
$(OBJROOT)/glutTest: $(Objects.glutTest)
$(LD) -o $@ $(Objects.glutTest) $(LinkFlags.glutTest)
$(OBJROOT)/perfTest: $(Objects.perfTest)
$(LD) -o $@ $(Objects.perfTest) $(LinkFlags.perfTest)
$(OBJROOT)/%.o: $(SRCROOT)/tests/%.c $(Headers) Makefile $(OBJROOT)/.dir
$(CC) -c -o $@ $< $(CompileFlags)
$(OBJROOT)/%.o: $(SRCROOT)/src/%.c $(Headers) Makefile $(OBJROOT)/.dir
$(CC) -c -o $@ $< $(CompileFlags)
%/.dir:
mkdir -p $* > /dev/null
echo > $@