-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
79 lines (60 loc) · 1.7 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
_CFLAGS:=$(CFLAGS)
CFLAGS:=$(_CFLAGS)
_LDFLAGS:=$(LDFLAGS)
LDFLAGS:=$(_LDFLAGS)
ARFLAGS?=rcs
PATHSEP?=/
BUILDROOT?=build
BUILDDIR?=$(BUILDROOT)$(PATHSEP)$(CC)
BUILDPATH?=$(BUILDDIR)$(PATHSEP)
ifndef PREFIX
INSTALL_ROOT=$(BUILDPATH)
else
INSTALL_ROOT=$(PREFIX)$(PATHSEP)
ifeq ($(INSTALL_ROOT),/)
INSTALL_ROOT=$(BUILDPATH)
endif
endif
ifdef DEBUG
CFLAGS+=-ggdb
ifeq ($(DEBUG),)
CFLAGS+=-Ddebug=1
else
CFLAGS+=-Ddebug=$(DEBUG)
endif
endif
ifeq ($(M32),1)
CFLAGS+=-m32
BIT_SUFFIX+=32
endif
override CFLAGS+=-std=c11 -Wpedantic -pedantic-errors -Wall -Wextra
#-ggdb
#-pg for profiling
override LDFLAGS+=-L$(BUILDDIR) -L/c/dev/lib$(BIT_SUFFIX)
override CFLAGS+=-I./include -I/c/dev/include
NAME=renderer
LIBNAME=lib$(NAME).a
LIB=$(BUILDPATH)$(LIBNAME)
OBJS=$(BUILDPATH)$(NAME).o $(BUILDPATH)camera.o
TESTBIN=$(BUILDPATH)test_$(NAME).exe
override LDFLAGS+=-l$(NAME) -lscene -lr_font -lmesh -lshape -ltexture -lnoise -lfractals -lgeometry -lcrgb_array -ldl_list -lfarray -larray -lcolor -lstatistics -lutilsmath -lmat -lvec
all: mkbuilddir $(LIB)
$(LIB): $(OBJS)
$(AR) $(ARFLAGS) $@ $^
$(OBJS): include/$(NAME).h include/camera.h
$(CC) $(CFLAGS) -c src/$(@F:.o=.c) -o $@
$(TESTBIN): $(LIB) test/font_provider_default.h
$(CC) $(CFLAGS) test/$(@F:.exe=.c) test/font_provider_default.c -o $@ $(LDFLAGS)
.PHONY: clean mkbuilddir test
test: mkbuilddir $(TESTBIN)
./$(TESTBIN)
mkbuilddir:
mkdir -p $(BUILDDIR)
clean:
-rm -dr $(BUILDROOT)
install:
mkdir -p $(INSTALL_ROOT)include
mkdir -p $(INSTALL_ROOT)lib$(BIT_SUFFIX)
cp ./include/$(NAME).h $(INSTALL_ROOT)include$(PATHSEP)$(NAME).h
cp ./include/camera.h $(INSTALL_ROOT)include$(PATHSEP)camera.h
cp $(LIB) $(INSTALL_ROOT)lib$(BIT_SUFFIX)$(PATHSEP)$(LIBNAME)