-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
87 lines (61 loc) · 2.03 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
80
81
82
83
84
85
86
87
PRODUCTION_PATH ?= /pub/sources/gotcha/production
DEBUG_FLAGS := -DDEBUG
PRODUCTION_FLAGS :=
BUILD_DIR := build
BINDIR := $(BUILD_DIR)/bin
LIBDIR := $(BUILD_DIR)/lib
NO_WARN_FLAGS := -Wno-pointer-sign
COMMON_CFLAGS := -Wall -g -DLOG_TO_SYSLOG -I$(shell pwd) $(NO_WARN_FLAGS)
APP_LDFLAGS := -L$(LIBDIR) -lgwebapp
GWEB_LIB := $(LIBDIR)/libgwebapp.so
GWEB_LIB_SRC := \
lib/uid.c \
lib/config.c
GWEB_LIB_CFLAGS := \
$(COMMON_CFLAGS) -I$(PRODUCTION_PATH)/include \
$(shell mysql_config --cflags)
GWEB_SERVER_BIN := $(BINDIR)/gwebserver
GWEB_SERVER_SRC := \
gweb_server.c \
mysqldb_handler.c \
json_parser.c \
avatardb.c
GWEB_SERVER_CFLAGS := \
$(COMMON_CFLAGS) -I$(PRODUCTION_PATH)/include \
$(shell mysql_config --cflags)
GWEB_SERVER_LDFLAGS := \
$(APP_LDFLAGS) \
-L$(PRODUCTION_PATH)/lib $(shell mysql_config --libs) \
-lmicrohttpd -ljson-c
MYSQL_SCHEMA_BIN := $(BINDIR)/mysql_schema
MYSQL_SCHEMA_SRC := \
setup/mysql_schema.c
MYSQL_SCHEMA_CFLAGS := \
$(COMMON_CFLAGS) -I$(PRODUCTION_PATH)/include \
$(shell mysql_config --cflags)
MYSQL_SCHEMA_LDFLAGS := \
$(APP_LDFLAGS) \
-L$(PRODUCTION_PATH)/lib $(shell mysql_config --libs) \
-ljson-c
ALL_BINS := $(GWEB_SERVER_BIN) $(MYSQL_SCHEMA_BIN)
ALL_LIBS := $(GWEB_LIB)
.PHONY: build_env_setup
debug: EXTRA_CFLAGS := $(DEBUG_FLAGS)
debug: all
production: EXTRA_CFLAGS := $(PRODUCTION_FLAGS)
production: all
all: build_env_setup $(ALL_LIBS) $(ALL_BINS)
build_env_setup:
mkdir -p $(BINDIR) $(LIBDIR)
$(GWEB_LIB): $(GWEB_LIB_SRC)
$(CC) -o $@ $^ -shared -fPIC $(EXTRA_CFLAGS) $(GWEB_LIB_CFLAGS)
$(GWEB_SERVER_BIN): $(GWEB_SERVER_SRC)
$(CC) -o $@ $^ $(EXTRA_CFLAGS) $(GWEB_SERVER_CFLAGS) $(GWEB_SERVER_LDFLAGS)
$(MYSQL_SCHEMA_BIN): $(MYSQL_SCHEMA_SRC)
$(CC) -o $@ $^ $(EXTRA_CFLAGS) $(MYSQL_SCHEMA_CFLAGS) $(MYSQL_SCHEMA_LDFLAGS)
clean:
rm -f *~ *.o $(ALL_BINS) $(ALL_LIBS) *.d
install:
mkdir -p $(PRODUCTION_PATH)/bin
cp -f $(ALL_BINS) $(PRODUCTION_PATH)/bin
cp -f $(ALL_LIBS) $(PRODUCTION_PATH)/lib