2015-03-15 21:38:29 +00:00
|
|
|
### Variable overrides
|
|
|
|
|
|
|
|
# You can change many aspects of the build behaviour without modifying this
|
|
|
|
# make file simply by setting environment variables.
|
|
|
|
#
|
|
|
|
# Dependencies and features are auto-detected, but can be overridden:
|
|
|
|
#
|
|
|
|
# OPENSSL_BASE Prefix of OpenSSL library and headers to build against
|
|
|
|
# LIBEVENT_BASE Prefix of libevent library and headers to build against
|
|
|
|
# CHECK_BASE Prefix of check library and headers to build against (optional)
|
|
|
|
# PKGCONFIG Name/path of pkg-config program to use for auto-detection
|
2015-03-23 21:10:00 +00:00
|
|
|
# PCFLAGS Additional pkg-config flags
|
2015-03-15 21:38:29 +00:00
|
|
|
# XNU_VERSION Version of included XNU headers to build against (OS X only)
|
|
|
|
# FEATURES Enable optional or force-enable undetected features (see below)
|
|
|
|
#
|
Allow uid, gid and mode of installed files to be tuned
Introducing the overridable variables INSTALLUID, INSTALLGID, BINUID,
BINGID, BINMODE, MANUID, MANGID, MANMODE that allow overriding of uid,
gid and mode of installed files. Note that this solution still has the
limitation that uid, gid and mode of created directories cannot be set.
Issue: #81
Reported by: Shiloh Heurich
2015-03-16 23:09:19 +00:00
|
|
|
# Where and how to install to:
|
2015-03-15 21:38:29 +00:00
|
|
|
#
|
|
|
|
# PREFIX Prefix to install under (default /usr/local)
|
|
|
|
# DESTDIR Destination root under which prefix is located (default /)
|
|
|
|
# MANDIR Subdir of PREFIX that contains man section dirs
|
Allow uid, gid and mode of installed files to be tuned
Introducing the overridable variables INSTALLUID, INSTALLGID, BINUID,
BINGID, BINMODE, MANUID, MANGID, MANMODE that allow overriding of uid,
gid and mode of installed files. Note that this solution still has the
limitation that uid, gid and mode of created directories cannot be set.
Issue: #81
Reported by: Shiloh Heurich
2015-03-16 23:09:19 +00:00
|
|
|
# INSTALLUID UID to use for installed files
|
|
|
|
# INSTALLGID GID to use for installed files
|
2015-03-15 21:38:29 +00:00
|
|
|
#
|
|
|
|
# Standard compiler variables are respected, e.g.:
|
|
|
|
#
|
|
|
|
# CC Compiler, e.g. for cross-compiling, ccache or ccc-analyzer
|
|
|
|
# CFLAGS Additional compiler flags, e.g. optimization flags
|
|
|
|
# CPPFLAGS Additional pre-processor flags
|
|
|
|
# LDFLAGS Additional linker flags
|
|
|
|
# LIBS Additional libraries to link against
|
2015-03-23 21:10:00 +00:00
|
|
|
#
|
|
|
|
# You can e.g. create a statically linked binary by running:
|
|
|
|
# % PCFLAGS='--static' CFLAGS='-static' LDFLAGS='-static' make
|
2015-03-15 21:38:29 +00:00
|
|
|
|
|
|
|
|
2012-04-13 12:47:30 +00:00
|
|
|
### OpenSSL tweaking
|
|
|
|
|
2014-11-05 19:06:11 +00:00
|
|
|
# Define to enable support for SSLv2.
|
2015-07-28 21:23:53 +00:00
|
|
|
# Default since 0.4.9 is to disable SSLv2 entirely even if OpenSSL supports it,
|
|
|
|
# since there are servers that are not compatible with SSLv2 Client Hello
|
|
|
|
# messages. If you build in SSLv2 support, you can disable it at runtime using
|
|
|
|
# -R ssl2 to get the same result as not building in SSLv2 support at all.
|
2014-11-05 19:06:11 +00:00
|
|
|
#FEATURES+= -DWITH_SSLV2
|
2012-04-13 12:47:30 +00:00
|
|
|
|
|
|
|
# Define to make SSLsplit set a session id context in server mode.
|
|
|
|
#FEATURES+= -DUSE_SSL_SESSION_ID_CONTEXT
|
|
|
|
|
|
|
|
|
|
|
|
### Debugging
|
|
|
|
|
2012-06-05 21:11:05 +00:00
|
|
|
# These flags are added to CFLAGS iff building from a git repo.
|
2012-04-13 12:47:30 +00:00
|
|
|
DEBUG_CFLAGS?= -g
|
|
|
|
#DEBUG_CFLAGS+= -Werror
|
|
|
|
|
|
|
|
# Define to remove false positives when debugging memory allocation.
|
|
|
|
# Note that you probably want to build OpenSSL with -DPURIFY too.
|
|
|
|
#FEATURES+= -DPURIFY
|
|
|
|
|
|
|
|
# Define to add proxy state machine debugging; dump state in debug mode.
|
2017-05-29 09:22:23 +00:00
|
|
|
FEATURES+= -DDEBUG_PROXY
|
2012-04-13 12:47:30 +00:00
|
|
|
|
|
|
|
# Define to add certificate debugging; dump all certificates in debug mode.
|
|
|
|
#FEATURES+= -DDEBUG_CERTIFICATE
|
|
|
|
|
|
|
|
# Define to add SSL session cache debugging; dump all sessions in debug mode.
|
|
|
|
#FEATURES+= -DDEBUG_SESSION_CACHE
|
|
|
|
|
2015-05-17 18:23:25 +00:00
|
|
|
# Define to add debugging of sslsplit's own ClientHello message parser.
|
|
|
|
#FEATURES+= -DDEBUG_CLIENTHELLO_PARSER
|
2012-04-13 12:47:30 +00:00
|
|
|
|
|
|
|
# Define to add thread debugging; dump thread state when choosing a thread.
|
2017-05-29 09:22:23 +00:00
|
|
|
FEATURES+= -DDEBUG_THREAD
|
2012-04-13 12:47:30 +00:00
|
|
|
|
2017-06-30 21:29:39 +00:00
|
|
|
# Define to add features specific to OpenBSD only, such as uuid_create().
|
|
|
|
FEATURES+= -DOPENBSD
|
|
|
|
|
2014-01-14 16:28:59 +00:00
|
|
|
# When debugging OpenSSL related issues, make sure you use a debug build of
|
|
|
|
# OpenSSL and consider enabling its debugging options -DREF_PRINT -DREF_CHECK
|
|
|
|
# for debugging reference counting of OpenSSL objects and/or
|
|
|
|
# -DPURIFY for using valgrind and similar tools.
|
|
|
|
|
2012-04-13 12:47:30 +00:00
|
|
|
|
2014-10-30 22:01:55 +00:00
|
|
|
### Mac OS X header selection
|
2014-01-10 13:58:04 +00:00
|
|
|
|
2015-02-24 18:24:12 +00:00
|
|
|
# First, try to use the exact XNU version reported by the kernel. If they
|
|
|
|
# are not available, try to look up a suitable XNU version that we have
|
|
|
|
# headers for based on the OS X release reported by sw_vers. Then as a last
|
|
|
|
# resort, fall back to the latest version of XNU that we have headers for,
|
2015-05-02 10:23:14 +00:00
|
|
|
# which may or may not work, depending on if there were API or ABI changes
|
2015-02-24 18:24:12 +00:00
|
|
|
# in the DIOCNATLOOK ioctl interface to the NAT state table in the kernel.
|
2015-03-15 21:38:29 +00:00
|
|
|
#
|
|
|
|
# Note that you can override the XNU headers used by defining XNU_VERSION.
|
2015-02-24 18:24:12 +00:00
|
|
|
|
2014-01-10 13:58:04 +00:00
|
|
|
ifeq ($(shell uname),Darwin)
|
2014-11-10 18:59:56 +00:00
|
|
|
ifneq ($(wildcard /usr/include/libproc.h),)
|
2014-11-07 23:46:07 +00:00
|
|
|
FEATURES+= -DHAVE_DARWIN_LIBPROC
|
2014-11-10 18:59:56 +00:00
|
|
|
endif
|
2014-10-30 22:01:55 +00:00
|
|
|
XNU_VERSION?= $(shell uname -a|sed 's/^.*root:xnu-//g'|sed 's/~.*$$//')
|
|
|
|
OSX_VERSION?= $(shell sw_vers -productVersion)
|
2015-02-24 18:24:12 +00:00
|
|
|
XNU_METHOD= uname
|
2015-03-02 22:13:48 +00:00
|
|
|
XNU_HAVE:= $(XNU_VERSION)
|
2014-10-30 22:01:55 +00:00
|
|
|
ifeq ($(wildcard xnu/xnu-$(XNU_VERSION)),)
|
2015-05-02 10:23:14 +00:00
|
|
|
XNU_VERSION= $(shell awk '/^XNU_RELS.*\# $(OSX_VERSION)$$/ {print $$2}' xnu/GNUmakefile)
|
2015-02-24 18:24:12 +00:00
|
|
|
XNU_METHOD= sw_vers
|
|
|
|
endif
|
|
|
|
ifeq ($(wildcard xnu/xnu-$(XNU_VERSION)),)
|
|
|
|
XNU_VERSION= $(shell awk '/^XNU_RELS/ {print $$2}' xnu/GNUmakefile|tail -1)
|
|
|
|
XNU_METHOD= fallback
|
2014-10-30 22:01:55 +00:00
|
|
|
endif
|
|
|
|
ifneq ($(wildcard xnu/xnu-$(XNU_VERSION)),)
|
2014-10-18 01:45:28 +00:00
|
|
|
FEATURES+= -DHAVE_PF
|
2014-10-30 22:01:55 +00:00
|
|
|
PKG_CPPFLAGS+= -I./xnu/xnu-$(XNU_VERSION)
|
2015-03-02 22:13:48 +00:00
|
|
|
BUILD_INFO+= OSX:$(OSX_VERSION) XNU:$(XNU_VERSION):$(XNU_METHOD):$(XNU_HAVE)
|
2014-01-10 13:58:04 +00:00
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
2012-04-13 12:47:30 +00:00
|
|
|
### Autodetected features
|
|
|
|
|
|
|
|
# Autodetect pf
|
|
|
|
ifneq ($(wildcard /usr/include/net/pfvar.h),)
|
|
|
|
FEATURES+= -DHAVE_PF
|
2013-12-23 13:27:39 +00:00
|
|
|
# OpenBSD 4.7+ and FreeBSD 9.0+ also include ipfw-style divert-to in pf
|
|
|
|
FEATURES+= -DHAVE_IPFW
|
2012-04-13 12:47:30 +00:00
|
|
|
endif
|
|
|
|
|
|
|
|
# Autodetect ipfw
|
|
|
|
ifneq ($(wildcard /sbin/ipfw),)
|
|
|
|
FEATURES+= -DHAVE_IPFW
|
|
|
|
endif
|
|
|
|
|
|
|
|
# Autodetect ipfilter
|
|
|
|
ifneq ($(wildcard /usr/include/netinet/ip_fil.h),)
|
|
|
|
FEATURES+= -DHAVE_IPFILTER
|
|
|
|
endif
|
|
|
|
|
|
|
|
# Autodetect netfilter
|
|
|
|
ifneq ($(wildcard /usr/include/linux/netfilter.h),)
|
|
|
|
FEATURES+= -DHAVE_NETFILTER
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
|
|
### Variables you might need to override
|
|
|
|
|
|
|
|
PREFIX?= /usr/local
|
2014-10-18 17:32:22 +00:00
|
|
|
MANDIR?= share/man
|
2012-04-13 12:47:30 +00:00
|
|
|
|
Allow uid, gid and mode of installed files to be tuned
Introducing the overridable variables INSTALLUID, INSTALLGID, BINUID,
BINGID, BINMODE, MANUID, MANGID, MANMODE that allow overriding of uid,
gid and mode of installed files. Note that this solution still has the
limitation that uid, gid and mode of created directories cannot be set.
Issue: #81
Reported by: Shiloh Heurich
2015-03-16 23:09:19 +00:00
|
|
|
INSTALLUID?= 0
|
|
|
|
INSTALLGID?= 0
|
|
|
|
BINUID?= $(INSTALLUID)
|
|
|
|
BINGID?= $(INSTALLGID)
|
|
|
|
BINMODE?= 0755
|
|
|
|
MANUID?= $(INSTALLUID)
|
|
|
|
MANGID?= $(INSTALLGID)
|
|
|
|
MANMODE?= 0644
|
|
|
|
|
2012-04-13 12:47:30 +00:00
|
|
|
OPENSSL?= openssl
|
|
|
|
PKGCONFIG?= pkg-config
|
|
|
|
|
|
|
|
BASENAME?= basename
|
|
|
|
CAT?= cat
|
2015-04-22 21:12:03 +00:00
|
|
|
CUT?= cut
|
2012-04-13 12:47:30 +00:00
|
|
|
GREP?= grep
|
|
|
|
INSTALL?= install
|
|
|
|
MKDIR?= mkdir
|
|
|
|
SED?= sed
|
|
|
|
|
|
|
|
|
|
|
|
### Variables only used for developer targets
|
|
|
|
|
|
|
|
KHASH_URL?= https://github.com/attractivechaos/klib/raw/master/khash.h
|
2012-05-14 19:07:53 +00:00
|
|
|
GPGSIGNKEY?= 0xB5D3397E
|
2012-04-13 12:47:30 +00:00
|
|
|
|
|
|
|
CPPCHECK?= cppcheck
|
2012-05-14 19:07:53 +00:00
|
|
|
GPG?= gpg
|
2012-04-13 12:47:30 +00:00
|
|
|
GIT?= git
|
|
|
|
WGET?= wget
|
|
|
|
|
|
|
|
BZIP2?= bzip2
|
2012-04-13 13:25:07 +00:00
|
|
|
COL?= col
|
2012-04-13 12:47:30 +00:00
|
|
|
LN?= ln
|
|
|
|
MAN?= man
|
|
|
|
TAR?= tar
|
|
|
|
|
|
|
|
|
|
|
|
### You should not need to touch anything below this line
|
|
|
|
|
|
|
|
TARGET:= sslsplit
|
|
|
|
PNAME:= SSLsplit
|
2012-04-30 23:40:31 +00:00
|
|
|
SRCS:= $(filter-out $(wildcard *.t.c),$(wildcard *.c))
|
2012-04-13 12:47:30 +00:00
|
|
|
HDRS:= $(wildcard *.h)
|
|
|
|
OBJS:= $(SRCS:.c=.o)
|
|
|
|
|
2012-04-30 23:40:31 +00:00
|
|
|
TSRCS:= $(wildcard *.t.c)
|
|
|
|
TOBJS:= $(TSRCS:.t.c=.t.o)
|
2012-04-13 12:47:30 +00:00
|
|
|
TOBJS+= $(filter-out main.o,$(OBJS))
|
|
|
|
|
|
|
|
VFILE:= $(wildcard VERSION)
|
|
|
|
GITDIR:= $(wildcard .git)
|
|
|
|
ifdef VFILE
|
|
|
|
VERSION:= $(shell $(CAT) VERSION)
|
2014-10-30 22:01:55 +00:00
|
|
|
BUILD_INFO+= V:FILE
|
2012-04-13 12:47:30 +00:00
|
|
|
else
|
|
|
|
ifndef GITDIR
|
|
|
|
VERSION:= $(shell $(BASENAME) $(PWD)|\
|
|
|
|
$(GREP) $(TARGET)-|\
|
|
|
|
$(SED) 's/.*$(TARGET)-\(.*\)/\1/g')
|
2015-04-22 21:12:03 +00:00
|
|
|
NEWSSHA:= $(shell $(OPENSSL) dgst -sha1 -r NEWS.md |\
|
|
|
|
$(CUT) -c -7)
|
|
|
|
BUILD_INFO+= V:DIR N:$(NEWSSHA)
|
2012-04-13 12:47:30 +00:00
|
|
|
else
|
|
|
|
VERSION:= $(shell $(GIT) describe --tags --dirty --always)
|
2014-10-30 22:01:55 +00:00
|
|
|
BUILD_INFO+= V:GIT
|
2012-04-13 12:47:30 +00:00
|
|
|
endif
|
|
|
|
CFLAGS+= $(DEBUG_CFLAGS)
|
|
|
|
endif
|
|
|
|
BUILD_DATE:= $(shell date +%Y-%m-%d)
|
|
|
|
|
|
|
|
# Autodetect dependencies known to pkg-config
|
|
|
|
PKGS:=
|
|
|
|
ifndef OPENSSL_BASE
|
2015-03-23 21:10:00 +00:00
|
|
|
PKGS+= $(shell $(PKGCONFIG) $(PCFLAGS) --exists openssl \
|
|
|
|
&& echo openssl)
|
2012-04-13 12:47:30 +00:00
|
|
|
endif
|
|
|
|
ifndef LIBEVENT_BASE
|
2015-03-23 21:10:00 +00:00
|
|
|
PKGS+= $(shell $(PKGCONFIG) $(PCFLAGS) --exists libevent \
|
|
|
|
&& echo libevent)
|
|
|
|
PKGS+= $(shell $(PKGCONFIG) $(PCFLAGS) --exists libevent_openssl \
|
2012-04-13 12:47:30 +00:00
|
|
|
&& echo libevent_openssl)
|
2015-03-23 21:10:00 +00:00
|
|
|
PKGS+= $(shell $(PKGCONFIG) $(PCFLAGS) --exists libevent_pthreads \
|
2012-04-13 12:47:30 +00:00
|
|
|
&& echo libevent_pthreads)
|
|
|
|
endif
|
|
|
|
TPKGS:=
|
|
|
|
ifndef CHECK_BASE
|
2015-03-23 21:10:00 +00:00
|
|
|
TPKGS+= $(shell $(PKGCONFIG) $(PCFLAGS) --exists check \
|
|
|
|
&& echo check)
|
2012-04-13 12:47:30 +00:00
|
|
|
endif
|
|
|
|
|
|
|
|
# Autodetect dependencies not known to pkg-config
|
|
|
|
ifeq (,$(filter openssl,$(PKGS)))
|
|
|
|
OPENSSL_PAT:= include/openssl/ssl.h
|
|
|
|
ifdef OPENSSL_BASE
|
|
|
|
OPENSSL_FIND:= $(wildcard $(OPENSSL_BASE)/$(OPENSSL_PAT))
|
|
|
|
else
|
|
|
|
OPENSSL_FIND:= $(wildcard \
|
|
|
|
/opt/local/$(OPENSSL_PAT) \
|
|
|
|
/usr/local/$(OPENSSL_PAT) \
|
|
|
|
/usr/$(OPENSSL_PAT))
|
|
|
|
endif
|
2015-05-02 10:23:14 +00:00
|
|
|
OPENSSL_AVAIL:= $(OPENSSL_FIND:/$(OPENSSL_PAT)=)
|
|
|
|
OPENSSL_FOUND:= $(word 1,$(OPENSSL_AVAIL))
|
2012-04-13 12:47:30 +00:00
|
|
|
ifndef OPENSSL_FOUND
|
2012-05-02 11:35:36 +00:00
|
|
|
$(error dependency 'OpenSSL' not found; \
|
|
|
|
install it or point OPENSSL_BASE to base path)
|
2012-04-13 12:47:30 +00:00
|
|
|
endif
|
|
|
|
endif
|
|
|
|
ifeq (,$(filter libevent,$(PKGS)))
|
|
|
|
LIBEVENT_PAT:= include/event2/event.h
|
|
|
|
ifdef LIBEVENT_BASE
|
|
|
|
LIBEVENT_FIND:= $(wildcard $(LIBEVENT_BASE)/$(LIBEVENT_PAT))
|
|
|
|
else
|
|
|
|
LIBEVENT_FIND:= $(wildcard \
|
|
|
|
/opt/local/$(LIBEVENT_PAT) \
|
|
|
|
/usr/local/$(LIBEVENT_PAT) \
|
|
|
|
/usr/$(LIBEVENT_PAT))
|
|
|
|
endif
|
2015-05-02 10:23:14 +00:00
|
|
|
LIBEVENT_AVAIL:=$(LIBEVENT_FIND:/$(LIBEVENT_PAT)=)
|
|
|
|
LIBEVENT_FOUND:=$(word 1,$(LIBEVENT_AVAIL))
|
2012-04-13 12:47:30 +00:00
|
|
|
ifndef LIBEVENT_FOUND
|
2012-05-02 11:35:36 +00:00
|
|
|
$(error dependency 'libevent 2.x' not found; \
|
|
|
|
install it or point LIBEVENT_BASE to base path)
|
2012-04-13 12:47:30 +00:00
|
|
|
endif
|
|
|
|
endif
|
|
|
|
ifeq (,$(filter check,$(TPKGS)))
|
|
|
|
CHECK_PAT:= include/check.h
|
|
|
|
ifdef CHECK_BASE
|
|
|
|
CHECK_FIND:= $(wildcard $(CHECK_BASE)/$(CHECK_PAT))
|
|
|
|
else
|
|
|
|
CHECK_FIND:= $(wildcard \
|
|
|
|
/opt/local/$(CHECK_PAT) \
|
|
|
|
/usr/local/$(CHECK_PAT) \
|
|
|
|
/usr/$(CHECK_PAT))
|
|
|
|
endif
|
2015-05-02 10:23:14 +00:00
|
|
|
CHECK_AVAIL:= $(CHECK_FIND:/$(CHECK_PAT)=)
|
|
|
|
CHECK_FOUND:= $(word 1,$(CHECK_AVAIL))
|
2012-04-13 12:47:30 +00:00
|
|
|
ifndef CHECK_FOUND
|
2012-05-02 11:35:36 +00:00
|
|
|
CHECK_MISSING:= 1
|
2012-04-13 12:47:30 +00:00
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifdef OPENSSL_FOUND
|
|
|
|
PKG_CPPFLAGS+= -I$(OPENSSL_FOUND)/include
|
|
|
|
PKG_LDFLAGS+= -L$(OPENSSL_FOUND)/lib
|
|
|
|
PKG_LIBS+= -lssl -lcrypto -lz
|
|
|
|
endif
|
|
|
|
ifdef LIBEVENT_FOUND
|
|
|
|
PKG_CPPFLAGS+= -I$(LIBEVENT_FOUND)/include
|
|
|
|
PKG_LDFLAGS+= -L$(LIBEVENT_FOUND)/lib
|
|
|
|
PKG_LIBS+= -levent
|
|
|
|
endif
|
|
|
|
ifeq (,$(filter libevent_openssl,$(PKGS)))
|
|
|
|
PKG_LIBS+= -levent_openssl
|
|
|
|
endif
|
|
|
|
ifeq (,$(filter libevent_pthreads,$(PKGS)))
|
|
|
|
PKG_LIBS+= -levent_pthreads
|
|
|
|
endif
|
|
|
|
ifdef CHECK_FOUND
|
|
|
|
TPKG_CPPFLAGS+= -I$(CHECK_FOUND)/include
|
|
|
|
TPKG_LDFLAGS+= -L$(CHECK_FOUND)/lib
|
|
|
|
TPKG_LIBS+= -lcheck
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifneq (,$(strip $(PKGS)))
|
2015-03-23 21:10:00 +00:00
|
|
|
PKG_CFLAGS+= $(shell $(PKGCONFIG) $(PCFLAGS) --cflags-only-other $(PKGS))
|
|
|
|
PKG_CPPFLAGS+= $(shell $(PKGCONFIG) $(PCFLAGS) --cflags-only-I $(PKGS))
|
|
|
|
PKG_LDFLAGS+= $(shell $(PKGCONFIG) $(PCFLAGS) --libs-only-L \
|
|
|
|
--libs-only-other $(PKGS))
|
|
|
|
PKG_LIBS+= $(shell $(PKGCONFIG) $(PCFLAGS) --libs-only-l $(PKGS))
|
2012-04-13 12:47:30 +00:00
|
|
|
endif
|
|
|
|
ifneq (,$(strip $(TPKGS)))
|
2015-03-23 21:10:00 +00:00
|
|
|
TPKG_CFLAGS+= $(shell $(PKGCONFIG) $(PCFLAGS) --cflags-only-other $(TPKGS))
|
|
|
|
TPKG_CPPFLAGS+= $(shell $(PKGCONFIG) $(PCFLAGS) --cflags-only-I $(TPKGS))
|
|
|
|
TPKG_LDFLAGS+= $(shell $(PKGCONFIG) $(PCFLAGS) --libs-only-L \
|
|
|
|
--libs-only-other $(TPKGS))
|
|
|
|
TPKG_LIBS+= $(shell $(PKGCONFIG) $(PCFLAGS) --libs-only-l $(TPKGS))
|
2012-04-13 12:47:30 +00:00
|
|
|
endif
|
|
|
|
|
2014-11-03 21:08:07 +00:00
|
|
|
CPPDEFS+= -D_GNU_SOURCE \
|
2012-05-23 17:09:52 +00:00
|
|
|
-D"BNAME=\"$(TARGET)\"" -D"PNAME=\"$(PNAME)\"" \
|
|
|
|
-D"VERSION=\"$(VERSION)\"" -D"BUILD_DATE=\"$(BUILD_DATE)\"" \
|
2014-10-30 22:01:55 +00:00
|
|
|
-D"FEATURES=\"$(FEATURES)\"" -D"BUILD_INFO=\"$(BUILD_INFO)\""
|
2014-11-03 21:08:07 +00:00
|
|
|
CPPCHECKFLAGS+= $(CPPDEFS)
|
|
|
|
FEATURES:= $(sort $(FEATURES))
|
|
|
|
|
2014-11-04 17:31:19 +00:00
|
|
|
ifneq (ccc-analyzer,$(notdir $(CC)))
|
|
|
|
PKG_CPPFLAGS:= $(subst -I,-isystem,$(PKG_CPPFLAGS))
|
|
|
|
TPKG_CPPFLAGS:= $(subst -I,-isystem,$(TPKG_CPPFLAGS))
|
|
|
|
endif
|
|
|
|
|
2014-11-03 21:08:07 +00:00
|
|
|
CFLAGS+= $(PKG_CFLAGS) \
|
|
|
|
-std=c99 -Wall -Wextra -pedantic \
|
|
|
|
-D_FORTIFY_SOURCE=2 -fstack-protector-all
|
2014-11-04 17:31:19 +00:00
|
|
|
CPPFLAGS+= $(PKG_CPPFLAGS) $(CPPDEFS) $(FEATURES)
|
|
|
|
TCPPFLAGS+= $(TPKG_CPPFLAGS)
|
2014-01-14 16:29:32 +00:00
|
|
|
LDFLAGS+= $(PKG_LDFLAGS)
|
2012-05-23 17:09:52 +00:00
|
|
|
LIBS+= $(PKG_LIBS)
|
|
|
|
|
2014-01-14 16:29:32 +00:00
|
|
|
ifneq ($(shell uname),Darwin)
|
|
|
|
CFLAGS+= -pthread
|
|
|
|
LDFLAGS+= -pthread
|
|
|
|
endif
|
|
|
|
|
2012-04-13 12:47:30 +00:00
|
|
|
export VERSION
|
|
|
|
export OPENSSL
|
|
|
|
export MKDIR
|
2014-10-30 22:01:55 +00:00
|
|
|
export WGET
|
2012-04-13 12:47:30 +00:00
|
|
|
|
2015-03-15 21:38:29 +00:00
|
|
|
ifndef MAKE_RESTARTS
|
|
|
|
$(info ------------------------------------------------------------------------------)
|
|
|
|
$(info $(PNAME) $(VERSION))
|
|
|
|
$(info ------------------------------------------------------------------------------)
|
|
|
|
$(info Report bugs at https://github.com/droe/sslsplit/issues/new)
|
|
|
|
$(info Before reporting bugs, make sure to try the latest develop branch first:)
|
|
|
|
$(info % git clone -b develop https://github.com/droe/sslsplit.git)
|
|
|
|
$(info ------------------------------------------------------------------------------)
|
|
|
|
$(info Via pkg-config: $(strip $(PKGS) $(TPKGS)))
|
2012-04-13 12:47:30 +00:00
|
|
|
ifdef OPENSSL_FOUND
|
2015-03-15 21:38:29 +00:00
|
|
|
$(info OPENSSL_BASE: $(strip $(OPENSSL_FOUND)))
|
2012-04-13 12:47:30 +00:00
|
|
|
endif
|
|
|
|
ifdef LIBEVENT_FOUND
|
2015-03-15 21:38:29 +00:00
|
|
|
$(info LIBEVENT_BASE: $(strip $(LIBEVENT_FOUND)))
|
2012-04-13 12:47:30 +00:00
|
|
|
endif
|
|
|
|
ifdef CHECK_FOUND
|
2015-03-15 21:38:29 +00:00
|
|
|
$(info CHECK_BASE: $(strip $(CHECK_FOUND)))
|
2012-04-13 12:47:30 +00:00
|
|
|
endif
|
2015-03-15 21:38:29 +00:00
|
|
|
$(info Build options: $(FEATURES))
|
2014-10-30 22:01:55 +00:00
|
|
|
ifeq ($(shell uname),Darwin)
|
2015-03-15 21:38:29 +00:00
|
|
|
$(info OSX_VERSION: $(OSX_VERSION))
|
|
|
|
$(info XNU_VERSION: $(XNU_VERSION) ($(XNU_METHOD), have $(XNU_HAVE)))
|
|
|
|
endif
|
|
|
|
$(info uname -a: $(shell uname -a))
|
|
|
|
$(info ------------------------------------------------------------------------------)
|
2014-10-30 22:01:55 +00:00
|
|
|
endif
|
2012-04-13 12:47:30 +00:00
|
|
|
|
2015-03-15 21:38:29 +00:00
|
|
|
all: $(TARGET)
|
|
|
|
|
2012-04-13 12:47:30 +00:00
|
|
|
$(TARGET): $(OBJS)
|
|
|
|
$(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
|
|
|
|
|
2012-05-02 11:35:36 +00:00
|
|
|
version.o: version.c version.h GNUmakefile $(VFILE) FORCE
|
|
|
|
|
|
|
|
%.t.o: %.t.c $(HDRS) GNUmakefile
|
|
|
|
ifdef CHECK_MISSING
|
|
|
|
$(error unit test dependency 'check' not found; \
|
|
|
|
install it or point CHECK_BASE to base path)
|
|
|
|
endif
|
2014-11-03 21:08:07 +00:00
|
|
|
$(CC) -c $(CPPFLAGS) $(TCPPFLAGS) $(CFLAGS) $(TPKG_CFLAGS) -o $@ \
|
2012-05-02 11:35:36 +00:00
|
|
|
-x c $<
|
|
|
|
|
2012-04-13 20:49:52 +00:00
|
|
|
%.o: %.c $(HDRS) GNUmakefile
|
2012-04-13 12:47:30 +00:00
|
|
|
$(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $<
|
|
|
|
|
2016-03-25 11:00:35 +00:00
|
|
|
travis: TCPPFLAGS+=-DTRAVIS
|
|
|
|
travis: test
|
|
|
|
|
2014-11-16 21:47:42 +00:00
|
|
|
test: TCPPFLAGS+=-D"TEST_ZEROUSR=\"$(shell id -u -n root||echo 0)\""
|
|
|
|
test: TCPPFLAGS+=-D"TEST_ZEROGRP=\"$(shell id -g -n root||echo 0)\""
|
2012-06-05 21:23:27 +00:00
|
|
|
test: $(TARGET).test
|
2012-04-13 12:47:30 +00:00
|
|
|
$(RM) extra/pki/session.pem
|
2012-06-05 21:23:27 +00:00
|
|
|
$(MAKE) -C extra/pki testreqs session
|
2012-04-13 12:47:30 +00:00
|
|
|
./$(TARGET).test
|
|
|
|
|
|
|
|
$(TARGET).test: $(TOBJS)
|
|
|
|
$(CC) $(LDFLAGS) $(TPKG_LDFLAGS) -o $@ $^ $(LIBS) $(TPKG_LIBS)
|
|
|
|
|
|
|
|
clean:
|
2014-11-27 21:09:03 +00:00
|
|
|
$(RM) -f $(TARGET) $(TARGET).test *.o .*.o *.core *~
|
2012-04-13 12:47:30 +00:00
|
|
|
$(RM) -rf *.dSYM
|
|
|
|
|
|
|
|
install: $(TARGET)
|
2014-10-18 17:32:22 +00:00
|
|
|
test -d $(DESTDIR)$(PREFIX)/bin || $(MKDIR) -p $(DESTDIR)$(PREFIX)/bin
|
|
|
|
test -d $(DESTDIR)$(PREFIX)/$(MANDIR)/man1 || \
|
|
|
|
$(MKDIR) -p $(DESTDIR)$(PREFIX)/$(MANDIR)/man1
|
Allow uid, gid and mode of installed files to be tuned
Introducing the overridable variables INSTALLUID, INSTALLGID, BINUID,
BINGID, BINMODE, MANUID, MANGID, MANMODE that allow overriding of uid,
gid and mode of installed files. Note that this solution still has the
limitation that uid, gid and mode of created directories cannot be set.
Issue: #81
Reported by: Shiloh Heurich
2015-03-16 23:09:19 +00:00
|
|
|
$(INSTALL) -o $(BINUID) -g $(BINGID) -m $(BINMODE) \
|
|
|
|
$(TARGET) $(DESTDIR)$(PREFIX)/bin/
|
|
|
|
$(INSTALL) -o $(MANUID) -g $(MANGID) -m $(MANMODE) \
|
|
|
|
$(TARGET).1 $(DESTDIR)$(PREFIX)/$(MANDIR)/man1/
|
2012-04-13 12:47:30 +00:00
|
|
|
|
|
|
|
deinstall:
|
2014-10-18 17:32:22 +00:00
|
|
|
$(RM) -f $(DESTDIR)$(PREFIX)/bin/$(TARGET) $(DESTDIR)$(PREFIX)/$(MANDIR)/man1/$(TARGET).1
|
2012-04-13 12:47:30 +00:00
|
|
|
|
|
|
|
ifdef GITDIR
|
2012-04-13 20:49:52 +00:00
|
|
|
lint:
|
2014-11-03 21:08:07 +00:00
|
|
|
$(CPPCHECK) $(CPPCHECKFLAGS) --force --enable=all --error-exitcode=1 .
|
2012-04-13 20:49:52 +00:00
|
|
|
|
2012-04-13 12:47:30 +00:00
|
|
|
mantest:
|
|
|
|
$(RM) -f man1
|
|
|
|
$(LN) -sf . man1
|
|
|
|
$(MAN) -M . 1 $(TARGET)
|
|
|
|
$(RM) man1
|
|
|
|
|
2012-04-13 13:25:07 +00:00
|
|
|
$(TARGET)-$(VERSION).1.txt: $(TARGET).1
|
|
|
|
$(RM) -f man1
|
|
|
|
$(LN) -sf . man1
|
|
|
|
$(MAN) -M . 1 $(TARGET) | $(COL) -b >$@
|
|
|
|
$(RM) man1
|
|
|
|
|
|
|
|
man: $(TARGET)-$(VERSION).1.txt
|
|
|
|
|
|
|
|
manclean:
|
|
|
|
$(RM) -f $(TARGET)-*.1.txt
|
|
|
|
|
2012-04-13 12:47:30 +00:00
|
|
|
fetchdeps:
|
2014-11-04 17:30:26 +00:00
|
|
|
$(WGET) -O- $(KHASH_URL) >khash.h
|
2014-10-30 22:01:55 +00:00
|
|
|
#$(RM) -rf xnu/xnu-*
|
|
|
|
$(MAKE) -C xnu fetch
|
2012-04-13 12:47:30 +00:00
|
|
|
|
2012-05-14 19:07:53 +00:00
|
|
|
dist: $(TARGET)-$(VERSION).tar.bz2 $(TARGET)-$(VERSION).tar.bz2.asc
|
|
|
|
|
|
|
|
%.asc: %
|
|
|
|
$(GPG) -u $(GPGSIGNKEY) --armor --output $@ --detach-sig $<
|
2012-04-13 12:47:30 +00:00
|
|
|
|
|
|
|
$(TARGET)-$(VERSION).tar.bz2:
|
|
|
|
$(MKDIR) -p $(TARGET)-$(VERSION)
|
|
|
|
echo $(VERSION) >$(TARGET)-$(VERSION)/VERSION
|
|
|
|
$(GIT) archive --prefix=$(TARGET)-$(VERSION)/ HEAD \
|
|
|
|
>$(TARGET)-$(VERSION).tar
|
|
|
|
$(TAR) -f $(TARGET)-$(VERSION).tar -r $(TARGET)-$(VERSION)/VERSION
|
|
|
|
$(BZIP2) <$(TARGET)-$(VERSION).tar >$(TARGET)-$(VERSION).tar.bz2
|
|
|
|
$(RM) $(TARGET)-$(VERSION).tar
|
|
|
|
$(RM) -r $(TARGET)-$(VERSION)
|
|
|
|
|
2012-05-14 19:07:53 +00:00
|
|
|
disttest: $(TARGET)-$(VERSION).tar.bz2 $(TARGET)-$(VERSION).tar.bz2.asc
|
|
|
|
$(GPG) --verify $<.asc $<
|
|
|
|
$(BZIP2) -d < $< | $(TAR) -x -f -
|
2012-04-13 12:47:30 +00:00
|
|
|
cd $(TARGET)-$(VERSION) && $(MAKE) && $(MAKE) test && ./$(TARGET) -V
|
|
|
|
$(RM) -r $(TARGET)-$(VERSION)
|
|
|
|
|
2012-04-13 13:25:07 +00:00
|
|
|
distclean:
|
2012-05-14 19:07:53 +00:00
|
|
|
$(RM) -f $(TARGET)-*.tar.bz2*
|
2012-04-13 12:47:30 +00:00
|
|
|
|
2012-04-13 13:25:07 +00:00
|
|
|
realclean: distclean manclean clean
|
2012-04-13 12:47:30 +00:00
|
|
|
$(MAKE) -C extra/pki clean
|
|
|
|
endif
|
|
|
|
|
2012-04-13 20:49:52 +00:00
|
|
|
FORCE:
|
|
|
|
|
2012-04-13 12:47:30 +00:00
|
|
|
.PHONY: all config clean test lint install deinstall \
|
2012-04-13 13:25:07 +00:00
|
|
|
mantest man manclean fetchdeps dist disttest distclean realclean
|
2012-04-13 12:47:30 +00:00
|
|
|
|