-
Notifications
You must be signed in to change notification settings - Fork 21
/
BSDmakefile
43 lines (32 loc) · 946 Bytes
/
BSDmakefile
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
LUA_IMPL ?= lua5.1
DESTDIR ?= /
CFLAGS ?= -O2 -fPIC -DPIC
PKG_CONFIG ?= pkg-config
CC ?= gcc
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
$(CC) $(LF) $^ -o $@
geoip/country.so: src/database.o src/country.o
$(CC) $(LF) $^ -o $@
geoip/city.so: src/database.o src/city.o
$(CC) $(LF) $^ -o $@
.c.o:
$(CC) $(CF) -c $^ -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