-
Notifications
You must be signed in to change notification settings - Fork 53
/
Makefile
69 lines (55 loc) · 1.78 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
.PHONY: all clean
PLATFORM ?= $(shell uname -s)
BUILD_PATH ?= build
OBJ_PATH ?= obj
# platform specific settings:
ifeq ($(PLATFORM), Linux)
LDFLAGS = -lm -ldl
RANLIB = ar -crs
else ifeq ($(PLATFORM), Darwin)
LDFLAGS =
RANLIB = libtool -static -o
else ifneq ($(findstring MINGW64_NT,$(PLATFORM)),)
LDFLAGS = -lm
RANLIB = ar -crs
endif
# identical for all platforms:
UMKA_LIB_STATIC = $(BUILD_PATH)/libumka.a
UMKA_LIB_DYNAMIC = $(BUILD_PATH)/libumka.so
UMKA_EXE = $(BUILD_PATH)/umka
CFLAGS = -s -fPIC -O3 -Wall -Wno-format-security -malign-double -fno-strict-aliasing -DUMKA_EXT_LIBS
STATIC_CFLAGS = $(CFLAGS) -DUMKA_STATIC
DYNAMIC_CFLAGS = $(CFLAGS) -DUMKA_BUILD -shared -fvisibility=hidden
SRCS = $(filter-out src/umka.c,$(wildcard src/*.c))
OBJS_STATIC = $(sort $(SRCS:src/%.c=$(OBJ_PATH)/%_static.o))
OBJS_DYNAMIC = $(sort $(SRCS:src/%.c=$(OBJ_PATH)/%_dynamic.o))
APIS = src/umka_api.h
OBJS_EXE = $(OBJ_PATH)/umka_static.o
all: $(UMKA_EXE) $(UMKA_LIB_STATIC) $(UMKA_LIB_DYNAMIC)
static: $(UMKA_LIB_STATIC)
dynamic: $(UMKA_LIB_DYNAMIC)
exe: $(UMKA_EXE)
clean:
$(RM) $(BUILD_PATH) $(OBJ_PATH) -r
$(UMKA_LIB_STATIC): $(OBJS_STATIC)
@echo AR $@
@mkdir -p -- $(BUILD_PATH)/include/
@$(RANLIB) $(UMKA_LIB_STATIC) $^
@cp $(APIS) $(BUILD_PATH)/include/
$(UMKA_LIB_DYNAMIC): $(OBJS_DYNAMIC)
@echo LD $@
@mkdir -p -- $(BUILD_PATH)/include/
@$(CC) $(DYNAMIC_CFLAGS) -o $(UMKA_LIB_DYNAMIC) $^ $(LDFLAGS)
@cp $(APIS) $(BUILD_PATH)/include/
$(UMKA_EXE): $(OBJS_EXE) $(UMKA_LIB_STATIC)
@echo LD $@
@mkdir -p -- $(dir $@)
@$(CC) $(STATIC_CFLAGS) -o $(UMKA_EXE) $^ $(LDFLAGS)
$(OBJ_PATH)/%_static.o: src/%.c
@echo CC $@
@mkdir -p -- $(dir $@)
@$(CC) $(STATIC_CFLAGS) -o $@ -c $^
$(OBJ_PATH)/%_dynamic.o: src/%.c
@echo CC $@
@mkdir -p -- $(dir $@)
@$(CC) $(DYNAMIC_CFLAGS) -o $@ -c $^