-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMakefile
58 lines (45 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
BIN=ngcp-mediator
VERSION := $(shell sed -n -e '1s/^.*(\(.*\)).*$$/\1/p' debian/changelog)
CC := gcc
CPPFLAGS += -DMEDIATOR_VERSION="\"$(VERSION)\""
GLIB_CFLAGS := $(shell pkg-config glib-2.0 --cflags)
# mariadb/mysql support
ifeq ($(shell pkg-config --exists libmariadb && echo yes),yes)
MYSQL_CFLAGS := $(shell pkg-config --cflags libmariadb) -DMARIADB=1
MYSQL_LDFLAGS := $(shell pkg-config --libs libmariadb)
else ifneq ($(shell which mariadb_config),)
MYSQL_CFLAGS := $(shell mariadb_config --cflags) -DMARIADB=1
MYSQL_LDFLAGS := $(shell mariadb_config --libs)
else ifneq ($(shell which mysql_config),)
MYSQL_CFLAGS := $(shell mysql_config --cflags)
MYSQL_LDFLAGS := $(shell mysql_config --libs)
else
MYSQL_CFLAGS := -I/usr/include/mysql
MYSQL_LDFLAGS := -lmysqlclient
endif
CFLAGS ?= -g -Wall -Wextra -Wstrict-prototypes -O2
CFLAGS += -D_GNU_SOURCE
CFLAGS += $(GLIB_CFLAGS)
CFLAGS += $(MYSQL_CFLAGS)
#CFLAGS += -DWITH_TIME_CALC
CFLAGS += $(shell pkg-config json-c --cflags)
CFLAGS += $(shell pkg-config hiredis --cflags)
CFLAGS += $(shell pkg-config libsystemd --cflags)
GLIB_LDFLAGS := $(shell pkg-config glib-2.0 --libs)
LDFLAGS += $(GLIB_LDFLAGS)
LDFLAGS += $(MYSQL_LDFLAGS)
LDFLAGS += $(shell pkg-config json-c --libs)
LDFLAGS += $(shell pkg-config hiredis --libs)
LDFLAGS += $(shell pkg-config libsystemd --libs)
CFILES := $(wildcard *.c)
OFILES := $(CFILES:.c=.o)
.PHONY: $(BIN) all clean
all: $(BIN)
$(BIN): $(OFILES)
$(CC) -o $@ $^ $(CFLAGS) $(LDFLAGS)
%.o: %.c
$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
clean:
rm -f *.o
rm -f core*
rm -f $(BIN)