-
Notifications
You must be signed in to change notification settings - Fork 123
Expand file tree
/
Copy pathMakefile
More file actions
189 lines (159 loc) · 6.51 KB
/
Makefile
File metadata and controls
189 lines (159 loc) · 6.51 KB
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
# Copyright (C) 2007 Manu Garg.
# Author: Manu Garg <manugarg@gmail.com>
#
# Makefile for pacparser. Please read README file included with this package
# for more information about pacparser.
#
# pacparser 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.
# pacparser 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, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
# This file is not part of the source code repository. It's generated by the
# packaging script.
-include version.mk
BASH ?= bash
PREFIX ?= /usr
VERSION ?= $(shell git describe --always --tags --candidate=100)
OS_ARCH := $(subst /,_,$(shell uname -s | sed /\ /s//_/))
LIBRARY_NAME = libpacparser
LIB_VER = 1
PYTHON ?= python
LDFLAGS =
CFLAGS = -g -DXP_UNIX -Wall -DVERSION=$(VERSION)
# NOTICE(slattarini): in an ideal world, we would autonconfiscate the
# pacparser build system and turn these definition into automatically
# populated ones (via ./configure); however, given the current status of
# the build system, compounded by the fact that we use a bundled package
# (SpiderMonkey) which is not autoconfiscated and mostly incompatible with
# several autotools conventions, we take the easier albeit suboptimal
# solution.
ENABLE_C_ARES ?= auto
ifeq "$(ENABLE_C_ARES)" "auto"
ENABLE_C_ARES := $(shell pkg-config --exists libcares && echo yes || echo no)
$(info ENABLE_C_ARES was undefined; autodetected to "$(ENABLE_C_ARES)")
ifeq "$(ENABLE_C_ARES)" "yes"
C_ARES_CFLAGS := $(shell pkg-config --cflags libcares)
C_ARES_LDFLAGS := $(shell pkg-config --libs libcares)
C_ARES_LDFLAGS += -Wl,-rpath
C_ARES_LDFLAGS += -Wl,$(shell pkg-config --variable=libdir libcares)
endif
endif
ifeq "$(ENABLE_C_ARES)" "yes"
C_ARES_CFLAGS += -DHAVE_C_ARES
else
$(warning c-ares (http://c-ares.haxx.se) library not found or disabled)
$(warning Some DNS-related features will be unavailable)
endif
CFLAGS += $(C_ARES_CFLAGS)
LDFLAGS += $(C_ARES_LDFLAGS)
# This Makefile should at least work on Linux and Mac OS X. It should work on
# most other types of Unix systems too, but I have not put any conscious effort
# for that.
#
# Set variables according to Linux.
SO_SUFFIX = so
LIBRARY = $(LIBRARY_NAME).$(SO_SUFFIX).$(LIB_VER)
MKSHLIB = $(CC) -shared
LIB_OPTS = -Wl,-soname=$(LIBRARY) -Wl,-exclude-libs=libjs.a
SHFLAGS = -fPIC
SMCFLAGS = -DHAVE_VA_COPY -DVA_COPY=__va_copy
ifeq ($(OS_ARCH),Darwin)
MAC_MINOR_VERSION := $(shell sw_vers -productVersion | cut -d. -f2)
MAC_GT_5 := $(shell [ $(MAC_MINOR_VERSION) -le 5 ] && echo false)
SO_SUFFIX = dylib
LIBRARY = $(LIBRARY_NAME).$(LIB_VER).$(SO_SUFFIX)
MKSHLIB = $(CC) -dynamiclib -framework System
LIB_OPTS = -install_name $(PREFIX)/lib/$(notdir $@)
SHFLAGS =
ifeq ($(MAC_GT_5),false)
SMCFLAGS =
endif
endif
# Spidermonkey library.
CFLAGS += -Ispidermonkey/js/src
LIBRARY_LINK = $(LIBRARY_NAME).$(SO_SUFFIX)
PREFIX := $(DESTDIR)$(PREFIX)
LIB_PREFIX = $(PREFIX)/lib
INC_PREFIX = $(PREFIX)/include
BIN_PREFIX = $(PREFIX)/bin
MAN_PREFIX = $(PREFIX)/share/man
DOC_PREFIX = $(PREFIX)/share/doc
.PHONY: all docs pymod install-pymod install test pymod-test clean pymod-clean
all: pactester
spidermonkey/js/src: spidermonkey/js.tar.gz
tar xzvf $< -C spidermonkey
sed -i -e 's:\(shell uname -s | sed /\\ /s//_/\):\1 | sed s,GNU.*,Linux,:g' spidermonkey/js/src/config.mk
jsapi_buildstamp: spidermonkey/js/src
cd spidermonkey && SMCFLAGS="$(SHFLAGS) $(SMCFLAGS)" "$(MAKE)" jsapi
touch jsapi_buildstamp
libjs.a: spidermonkey/js/src
cd spidermonkey && SMCFLAGS="$(SHFLAGS) $(SMCFLAGS)" "$(MAKE)" jslib
%.o: %.c
$(CC) $(CFLAGS) $(SHFLAGS) -c $< -o $@
pacparser.o: pac_builtins.h pacparser_utils.h pacparser.h jsapi_buildstamp
pactester.o: pacparser.h pacparser_utils.h
# Also used for the python module, below.
LIBRARY_DEPS = pacparser.o libjs.a
$(LIBRARY): $(LIBRARY_DEPS)
$(MKSHLIB) $(CFLAGS) $(LDFLAGS) -o $@ $^ -lm
$(LIBRARY_LINK): $(LIBRARY)
ln -sf $(LIBRARY) $(LIBRARY_LINK)
pactester: pactester.o $(LIBRARY_LINK) $(LIBRARY_DEPS)
$(CC) $(CFLAGS) $< -o $@ -lpacparser $(LDFLAGS) -L. -I.
test: pactester
@set -u -e; st=0; \
export PACTESTER="$$(pwd)/$<"; \
(set -x && $(BASH) pactester_nointernet_test.sh) || st=1; \
tst=pactester_dns_test.sh; \
if [ -n '$(NO_INTERNET)' ]; then \
echo "Skipping test $${tst}"; \
exit $${st}; \
fi; \
args=$$(test -z '$(NO_IPV6)' && printf '%s\n' '--ipv6'); \
(set -x && $(BASH) $${tst} $${args}) || st=1; \
if [ '$(ENABLE_C_ARES)' = 'yes' ]; then \
(set -x && $(BASH) $${tst} $${args} --c-ares) || st=1; \
fi; \
exit $${st}
docs:
tools/generatedocs.sh
install: all
install -d $(LIB_PREFIX) $(INC_PREFIX) $(BIN_PREFIX)
install -m 644 $(LIBRARY) $(LIB_PREFIX)/$(LIBRARY)
ln -sf $(LIBRARY) $(LIB_PREFIX)/$(LIBRARY_LINK)
install -m 755 pactester $(BIN_PREFIX)/pactester
install -m 644 pacparser.h $(INC_PREFIX)/pacparser.h
# install pactester manpages
install -d $(MAN_PREFIX)/man1/
(test -d docs && install -m 644 docs/man/man1/*.1 $(MAN_PREFIX)/man1/) || true
# install pacparser manpages
install -d $(MAN_PREFIX)/man3/
(test -d docs && install -m 644 docs/man/man3/*.3 $(MAN_PREFIX)/man3/) || true
# install html docs
install -d $(PREFIX)/share/doc/pacparser/html/
(test -d docs/html && install -m 644 docs/html/* $(PREFIX)/share/doc/pacparser/html/) || true
# install examples
install -d $(PREFIX)/share/doc/pacparser/examples/
(test -d examples && install -m 644 examples/* $(PREFIX)/share/doc/pacparser/examples/) || true
pymod: all
cd pymod && python setup.py clean --all
cd pymod && C_ARES_LDFLAGS='$(C_ARES_LDFLAGS)' ARCHFLAGS="" $(PYTHON) setup.py build
pymod-test: pymod
cd pymod && ENABLE_C_ARES='$(ENABLE_C_ARES)' $(PYTHON) setup.py test
install-pymod: pymod
cd pymod && ARCHFLAGS="" $(PYTHON) setup.py install --root="$(DESTDIR)/" $(EXTRA_ARGS)
pymod-clean:
cd pymod && python setup.py clean --all
cd pymod && rm -rf pacparser.egg-info
cd pymod && rm -f $$(find -name '*.py[co]')
clean: pymod-clean
rm -f $(LIBRARY_LINK) $(LIBRARY) libjs.a *.o pactester jsapi_buildstamp
rm -f pac.js.tmp stdout.tmp stderr.tmp
cd spidermonkey && "$(MAKE)" clean