forked from marcobambini/gravity
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
73 lines (63 loc) · 1.56 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
COMPILER_DIR = src/compiler/
RUNTIME_DIR = src/runtime/
SHARED_DIR = src/shared/
UTILS_DIR = src/utils/
OPT_DIR = src/optionals/
GRAVITY_SRC = src/cli/gravity.c
EXAMPLE_SRC = examples/example.c
CC ?= gcc
SRC = $(wildcard $(COMPILER_DIR)*.c) \
$(wildcard $(RUNTIME_DIR)*.c) \
$(wildcard $(SHARED_DIR)*.c) \
$(wildcard $(UTILS_DIR)*.c) \
$(wildcard $(OPT_DIR)*.c)
INCLUDE = -I$(COMPILER_DIR) -I$(RUNTIME_DIR) -I$(SHARED_DIR) -I$(UTILS_DIR) -I$(OPT_DIR)
CFLAGS = $(INCLUDE) -std=gnu99 -fgnu89-inline -fPIC -DBUILD_GRAVITY_API
OBJ = $(SRC:.c=.o)
ifeq ($(OS),Windows_NT)
# Windows
LIBTARGET = gravity.dll
LDFLAGS = -lm -lShlwapi
else
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Darwin)
# MacOS
LIBTARGET = libgravity.dylib
LDFLAGS = -lm
else ifeq ($(UNAME_S),OpenBSD)
# OpenBSD
LIBTARGET = libgravity.so
LDFLAGS = -lm
else ifeq ($(UNAME_S),FreeBSD)
# FreeBSD
LIBTARGET = libgravity.so
LDFLAGS = -lm
else ifeq ($(UNAME_S),NetBSD)
# NetBSD
LIBTARGET = libgravity.so
LDFLAGS = -lm
else ifeq ($(UNAME_S),DragonFly)
# DragonFly
LIBTARGET = libgravity.so
LDFLAGS = -lm
else
# Linux
LIBTARGET = libgravity.so
LDFLAGS = -lm -lrt
endif
endif
ifeq ($(mode),debug)
CFLAGS += -g -O0 -DDEBUG
else
CFLAGS += -O2
endif
all: gravity
gravity: $(OBJ) $(GRAVITY_SRC)
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
example: $(OBJ) $(EXAMPLE_SRC)
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
lib: gravity
$(CC) -shared -o $(LIBTARGET) $(OBJ) $(LDFLAGS)
clean:
rm -f $(OBJ) gravity example libgravity.so gravity.dll
.PHONY: all clean gravity example