forked from spc476/SPCDNS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
110 lines (84 loc) · 3.04 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#######################################################################
#
# Copyright 2010 by Sean Conner. All Rights Reserved.
#
# This library is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 3 of the License, or (at your
# option) any later version.
#
# This library is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
# License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this library; if not, see <http://www.gnu.org/licenses/>.
#
######################################################################
UNAME := $(shell uname)
VERSION := $(shell git describe --tag)
ifeq ($(VERSION),)
VERSION=v2.0.5
endif
# ===================================================
CC = gcc -std=c99 -Wall -Wextra -pedantic -Wwrite-strings
CFLAGS = -g
LDFLAGS = -g
LDLIBS = -lm
ifeq ($(UNAME),Linux)
CSHARE = -fPIC
LDSHARE = -g -shared
endif
ifeq ($(UNAME),Darwin)
CSHARE = -fPIC
LDSHARE = -g -bundle -undefined dynamic_lookup -all_load
endif
#=================================================
INSTALL = /usr/bin/install
INSTALL_PROGRAM = $(INSTALL)
INSTALL_DATA = $(INSTALL) -m 644
prefix = /usr/local
libdir = $(prefix)/lib
LUA ?= lua
LUA_VERSION := $(shell $(LUA) -e "print(_VERSION:match '^Lua (.*)')")
LIBDIR ?= $(libdir)/lua/$(LUA_VERSION)
ifneq ($(LUA_INCDIR),)
src/dns.so : override CFLAGS += -I$(LUA_INCDIR)
endif
#=================================================
%.a :
$(AR) $(ARFLAGS) $@ $?
%.oo : %.c
$(CC) $(CFLAGS) -DVERSION='"$(VERSION)"' $(CSHARE) -c -o $@ $<
%.so :
$(CC) $(LDSHARE) -o $@ $^
#=================================================
.PHONY: all install-lua uninstall-lua clean dist depend
all : src/dotest src/libspcdns.a src/dns.so
src/dotest : src/dotest.o src/libspcdns.a
src/libspcdns.a : src/codec.o src/mappings.o src/netsimple.o src/output.o
src/dns.so : src/luadns.oo src/codec.oo src/mappings.oo src/netsimple.oo
install-lua : src/dns.so
$(INSTALL) -d $(DESTDIR)$(LIBDIR)/org/conman
$(INSTALL_PROGRAM) src/dns.so $(DESTDIR)$(LIBDIR)/org/conman
uninstall-lua :
$(RM) $(DESTDIR)$(LIBDIR)/org/conman/dns.so
clean:
$(RM) $(shell find . -name '*.o')
$(RM) $(shell find . -name '*.so')
$(RM) $(shell find . -name '*.oo')
$(RM) $(shell find . -name '*.a')
$(RM) $(shell find . -name '*~')
$(RM) Makefile.bak src/dotest
dist:
git archive -o /tmp/spcdns-$(VERSION).tar.gz --prefix spcdns/ $(VERSION)
depend:
makedepend -Y -- $(CFLAGS) -- src/*.c 2>/dev/null
# DO NOT DELETE
src/codec.o: src/dns.h
src/dotest.o: src/dns.h src/mappings.h src/netsimple.h src/output.h
src/luadns.o: src/dns.h src/mappings.h src/netsimple.h
src/mappings.o: src/dns.h src/mappings.h
src/netsimple.o: src/dns.h src/netsimple.h
src/output.o: src/dns.h src/mappings.h src/output.h