-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
67 lines (50 loc) · 1.54 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
ifeq ($(OS),Windows_NT)
LIBEXT=dll
PROGEXT=.exe
SYSFLAGS=-lgdi32
BACKEND=pb_winapi
else
UNAME:=$(shell uname -s)
PROGEXT=
ifeq ($(UNAME),Darwin)
LIBEXT=dylib
SYSFLAGS=-framework Cocoa
BACKEND=pb_cocoa
else ifeq ($(UNAME),Linux)
LIBEXT=so
SYSFLAGS=-lX11 -lm
BACKEND=pb_x11
else
$(error OS not supported by this Makefile)
endif
endif
.PHONY: default all library web
default: all
BUILD=build
CFLAGS = -Isrc -Ideps
LINK = src/rng.c -L$(BUILD) -lpb
$(BUILD)/:
mkdir -p $(BUILD)
libpb: $(BUILD)/
$(CC) -shared -fpic $(CFLAGS) $(SYSFLAGS) src/$(BACKEND).c -o $(BUILD)/libpb.$(LIBEXT)
fwp: libpb
$(CC) $(CFLAGS) src/fwp.c $(LINK) -o $(BUILD)/fwp$(PROGEXT)
test-lib: libpb
$(CC) $(CFLAGS) templates/pb_boilerplate.c $(LINK) -o $(BUILD)/test_lib$(PROGEXT)
test-scene: libpb
$(CC) $(CFLAGS) -shared -fpic templates/fwp_boilerplate.c $(LINK) -o $(BUILD)/test_scene.$(LIBEXT)
rebuild-test:
$(CC) $(CFLAGS) -shared -fpic examples/basic.c $(LINK) -o $(BUILD)/rebuild_test.$(LIBEXT)
test-web: libpb
emcc $(CFLAGS) src/pb_emscripten.c templates/pb_boilerplate.c -o $(BUILD)/fwp_web.html
tests: test-lib test-scene test-web
SRC := examples
BIN := build
TARGETS := $(foreach file,$(foreach src,$(wildcard $(SRC)/*.c),$(notdir $(src))),$(patsubst %.c,$(BIN)/fwp_example_%.$(LIBEXT),$(file)))
$(BIN)/fwp_example_%.$(LIBEXT): $(SRC)/%.c | $(BIN)
$(CC) -shared -fpic $(CFLAGS) $(LINK) -o $@ $^
examples: $(TARGETS)
all: fwp tests examples
clean:
$(RM) -rf $(BUILD)
.PHONY: default all clean libpb fwp test-lib test-scene test-web tests examples