forked from manugarg/pacparser
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
136 lines (111 loc) · 4.59 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
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
# 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
VERSION ?= $(shell git describe --always --tags --candidate=100)
PREFIX ?= /usr
OS_ARCH := $(subst /,_,$(shell uname -s | sed /\ /s//_/))
LIBRARY_NAME = libpacparser
LIB_VER = 1
# 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)
PREFIX = /usr/local
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
CFLAGS = -g -DXP_UNIX -Wall -DVERSION=$(VERSION)
ifndef PYTHON
PYTHON = python
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
.PHONY: clean pymod install-pymod
all: testpactester
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
pacparser.o: pacparser.c pac_utils.h pacparser.h jsapi_buildstamp
$(CC) $(CFLAGS) $(SHFLAGS) -c pacparser.c -o pacparser.o
touch pymod/pacparser_o_buildstamp
$(LIBRARY): pacparser.o libjs.a
$(MKSHLIB) $(CFLAGS) $(LDFLAGS) $(LIB_OPTS) -o $(LIBRARY) pacparser.o libjs.a -lm
$(LIBRARY_LINK): $(LIBRARY)
ln -sf $(LIBRARY) $(LIBRARY_LINK)
pactester: pactester.c pacparser.h $(LIBRARY_LINK)
$(CC) $(CFLAGS) $(LDFLAGS) pactester.c -o pactester -lpacparser -L. -I.
testpactester: pactester
echo "Running tests for pactester."
NO_INTERNET=$(NO_INTERNET) ../tests/runtests.sh
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
# Targets to build python module
pymod: pacparser.o pacparser.h libjs.a
cp libjs.a pacparser.o pymod/
cd pymod && ARCHFLAGS="" $(PYTHON) setup.py build
$(PYTHON) ../tests/runtests.py
install-pymod: pymod
cd pymod && ARCHFLAGS="" $(PYTHON) setup.py install --root="$(DESTDIR)/" $(EXTRA_ARGS)
clean:
rm -f $(LIBRARY_LINK) $(LIBRARY) libjs.a pacparser.o pactester pymod/pacparser_o_buildstamp jsapi_buildstamp
cd pymod && python setup.py clean --all
cd spidermonkey && "$(MAKE)" clean