-
Notifications
You must be signed in to change notification settings - Fork 23
/
Makefile
182 lines (150 loc) · 6.25 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
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
# Makefile for an IPSec VPN client compatible with Cisco equipment.
# Copyright (C) 2002 Geoffrey Keating
# Copyright (C) 2003-2004 Maurice Massar
# Copyright (C) 2006-2007 Dan Villiom Podlaski Christiansen
# Copyright (C) 2017-2020 Davide Pucci
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# $Id$
PREFIX?=/usr/local
ETCDIR=/etc/vpnc
BINDIR=$(PREFIX)/bin
SBINDIR=$(PREFIX)/sbin
MANDIR=$(PREFIX)/share/man
DOCDIR=$(PREFIX)/share/doc/vpnc
LICENSEDIR=$(PREFIX)/share/licenses/vpnc
SYSTEMDDIR=$(PREFIX)/lib/systemd/system
# The license of vpnc (Gpl >= 2) is quite likely incompatible with the
# openssl license. Openssl is one possible library used to provide certificate
# support for vpnc (hybrid only).
# While it is OK for users to build their own binaries linking in openssl
# with vpnc and even providing dynamically linked binaries it is probably
# not OK to provide the binaries inside a distribution.
# See http://www.gnome.org/~markmc/openssl-and-the-gpl.html for further
# details.
# Some distributions like Suse and Fedora seem to think otherwise.
# Comment this in to obtain a binary with certificate support which is
# GPL incompliant though.
#OPENSSL_GPL_VIOLATION=yes
PKG_CONFIG ?= pkg-config
LIBGCRYPT_CONFIG ?= libgcrypt-config
LIBGCRYPT_LDADD = $(shell $(PKG_CONFIG) --libs libgcrypt || $(LIBGCRYPT_CONFIG) --libs)
LIBGCRYPT_CFLAGS = $(shell $(PKG_CONFIG) --cflags libgcrypt || $(LIBGCRYPT_CONFIG) --cflags)
ifneq ($(CRYPTO_NONE), yes)
CRYPTO_SRC = src/crypto.c
CRYPTO_BINS = test-crypto
ifneq ($(OPENSSL_GPL_VIOLATION), yes)
CRYPTO_LDADD = $(shell $(PKG_CONFIG) --libs gnutls)
CRYPTO_CFLAGS = $(shell $(PKG_CONFIG) --cflags gnutls) -DCRYPTO_GNUTLS
CRYPTO_SRCS = $(CRYPTO_SRC) src/crypto-gnutls.c
else
CRYPTO_LDADD = -lcrypto
CRYPTO_CFLAGS = -DOPENSSL_GPL_VIOLATION -DCRYPTO_OPENSSL
CRYPTO_SRCS = $(CRYPTO_SRC) src/crypto-openssl.c
endif
else
CRYPTO_CFLAGS = -DCRYPTO_NONE
endif
SRCS = src/sysdep.c src/vpnc-debug.c src/isakmp-pkt.c src/tunip.c src/config.c src/dh.c src/math_group.c src/supp.c src/decrypt-utils.c $(CRYPTO_SRCS)
BINS = vpnc cisco-decrypt $(CRYPTO_BINS)
OBJS = $(addsuffix .o,$(basename $(SRCS)))
CRYPTO_OBJS = $(addsuffix .o,$(basename $(CRYPTO_SRCS)))
BINOBJS = $(addsuffix .o,$(BINS))
BINSRCS = $(addsuffix .c,$(BINS))
SCRIPT_PATH := /etc/vpnc/vpnc-script
ROOT_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
BUILDDIR := $(ROOT_DIR)/bin
export BUILDDIR
VERSION := 0.5.3
export VERSION
CC ?= gcc
CFLAGS ?= -O3 -g
CFLAGS += -W -Wall -Wmissing-declarations -Wwrite-strings
CFLAGS += $(LIBGCRYPT_CFLAGS) $(CRYPTO_CFLAGS)
CPPFLAGS += -DVERSION=\"$(VERSION)\" -DSCRIPT_PATH=\"$(SCRIPT_PATH)\"
LDFLAGS ?= -g
LIBS += $(LIBGCRYPT_LDADD) $(CRYPTO_LDADD)
VPNC ?= $(BUILDDIR)/vpnc
ifeq ($(shell uname -s), SunOS)
LIBS += -lnsl -lresolv -lsocket
endif
ifneq (,$(findstring Apple,$(shell $(CC) --version)))
# enabled in FSF GCC, disabled by default in Apple GCC
CFLAGS += -fstrict-aliasing -freorder-blocks -fsched-interblock
endif
all: $(addprefix $(BUILDDIR)/,$(BINS)) src/vpnc.8
$(BUILDDIR)/vpnc: $(OBJS) src/vpnc.o
@mkdir -p $(BUILDDIR)
$(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
src/vpnc.8: src/vpnc.8.template src/makeman.pl $(VPNC)
./src/makeman.pl $(VPNC)
$(BUILDDIR)/cisco-decrypt: src/cisco-decrypt.o src/decrypt-utils.o
@mkdir -p $(BUILDDIR)
$(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
ifneq ($(CRYPTO_NONE), yes)
$(BUILDDIR)/test-crypto: src/sysdep.o src/test-crypto.o src/crypto.o $(CRYPTO_OBJS)
@mkdir -p $(BUILDDIR)
$(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
endif
.depend: $(SRCS) $(BINSRCS)
$(CC) -MM $(SRCS) $(BINSRCS) $(CFLAGS) $(CPPFLAGS) > $@
src/vpnc-debug.c src/vpnc-debug.h: src/isakmp.h src/enum2debug.pl
cd src && LC_ALL=C perl -w ./enum2debug.pl isakmp.h >vpnc-debug.c 2>vpnc-debug.h
vpnc.ps: src/vpnc.c
enscript -E -G -T 4 --word-wrap -o- $^ | psnup -2 /dev/stdin $@
etags:
etags *.[ch]
ctags:
ctags *.[ch]
test: all
$(BUILDDIR)/test-crypto src/test/sig_data.bin src/test/dec_data.bin src/test/ca_list.pem \
src/test/cert3.pem src/test/cert2.pem src/test/cert1.pem src/test/cert0.pem
dist: vpnc.8
clean:
-rm -rf $(OBJS) $(BINOBJS) $(BUILDDIR) tags src/cisco-decrypt.o src/test-crypto.o src/vpnc.o
distclean: clean
-rm -f src/vpnc-debug.c src/vpnc-debug.h src/vpnc.ps src/vpnc.8 src/.depend
install-common: all
install -d $(DESTDIR)$(ETCDIR) $(DESTDIR)$(BINDIR) $(DESTDIR)$(SBINDIR) $(DESTDIR)$(MANDIR)/man1 $(DESTDIR)$(MANDIR)/man8 $(DESTDIR)$(SYSTEMDDIR) $(DESTDIR)$(LICENSEDIR)
install -m600 src/vpnc.conf $(DESTDIR)$(ETCDIR)/default.conf
install -m755 src/vpnc-disconnect $(DESTDIR)$(SBINDIR)
install -m755 src/pcf2vpnc $(DESTDIR)$(BINDIR)
install -m644 src/vpnc.8 $(DESTDIR)$(MANDIR)/man8
install -m644 src/pcf2vpnc.1 $(DESTDIR)$(MANDIR)/man1
install -m644 src/cisco-decrypt.1 $(DESTDIR)$(MANDIR)/man1
install -m644 src/[email protected] -t $(DESTDIR)$(SYSTEMDDIR)
install -m644 LICENSE $(DESTDIR)$(LICENSEDIR)
install-doc:
install -d $(DESTDIR)$(DOCDIR)
install -m644 docs/*.md $(DESTDIR)$(DOCDIR)
rm -f $(DESTDIR)$(DOCDIR)/README.md
install: install-common install-doc
install -m755 $(BUILDDIR)/vpnc $(DESTDIR)$(SBINDIR)
install -m755 $(BUILDDIR)/cisco-decrypt $(DESTDIR)$(BINDIR)
install-strip: install-common
install -s -m755 $(BUILDDIR)/vpnc $(DESTDIR)$(SBINDIR)
install -s -m755 $(BUILDDIR)/cisco-decrypt $(DESTDIR)$(BINDIR)
uninstall:
rm -f $(DESTDIR)$(SBINDIR)/vpnc \
$(DESTDIR)$(SBINDIR)/vpnc-disconnect \
$(DESTDIR)$(BINDIR)/pcf2vpnc \
$(DESTDIR)$(BINDIR)/cisco-decrypt \
$(DESTDIR)$(MANDIR)/man1/cisco-decrypt.1 \
$(DESTDIR)$(MANDIR)/man1/pcf2vpnc \
$(DESTDIR)$(MANDIR)/man8/vpnc.8
@echo NOTE: remove $(DESTDIR)$(ETCDIR) manually
.PHONY: clean distclean dist all install install-strip uninstall
#
-include .depend