-
Notifications
You must be signed in to change notification settings - Fork 39
/
Makefile
73 lines (59 loc) · 1.44 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
CC?=gcc
CXX?=g++
STDC=-std=gnu11
LEVEL?=-g
ifeq ($(OS),Windows_NT)
CFLAGS += -DWIN32
LDFLAGS += -lws2_32 -lwinmm # only for enet example
else
OSDEF := $(shell uname -s)
ifeq ($(OSDEF),Linux)
LDFLAGS += -pthread -lm
endif
ifeq ($(OSDEF),OpenBSD)
STDC=-std=c11
CC=clang
CXX=clang++
LDFLAGS += -pthread -lm
endif
ifeq ($(OSDEF),FreeBSD)
STDC=-std=c11
CC=clang
CXX=clang++
LDFLAGS+=-pthread -lm
endif
endif
WARNS = -Wall -Wextra -Werror -Wno-missing-field-initializers -Wno-unused-value -Wno-unused-function -Wno-missing-braces
CFLAGS += $(LEVEL) $(STDC) -Icode $(WARNS)
CXXFLAGS += $(LEVEL) -std=c++11 -Icode $(WARNS)
APPS += $(patsubst %.c,%,$(wildcard code/apps/*.c))
APPS += $(patsubst %.cc,%,$(wildcard code/apps/*.cc))
BUILD_FILES = $(wildcard build/*)
.PHONY: all clean apps test web
all: clean apps test
test: code/tests/unit
@echo '> Building unit tests'
build/unit
apps: $(APPS)
@echo '> Building apps'
app: code/apps/$(NAME)
@echo '> Building app $(NAME)'
web:
emcc $(LEVEL) -s WASM=1 -s EXTRA_EXPORTED_RUNTIME_METHODS='["cwrap"]' \
-DLIBRG_EMSCRIPTEN=1 -I code/ code/apps/library.c -o build/librg.js
clean:
ifneq ($(BUILD_FILES),)
@echo '> Cleaning up files'
@rm -r $(BUILD_FILES)
endif
% : %.c
@mkdir -p build
@echo '> Building $(@F)'
$(CC) $(CFLAGS) $^ $(LDFLAGS) -o build/$(@F)
% : %.cc
@mkdir -p build
@echo '> Building $(@F)'
$(CXX) $(CXXFLAGS) $^ $(LDFLAGS) -o build/$(@F)
.SILENT:
embed:
./misc/embed.sh