# Copyright (C) 2007 Manu Garg. # Author: Manu Garg # # 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 ifeq ($(shell uname),FreeBSD) SHELL := /usr/local/bin/bash else SHELL := /bin/bash endif VERSION ?= $(shell git describe --always --tags --candidate=100) GIT_TAG := $(shell git describe --exact-match --exclude tip --tags HEAD 2>/dev/null || /bin/true) 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=libquickjs.a SHFLAGS = -fPIC ifeq ($(OS_ARCH),FreeBSD) PREFIX ?= /usr/local endif ifeq ($(OS_ARCH),Darwin) PREFIX ?= /usr/local MAC_MAJOR_VERSION := $(shell sw_vers -productVersion | cut -d. -f1) MAC_GT_OS11 := $(shell [ $(MAC_MAJOR_VERSION) -le 10 ] && 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 = endif PREFIX ?= /usr MAINT_CFLAGS := -g -Wall -DVERSION=$(VERSION) ifndef PYTHON PYTHON = python3 endif # QuickJS library. MAINT_CFLAGS += -Iquickjs LIBRARY_LINK = $(LIBRARY_NAME).$(SO_SUFFIX) PREFIX := $(DESTDIR)$(PREFIX) LIB_PREFIX = $(PREFIX)/lib INC_PREFIX = $(PREFIX)/include BIN_PREFIX = $(PREFIX)/bin DOC_PREFIX = $(PREFIX)/share/doc/pacparser MAN_PREFIX = $(PREFIX)/share/man .PHONY: clean pymod install-pymod all: testpactester quickjs/libquickjs.a: cd quickjs && $(MAKE) CFLAGS="$(SHFLAGS)" pacparser.o: pacparser.c pac_utils.h pacparser.h $(CC) $(MAINT_CFLAGS) $(CFLAGS) $(SHFLAGS) -c pacparser.c -o pacparser.o touch pymod/pacparser_o_buildstamp $(LIBRARY): pacparser.o quickjs/libquickjs.a $(MKSHLIB) $(MAINT_CFLAGS) $(CFLAGS) $(LDFLAGS) $(LIB_OPTS) -o $(LIBRARY) pacparser.o quickjs/libquickjs.a -lm libpacparser.a: pacparser.o quickjs/libquickjs.a cp quickjs/libquickjs.a libpacparser.a ar rcs libpacparser.a pacparser.o $(LIBRARY_LINK): $(LIBRARY) ln -sf $(LIBRARY) $(LIBRARY_LINK) pactester: pactester.c pacparser.h libpacparser.a $(CC) $(MAINT_CFLAGS) $(CFLAGS) $(LDFLAGS) pactester.c libpacparser.a -o pactester -lm -L. -I. testpactester: pactester $(LIBRARY_LINK) echo "Running tests for pactester." NO_INTERNET=$(NO_INTERNET) ../tests/runtests.sh pac_utils_dump: pac_utils_dump.c pac_utils.h $(CC) -o pac_utils_dump pac_utils_dump.c pac_utils_js: pac_utils_dump ./pac_utils_dump > ../web/pac_utils.js 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 $(DOC_PREFIX)/html/ (test -d ../docs/html && install -m 644 ../docs/html/* $(DOC_PREFIX)/html/) || true # install examples install -d $(DOC_PREFIX)/examples/ (test -d ../examples && install -m 644 ../examples/* $(DOC_PREFIX)/examples/) || true dist: all bindir=pacparser-$(VERSION)-$(DIST_OS_SUFFIX); \ bindir=$${bindir/-latest/}; \ PREFIX= $(MAKE) install DESTDIR=$${bindir}; \ zip -r $${bindir}.zip $${bindir}/. # Targets to build python module pymod: pacparser.o pacparser.h quickjs/libquickjs.a cd pymod && ARCHFLAGS="" $(PYTHON) setup.py build $(PYTHON) ../tests/runtests.py pymod-dist: pacparser.o pacparser.h quickjs/libquickjs.a cd pymod && ARCHFLAGS="" $(PYTHON) setup.py build cd pymod && ARCHFLAGS="" $(PYTHON) setup.py dist $(PYTHON) ../tests/runtests.py install-pymod: pymod cd pymod && ARCHFLAGS="" $(PYTHON) setup.py install --root="$(DESTDIR)/" $(EXTRA_ARGS) clean: rm -f $(LIBRARY_LINK) $(LIBRARY) pacparser.o pactester pymod/pacparser_o_buildstamp libpacparser.a pac_utils_dump rm -rf dist cd pymod && $(PYTHON) setup.py clean --all cd quickjs && $(MAKE) clean