Debian Codegraph @

src/Makefile

raw ◀ ▶
Source reconstructed at patch state 0 of 1 — not the installed (fully patched) source.
1 Debian patch touch this file
1 # Copyright (C) 2007 Manu Garg.
2 # Author: Manu Garg <[email protected]>
3 #
4 # Makefile for pacparser. Please read README file included with this package
5 # for more information about pacparser.
6 #
7 # pacparser is free software; you can redistribute it and/or
8 # modify it under the terms of the GNU Lesser General Public
9 # License as published by the Free Software Foundation; either
10 # version 3 of the License, or (at your option) any later version.
11
12 # pacparser is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 # Lesser General Public License for more details.
16
17 # You should have received a copy of the GNU Lesser General Public
18 # License along with this library; if not, write to the Free Software
19 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
20
21 # This file is not part of the source code repository. It's generated by the
22 # packaging script.
23 -include version.mk
24
25 ifeq ($(shell uname),FreeBSD)
26 SHELL := /usr/local/bin/bash
27 else
28 SHELL := /bin/bash
29 endif
30
31 VERSION ?= $(shell git describe --always --tags --candidate=100)
32
33 GIT_TAG := $(shell git describe --exact-match --exclude tip --tags HEAD 2>/dev/null || /bin/true)
34
35 OS_ARCH := $(subst /,_,$(shell uname -s | sed /\ /s//_/))
36
37 LIBRARY_NAME = libpacparser
38 LIB_VER = 1
39
40 # This Makefile should at least work on Linux and Mac OS X. It should work on
41 # most other types of Unix systems too, but I have not put any conscious effort
42 # for that.
43 #
44 # Set variables according to Linux.
45 SO_SUFFIX = so
46 LIBRARY = $(LIBRARY_NAME).$(SO_SUFFIX).$(LIB_VER)
47 MKSHLIB = $(CC) -shared
48 LIB_OPTS = -Wl,-soname=$(LIBRARY) -Wl,-exclude-libs=libquickjs.a
49 SHFLAGS = -fPIC
50
51 ifeq ($(OS_ARCH),FreeBSD)
52 PREFIX ?= /usr/local
53 endif
54
55 ifeq ($(OS_ARCH),Darwin)
56 PREFIX ?= /usr/local
57 MAC_MAJOR_VERSION := $(shell sw_vers -productVersion | cut -d. -f1)
58 MAC_GT_OS11 := $(shell [ $(MAC_MAJOR_VERSION) -le 10 ] && echo false)
59 SO_SUFFIX = dylib
60 LIBRARY = $(LIBRARY_NAME).$(LIB_VER).$(SO_SUFFIX)
61 MKSHLIB = $(CC) -dynamiclib -framework System
62 LIB_OPTS = -install_name $(PREFIX)/lib/$(notdir $@)
63 SHFLAGS =
64 endif
65
66 PREFIX ?= /usr
67 MAINT_CFLAGS := -g -Wall -DVERSION=$(VERSION)
68
69 ifndef PYTHON
70 PYTHON = python
71 endif
72
73 # QuickJS library.
74 MAINT_CFLAGS += -Iquickjs
75
76 LIBRARY_LINK = $(LIBRARY_NAME).$(SO_SUFFIX)
77 PREFIX := $(DESTDIR)$(PREFIX)
78 LIB_PREFIX = $(PREFIX)/lib
79 INC_PREFIX = $(PREFIX)/include
80 BIN_PREFIX = $(PREFIX)/bin
81 DOC_PREFIX = $(PREFIX)/share/doc/pacparser
82 MAN_PREFIX = $(PREFIX)/share/man
83
84 .PHONY: clean pymod install-pymod
85 all: testpactester
86
87 quickjs/libquickjs.a:
88 cd quickjs && $(MAKE) CFLAGS="$(SHFLAGS)"
89
90 pacparser.o: pacparser.c pac_utils.h pacparser.h
91 $(CC) $(MAINT_CFLAGS) $(CFLAGS) $(SHFLAGS) -c pacparser.c -o pacparser.o
92 touch pymod/pacparser_o_buildstamp
93
94 $(LIBRARY): pacparser.o quickjs/libquickjs.a
95 $(MKSHLIB) $(MAINT_CFLAGS) $(CFLAGS) $(LDFLAGS) $(LIB_OPTS) -o $(LIBRARY) pacparser.o quickjs/libquickjs.a -lm
96
97 libpacparser.a: pacparser.o quickjs/libquickjs.a
98 cp quickjs/libquickjs.a libpacparser.a
99 ar rcs libpacparser.a pacparser.o
100
101 $(LIBRARY_LINK): $(LIBRARY)
102 ln -sf $(LIBRARY) $(LIBRARY_LINK)
103
104 pactester: pactester.c pacparser.h libpacparser.a
105 $(CC) $(MAINT_CFLAGS) $(CFLAGS) $(LDFLAGS) pactester.c libpacparser.a -o pactester -lm -L. -I.
106
107 testpactester: pactester $(LIBRARY_LINK)
108 echo "Running tests for pactester."
109 NO_INTERNET=$(NO_INTERNET) ../tests/runtests.sh
110
111 pac_utils_dump: pac_utils_dump.c pac_utils.h
112 $(CC) -o pac_utils_dump pac_utils_dump.c
113
114 pac_utils_js: pac_utils_dump
115 ./pac_utils_dump > ../web/pac_utils.js
116
117 docs:
118 ../tools/generatedocs.sh
119
120 install: all
121 install -d $(LIB_PREFIX) $(INC_PREFIX) $(BIN_PREFIX)
122 install -m 644 $(LIBRARY) $(LIB_PREFIX)/$(LIBRARY)
123 ln -sf $(LIBRARY) $(LIB_PREFIX)/$(LIBRARY_LINK)
124 install -m 755 pactester $(BIN_PREFIX)/pactester
125 install -m 644 pacparser.h $(INC_PREFIX)/pacparser.h
126 # install pactester manpages
127 install -d $(MAN_PREFIX)/man1/
128 (test -d ../docs && install -m 644 ../docs/man/man1/*.1 $(MAN_PREFIX)/man1/) || true
129 # install pacparser manpages
130 install -d $(MAN_PREFIX)/man3/
131 (test -d ../docs && install -m 644 ../docs/man/man3/*.3 $(MAN_PREFIX)/man3/) || true
132 # install html docs
133 install -d $(DOC_PREFIX)/html/
134 (test -d ../docs/html && install -m 644 ../docs/html/* $(DOC_PREFIX)/html/) || true
135 # install examples
136 install -d $(DOC_PREFIX)/examples/
137 (test -d ../examples && install -m 644 ../examples/* $(DOC_PREFIX)/examples/) || true
138
139 dist: all
140 bindir=pacparser-$(VERSION)-$(DIST_OS_SUFFIX); \
141 bindir=$${bindir/-latest/}; \
142 PREFIX= $(MAKE) install DESTDIR=$${bindir}; \
143 zip -r $${bindir}.zip $${bindir}/.
144
145 # Targets to build python module
146 pymod: pacparser.o pacparser.h quickjs/libquickjs.a
147 cd pymod && ARCHFLAGS="" $(PYTHON) setup.py build
148 $(PYTHON) ../tests/runtests.py
149
150 pymod-dist: pacparser.o pacparser.h quickjs/libquickjs.a
151 cd pymod && ARCHFLAGS="" $(PYTHON) setup.py build
152 cd pymod && ARCHFLAGS="" $(PYTHON) setup.py dist
153 $(PYTHON) ../tests/runtests.py
154
155 install-pymod: pymod
156 cd pymod && ARCHFLAGS="" $(PYTHON) setup.py install --root="$(DESTDIR)/" $(EXTRA_ARGS)
157
158 clean:
159 rm -f $(LIBRARY_LINK) $(LIBRARY) pacparser.o pactester pymod/pacparser_o_buildstamp libpacparser.a pac_utils_dump
160 rm -rf dist
161 cd pymod && $(PYTHON) setup.py clean --all
162 cd quickjs && $(MAKE) clean