-
Notifications
You must be signed in to change notification settings - Fork 21
/
GNUmakefile
41 lines (31 loc) · 951 Bytes
/
GNUmakefile
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
LUA_IMPL ?= lua5.1
DESTDIR ?= /
PKG_CONFIG ?= pkg-config
CC ?= gcc
CFLAGS ?= -O2 -fPIC -DPIC $(shell $(PKG_CONFIG) $(LUA_IMPL) --cflags)
INSTALL ?= install
LUA_CMOD_DIR ?= $(shell $(PKG_CONFIG) $(LUA_IMPL) --variable INSTALL_CMOD)
CF += $(CFLAGS) -Werror -pedantic -std=c99 -Isrc
LF += $(LDFLAGS) -shared -lGeoIP
all: prepare geoip.so geoip/country.so geoip/city.so
prepare:
@mkdir -p geoip
geoip.so: src/database.o src/lua-geoip.o
geoip/country.so: src/database.o src/country.o
geoip/city.so: src/database.o src/city.o
.c.o:
$(CC) $(CF) -c $^ -o $@
%.so:
$(CC) $(LF) $^ -o $@
clean:
@rm -f geoip.so geoip/country.so geoip/city.so
@rm -f src/*.o
@rm -rf geoip
install: all
$(INSTALL) -d $(DESTDIR)/$(LUA_CMOD_DIR)/geoip
$(INSTALL) geoip/* $(DESTDIR)/$(LUA_CMOD_DIR)/geoip
$(INSTALL) geoip.so $(DESTDIR)/$(LUA_CMOD_DIR)
uninstall:
@rm -f $(LUA_CMOD_DIR)/geoip.so
@rm -rf $(LUA_CMOD_DIR)/geoip
.SUFFIXES: .c .o .so