openvpn: add from openvpn-devel from /packages, fix support for current polarssl
[openwrt.git] / package / network / services / openvpn / Makefile
1 #
2 # Copyright (C) 2010-2012 OpenWrt.org
3 #
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
6 #
7
8 include $(TOPDIR)/rules.mk
9
10 PKG_NAME:=openvpn
11
12 PKG_REV:=56cffde5d5320e0b1ec364d3e486aca9
13 PKG_VERSION:=2.3.0
14 PKG_RELEASE=1
15
16 PKG_SOURCE_URL:=http://swupdate.openvpn.net/community/releases
17 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
18
19 PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(BUILD_VARIANT)/$(PKG_NAME)-$(PKG_VERSION)
20
21 PKG_INSTALL:=1
22 PKG_FIXUP:=autoreconf
23 PKG_BUILD_PARALLEL:=1
24
25 include $(INCLUDE_DIR)/package.mk
26
27 define Package/openvpn/Default
28   TITLE:=Open source VPN solution using $(2)
29   SECTION:=net
30   CATEGORY:=Network
31   URL:=http://openvpn.net
32   SUBMENU:=VPN
33   MENU:=1
34   DEPENDS:=+kmod-tun +OPENVPN_$(1)_ENABLE_LZO:liblzo +OPENVPN_$(1)_ENABLE_IPROUTE2:ip $(3)
35   VARIANT:=$(1)
36   MAINTAINER:=Mirko Vogt <mirko@openwrt.org>
37 endef
38
39 Package/openvpn-openssl=$(call Package/openvpn/Default,openssl,OpenSSL,+libopenssl)
40 Package/openvpn-polarssl=$(call Package/openvpn/Default,polarssl,PolarSSL,+libpolarssl)
41 Package/openvpn-nossl=$(call Package/openvpn/Default,nossl,plaintext (no SSL))
42
43 define Package/openvpn/config/Default
44         source "$(SOURCE)/Config-$(1).in"
45 endef
46
47 Package/openvpn-openssl/config=$(call Package/openvpn/config/Default,openssl)
48 Package/openvpn-polarssl/config=$(call Package/openvpn/config/Default,polarssl)
49 Package/openvpn-nossl/config=$(call Package/openvpn/config/Default,nossl)
50
51 define Package/openvpn-easy-rsa
52   $(call Package/openvpn)
53   DEPENDS:=+openssl-util
54   TITLE:=Simple shell scripts to manage a Certificate Authority
55 endef
56
57 define Package/openvpn-easy-rsa/conffiles
58 /etc/easy-rsa/keys/serial
59 /etc/easy-rsa/keys/index.txt
60 /etc/easy-rsa/vars
61 endef
62
63
64 ifeq ($(BUILD_VARIANT),polarssl)
65 CONFIG_OPENVPN_POLARSSL:=y
66 endif
67 ifeq ($(BUILD_VARIANT),openssl)
68 CONFIG_OPENVPN_OPENSSL:=y
69 endif
70 ifeq ($(BUILD_VARIANT),nossl)
71 CONFIG_OPENVPN_NOSSL:=y
72 endif
73
74 CONFIGURE_VARS += \
75         IFCONFIG=/sbin/ifconfig \
76         ROUTE=/sbin/route \
77         IPROUTE=/usr/sbin/ip \
78         NETSTAT=/sbin/netstat
79
80 define Build/Configure
81         $(call Build/Configure/Default, \
82                 --enable-small \
83                 --disable-selinux \
84                 --disable-systemd \
85                 --disable-plugins \
86                 --disable-debug \
87                 --disable-eurephia \
88                 --disable-pkcs11 \
89                 $(if $(CONFIG_OPENVPN_$(BUILD_VARIANT)_ENABLE_LZO),--enable,--disable)-lzo \
90                 $(if $(CONFIG_OPENVPN_$(BUILD_VARIANT)_ENABLE_X509_ALT_USERNAME),enable,disable-x509-alt-username)-ssl \
91                 $(if $(CONFIG_OPENVPN_$(BUILD_VARIANT)_ENABLE_SERVER),--enable,--disable)-server \
92                 $(if $(CONFIG_OPENVPN_$(BUILD_VARIANT)_ENABLE_MANAGEMENT),--enable,--disable)-management \
93                 $(if $(CONFIG_OPENVPN_$(BUILD_VARIANT)_ENABLE_SOCKS),--enable,--disable)-socks \
94                 $(if $(CONFIG_OPENVPN_$(BUILD_VARIANT)_ENABLE_HTTP),--enable,--disable)-http \
95                 $(if $(CONFIG_OPENVPN_$(BUILD_VARIANT)_ENABLE_FRAGMENT),--enable,--disable)-fragment \
96                 $(if $(CONFIG_OPENVPN_$(BUILD_VARIANT)_ENABLE_MULTIHOME),--enable,--disable)-multihome \
97                 $(if $(CONFIG_OPENVPN_$(BUILD_VARIANT)_ENABLE_IPROUTE2),--enable,--disable)-iproute2 \
98                 $(if $(CONFIG_OPENVPN_$(BUILD_VARIANT)_ENABLE_DEF_AUTH),--enable,--disable)-def-auth \
99                 $(if $(CONFIG_OPENVPN_$(BUILD_VARIANT)_ENABLE_PF),--enable,--disable)-pf \
100                 $(if $(CONFIG_OPENVPN_NOSSL),--disable-ssl --disable-crypto,--enable-ssl --enable-crypto) \
101                 $(if $(CONFIG_OPENVPN_OPENSSL),--with-crypto-library=openssl) \
102                 $(if $(CONFIG_OPENVPN_POLARSSL),--with-crypto-library=polarssl) \
103         )
104 endef
105
106 define Package/openvpn-$(BUILD_VARIANT)/conffiles
107 /etc/config/openvpn
108 endef
109
110 define Package/openvpn-$(BUILD_VARIANT)/install
111         $(INSTALL_DIR) \
112                 $(1)/usr/sbin \
113                 $(1)/etc/init.d \
114                 $(1)/etc/config \
115                 $(1)/etc/openvpn \
116                 $(1)/lib/upgrade/keep.d
117
118         $(INSTALL_BIN) \
119                 $(PKG_INSTALL_DIR)/usr/sbin/openvpn \
120                 $(1)/usr/sbin/
121
122         $(INSTALL_BIN) \
123                 files/openvpn.init \
124                 $(1)/etc/init.d/openvpn
125
126         $(INSTALL_CONF) files/openvpn.config \
127                 $(1)/etc/config/openvpn
128
129         $(INSTALL_DATA) \
130                 files/openvpn.upgrade \
131                 $(1)/lib/upgrade/keep.d/openvpn
132 endef
133
134 define Package/openvpn-easy-rsa/install
135         $(INSTALL_DIR) $(1)/usr/sbin
136         $(CP) $(PKG_BUILD_DIR)/easy-rsa/2.0/{build-*,clean-all,inherit-inter,list-crl,pkitool,revoke-full,sign-req,whichopensslcnf} $(1)/usr/sbin/
137         $(INSTALL_DIR) $(1)/etc/easy-rsa
138         $(INSTALL_DATA) $(PKG_BUILD_DIR)/easy-rsa/2.0/openssl-1.0.0.cnf $(1)/etc/easy-rsa/openssl-1.0.0.cnf
139         $(INSTALL_DATA) $(PKG_BUILD_DIR)/easy-rsa/2.0/vars $(1)/etc/easy-rsa/vars
140         $(INSTALL_DIR) $(1)/etc/easy-rsa/keys
141         $(INSTALL_DATA) files/easy-rsa.index $(1)/etc/easy-rsa/keys/index.txt
142         $(INSTALL_DATA) files/easy-rsa.serial $(1)/etc/easy-rsa/keys/serial
143 endef
144
145 $(eval $(call BuildPackage,openvpn-openssl))
146 $(eval $(call BuildPackage,openvpn-polarssl))
147 $(eval $(call BuildPackage,openvpn-nossl))
148 $(eval $(call BuildPackage,openvpn-easy-rsa))