test-crypto: move crypted data out of code
[vpnc.git] / Makefile
blob1fded3ddb0bc788a63a5159d2ec3476c6d7ae8a3
1 # Makefile for an IPSec VPN client compatible with Cisco equipment.
2 # Copyright (C) 2002 Geoffrey Keating
3 # Copyright (C) 2003-2004 Maurice Massar
4 # Copyright (C) 2006-2007 Dan Villiom Podlaski Christiansen
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 # $Id$
22 DESTDIR=
23 PREFIX=/usr/local
24 ETCDIR=/etc/vpnc
25 BINDIR=$(PREFIX)/bin
26 SBINDIR=$(PREFIX)/sbin
27 MANDIR=$(PREFIX)/share/man
28 DOCDIR=$(PREFIX)/share/doc/vpnc
30 # The license of vpnc (Gpl >= 2) is quite likely incompatible with the
31 # openssl license. Openssl is one possible library used to provide certificate
32 # support for vpnc (hybrid only).
33 # While it is OK for users to build their own binaries linking in openssl
34 # with vpnc and even providing dynamically linked binaries it is probably
35 # not OK to provide the binaries inside a distribution.
36 # See http://www.gnome.org/~markmc/openssl-and-the-gpl.html for further
37 # details.
38 # Some distributions like Suse and Fedora seem to think otherwise.
40 # Comment this in to obtain a binary with certificate support which is
41 # GPL incompliant though.
42 #OPENSSL_GPL_VIOLATION=yes
44 CRYPTO_LDADD = $(shell pkg-config --libs gnutls)
45 CRYPTO_CFLAGS = $(shell pkg-config --cflags gnutls) -DCRYPTO_GNUTLS
46 CRYPTO_SRCS = crypto-gnutls.c
48 ifeq ($(OPENSSL_GPL_VIOLATION), yes)
49 CRYPTO_LDADD = -lcrypto
50 CRYPTO_CFLAGS = -DOPENSSL_GPL_VIOLATION -DCRYPTO_OPENSSL
51 CRYPTO_SRCS = crypto-openssl.c
52 endif
54 SRCS = sysdep.c vpnc-debug.c isakmp-pkt.c tunip.c config.c dh.c math_group.c supp.c decrypt-utils.c crypto.c $(CRYPTO_SRCS)
55 BINS = vpnc cisco-decrypt test-crypto
56 OBJS = $(addsuffix .o,$(basename $(SRCS)))
57 CRYPTO_OBJS = $(addsuffix .o,$(basename $(CRYPTO_SRCS)))
58 BINOBJS = $(addsuffix .o,$(BINS))
59 BINSRCS = $(addsuffix .c,$(BINS))
60 VERSION := $(shell sh mk-version)
61 RELEASE_VERSION := $(shell cat VERSION)
63 CC ?= gcc
64 CFLAGS ?= -O3 -g
65 CFLAGS += -W -Wall -Wmissing-declarations -Wwrite-strings
66 CFLAGS += $(shell libgcrypt-config --cflags) $(CRYPTO_CFLAGS)
67 CPPFLAGS += -DVERSION=\"$(VERSION)\"
68 LDFLAGS ?= -g
69 LIBS += $(shell libgcrypt-config --libs) $(CRYPTO_LDADD)
71 ifeq ($(shell uname -s), SunOS)
72 LIBS += -lnsl -lresolv -lsocket
73 endif
74 ifneq (,$(findstring Apple,$(shell $(CC) --version)))
75 # enabled in FSF GCC, disabled by default in Apple GCC
76 CFLAGS += -fstrict-aliasing -freorder-blocks -fsched-interblock
77 endif
79 all : $(BINS) vpnc.8
81 vpnc : $(OBJS) vpnc.o
82 $(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
84 vpnc.8 : vpnc.8.template makeman.pl vpnc
85 ./makeman.pl
87 cisco-decrypt : cisco-decrypt.o decrypt-utils.o
88 $(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
90 test-crypto : sysdep.o test-crypto.o crypto.o $(CRYPTO_OBJS)
91 $(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
93 .depend: $(SRCS) $(BINSRCS)
94 $(CC) -MM $(SRCS) $(BINSRCS) $(CFLAGS) $(CPPFLAGS) > $@
96 vpnc-debug.c vpnc-debug.h : isakmp.h enum2debug.pl
97 LC_ALL=C perl -w ./enum2debug.pl isakmp.h >vpnc-debug.c 2>vpnc-debug.h
99 vpnc.ps : vpnc.c
100 enscript -E -G -T 4 --word-wrap -o- $^ | psnup -2 /dev/stdin $@
102 ../vpnc-%.tar.gz : vpnc-$*.tar.gz
104 etags :
105 etags *.[ch]
106 ctags :
107 ctags *.[ch]
109 vpnc-%.tar.gz :
110 mkdir vpnc-$*
111 LC_ALL=C svn info -R | awk -v RS='' -v FS='\n' '/Node Kind: file/ {print substr($$1,7)}' | \
112 tar -cf - -T - | tar -xf - -C vpnc-$*/
113 tar -czf ../$@ vpnc-$*
114 rm -rf vpnc-$*
116 test : all
117 ./test-crypto test/sig_data.bin test/dec_data.bin \
118 test/cert.pem test/cert1.pem test/cert2.pem test/root.pem
120 dist : VERSION vpnc.8 vpnc-$(RELEASE_VERSION).tar.gz
122 clean :
123 -rm -f $(OBJS) $(BINOBJS) $(BINS) tags
125 distclean : clean
126 -rm -f vpnc-debug.c vpnc-debug.h vpnc.ps vpnc.8 .depend
128 install-common: all
129 install -d $(DESTDIR)$(ETCDIR) $(DESTDIR)$(BINDIR) $(DESTDIR)$(SBINDIR) $(DESTDIR)$(MANDIR)/man1 $(DESTDIR)$(MANDIR)/man8 $(DESTDIR)$(DOCDIR)
130 if [ "`uname -s | cut -c-6`" = "CYGWIN" ]; then \
131 install vpnc-script-win $(DESTDIR)$(ETCDIR)/vpnc-script; \
132 install vpnc-script-win.js $(DESTDIR)$(ETCDIR); \
133 else \
134 install vpnc-script $(DESTDIR)$(ETCDIR); \
136 install -m600 vpnc.conf $(DESTDIR)$(ETCDIR)/default.conf
137 install -m755 vpnc-disconnect $(DESTDIR)$(SBINDIR)
138 install -m755 pcf2vpnc $(DESTDIR)$(BINDIR)
139 install -m644 vpnc.8 $(DESTDIR)$(MANDIR)/man8
140 install -m644 pcf2vpnc.1 $(DESTDIR)$(MANDIR)/man1
141 install -m644 cisco-decrypt.1 $(DESTDIR)$(MANDIR)/man1
142 install -m644 COPYING $(DESTDIR)$(DOCDIR)
144 install : install-common
145 install -m755 vpnc $(DESTDIR)$(SBINDIR)
146 install -m755 cisco-decrypt $(DESTDIR)$(BINDIR)
148 install-strip : install-common
149 install -s -m755 vpnc $(DESTDIR)$(SBINDIR)
150 install -s -m755 cisco-decrypt $(DESTDIR)$(BINDIR)
152 uninstall :
153 rm -f $(DESTDIR)$(SBINDIR)/vpnc \
154 $(DESTDIR)$(SBINDIR)/vpnc-disconnect \
155 $(DESTDIR)$(BINDIR)/pcf2vpnc \
156 $(DESTDIR)$(BINDIR)/cisco-decrypt \
157 $(DESTDIR)$(MANDIR)/man1/cisco-decrypt.1 \
158 $(DESTDIR)$(MANDIR)/man1/pcf2vpnc \
159 $(DESTDIR)$(MANDIR)/man8/vpnc.8
160 @echo NOTE: remove $(DESTDIR)$(ETCDIR) manually
162 .PHONY : clean distclean dist all install install-strip uninstall
165 -include .depend