Stefan Seyfried <seife+obs@b1-systems.com>
[vpnc.git] / Makefile
blob3ed47001346bb50fb7b7eb33b602ee49eee32116
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 LDFLAGS += $(shell libgcrypt-config --libs) $(CRYPTO_LDADD)
71 ifeq ($(shell uname -s), SunOS)
72 LDFLAGS += -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 vpnc-script
81 vpnc : $(OBJS) vpnc.o
82 $(CC) -o $@ $^ $(LDFLAGS)
84 vpnc.8 : vpnc.8.template makeman.pl vpnc
85 ./makeman.pl
87 vpnc-script : vpnc-script.in
88 sed -e 's,@''PREFIX''@,$(PREFIX),g' $< > $@ && chmod 755 $@
90 cisco-decrypt : cisco-decrypt.o decrypt-utils.o
91 $(CC) -o $@ $^ $(LDFLAGS)
93 test-crypto : sysdep.o test-crypto.o crypto.o $(CRYPTO_OBJS)
94 $(CC) -o $@ $^ $(LDFLAGS)
96 .depend: $(SRCS) $(BINSRCS)
97 $(CC) -MM $(SRCS) $(BINSRCS) $(CFLAGS) $(CPPFLAGS) > $@
99 vpnc-debug.c vpnc-debug.h : isakmp.h enum2debug.pl
100 LC_ALL=C perl -w ./enum2debug.pl isakmp.h >vpnc-debug.c 2>vpnc-debug.h
102 vpnc.ps : vpnc.c
103 enscript -E -G -T 4 --word-wrap -o- $^ | psnup -2 /dev/stdin $@
105 ../vpnc-%.tar.gz : vpnc-$*.tar.gz
107 etags :
108 etags *.[ch]
109 ctags :
110 ctags *.[ch]
112 vpnc-%.tar.gz :
113 mkdir vpnc-$*
114 LC_ALL=C svn info -R | awk -v RS='' -v FS='\n' '/Node Kind: file/ {print substr($$1,7)}' | \
115 tar -cf - -T - | tar -xf - -C vpnc-$*/
116 tar -czf ../$@ vpnc-$*
117 rm -rf vpnc-$*
119 test : all
120 ./test-crypto test/cert.pem test/cert0.pem test/cert1.pem test/cert2.pem test/root.pem
121 #./test-crypto test/cert.pem test/cert0.crt test/cert1.crt test/cert2.crt test/root.crt
123 dist : VERSION vpnc.8 vpnc-$(RELEASE_VERSION).tar.gz
125 clean :
126 -rm -f $(OBJS) $(BINOBJS) $(BINS) tags
128 distclean : clean
129 -rm -f vpnc-debug.c vpnc-debug.h vpnc.ps vpnc.8 .depend vpnc-script
131 install-common: all
132 install -d $(DESTDIR)$(ETCDIR) $(DESTDIR)$(BINDIR) $(DESTDIR)$(SBINDIR) $(DESTDIR)$(MANDIR)/man1 $(DESTDIR)$(MANDIR)/man8 $(DESTDIR)$(DOCDIR)
133 if [ "`uname -s | cut -c-6`" = "CYGWIN" ]; then \
134 install vpnc-script-win $(DESTDIR)$(ETCDIR)/vpnc-script; \
135 install vpnc-script-win.js $(DESTDIR)$(ETCDIR); \
136 else \
137 install vpnc-script $(DESTDIR)$(ETCDIR); \
139 install -m600 vpnc.conf $(DESTDIR)$(ETCDIR)/default.conf
140 install -m755 vpnc-disconnect $(DESTDIR)$(SBINDIR)
141 install -m755 pcf2vpnc $(DESTDIR)$(BINDIR)
142 install -m644 vpnc.8 $(DESTDIR)$(MANDIR)/man8
143 install -m644 pcf2vpnc.1 $(DESTDIR)$(MANDIR)/man1
144 install -m644 cisco-decrypt.1 $(DESTDIR)$(MANDIR)/man1
145 install -m644 COPYING $(DESTDIR)$(DOCDIR)
147 install : install-common
148 install -m755 vpnc $(DESTDIR)$(SBINDIR)
149 install -m755 cisco-decrypt $(DESTDIR)$(BINDIR)
151 install-strip : install-common
152 install -s -m755 vpnc $(DESTDIR)$(SBINDIR)
153 install -s -m755 cisco-decrypt $(DESTDIR)$(BINDIR)
155 uninstall :
156 rm -f $(DESTDIR)$(SBINDIR)/vpnc \
157 $(DESTDIR)$(SBINDIR)/vpnc-disconnect \
158 $(DESTDIR)$(BINDIR)/pcf2vpnc \
159 $(DESTDIR)$(BINDIR)/cisco-decrypt \
160 $(DESTDIR)$(MANDIR)/man1/cisco-decrypt.1 \
161 $(DESTDIR)$(MANDIR)/man1/pcf2vpnc \
162 $(DESTDIR)$(MANDIR)/man8/vpnc.8
163 @echo NOTE: remove $(DESTDIR)$(ETCDIR) manually
165 .PHONY : clean distclean dist all install install-strip uninstall
168 -include .depend