c20ba3f2e75eaabda5514a5428b66ef344a43ba0
[openwrt/openwrt.git] / package / network / services / openvpn / Makefile
1 #
2 # Copyright (C) 2010-2015 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_VERSION:=2.4.5
13 PKG_RELEASE:=2
14
15 PKG_SOURCE_URL:=\
16 https://build.openvpn.net/downloads/releases/ \
17 https://swupdate.openvpn.net/community/releases/
18 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
19 PKG_HASH:=43c0a363a332350f620d1cd93bb431e082bedbc93d4fb872f758650d53c1d29e
20
21 PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(BUILD_VARIANT)/$(PKG_NAME)-$(PKG_VERSION)
22 PKG_MAINTAINER:=Felix Fietkau <nbd@nbd.name>
23
24 PKG_INSTALL:=1
25 PKG_FIXUP:=autoreconf
26 PKG_BUILD_PARALLEL:=1
27 PKG_LICENSE:=GPL-2.0
28 PKG_CPE_ID:=cpe:/a:openvpn:openvpn
29
30 include $(INCLUDE_DIR)/package.mk
31
32 define Package/openvpn/Default
33 TITLE:=Open source VPN solution using $(2)
34 SECTION:=net
35 CATEGORY:=Network
36 URL:=http://openvpn.net
37 SUBMENU:=VPN
38 MENU:=1
39 DEPENDS:=+kmod-tun +OPENVPN_$(1)_ENABLE_LZO:liblzo +OPENVPN_$(1)_ENABLE_IPROUTE2:ip $(3)
40 VARIANT:=$(1)
41 ifeq ($(1),nossl)
42 PROVIDES:=openvpn
43 else
44 PROVIDES:=openvpn openvpn-crypto
45 endif
46 endef
47
48 Package/openvpn-openssl=$(call Package/openvpn/Default,openssl,OpenSSL,+PACKAGE_openvpn-openssl:libopenssl)
49 Package/openvpn-mbedtls=$(call Package/openvpn/Default,mbedtls,mbedTLS,+PACKAGE_openvpn-mbedtls:libmbedtls)
50 Package/openvpn-nossl=$(call Package/openvpn/Default,nossl,plaintext (no SSL))
51
52 define Package/openvpn/config/Default
53 source "$(SOURCE)/Config-$(1).in"
54 endef
55
56 Package/openvpn-openssl/config=$(call Package/openvpn/config/Default,openssl)
57 Package/openvpn-mbedtls/config=$(call Package/openvpn/config/Default,mbedtls)
58 Package/openvpn-nossl/config=$(call Package/openvpn/config/Default,nossl)
59
60 ifeq ($(BUILD_VARIANT),mbedtls)
61 CONFIG_OPENVPN_MBEDTLS:=y
62 endif
63 ifeq ($(BUILD_VARIANT),openssl)
64 CONFIG_OPENVPN_OPENSSL:=y
65 endif
66 ifeq ($(BUILD_VARIANT),nossl)
67 CONFIG_OPENVPN_NOSSL:=y
68 endif
69
70 CONFIGURE_VARS += \
71 IFCONFIG=/sbin/ifconfig \
72 ROUTE=/sbin/route \
73 IPROUTE=/sbin/ip \
74 NETSTAT=/sbin/netstat
75
76 TARGET_CFLAGS += -ffunction-sections -fdata-sections
77 TARGET_LDFLAGS += -Wl,--gc-sections
78
79 define Build/Configure
80 $(call Build/Configure/Default, \
81 $(if $(CONFIG_OPENVPN_$(BUILD_VARIANT)_ENABLE_SMALL),--enable-small) \
82 --disable-selinux \
83 --disable-systemd \
84 --disable-plugins \
85 --disable-debug \
86 --disable-pkcs11 \
87 $(if $(CONFIG_OPENVPN_$(BUILD_VARIANT)_ENABLE_LZO),--enable,--disable)-lzo \
88 $(if $(CONFIG_OPENVPN_$(BUILD_VARIANT)_ENABLE_LZ4),--enable,--disable)-lz4 \
89 $(if $(CONFIG_OPENVPN_$(BUILD_VARIANT)_ENABLE_X509_ALT_USERNAME),enable,disable-x509-alt-username)-ssl \
90 $(if $(CONFIG_OPENVPN_$(BUILD_VARIANT)_ENABLE_SERVER),--enable,--disable)-server \
91 $(if $(CONFIG_OPENVPN_$(BUILD_VARIANT)_ENABLE_MANAGEMENT),--enable,--disable)-management \
92 $(if $(CONFIG_OPENVPN_$(BUILD_VARIANT)_ENABLE_SOCKS),--enable,--disable)-socks \
93 $(if $(CONFIG_OPENVPN_$(BUILD_VARIANT)_ENABLE_HTTP),--enable,--disable)-http-proxy \
94 $(if $(CONFIG_OPENVPN_$(BUILD_VARIANT)_ENABLE_FRAGMENT),--enable,--disable)-fragment \
95 $(if $(CONFIG_OPENVPN_$(BUILD_VARIANT)_ENABLE_MULTIHOME),--enable,--disable)-multihome \
96 $(if $(CONFIG_OPENVPN_$(BUILD_VARIANT)_ENABLE_IPROUTE2),--enable,--disable)-iproute2 \
97 $(if $(CONFIG_OPENVPN_$(BUILD_VARIANT)_ENABLE_DEF_AUTH),--enable,--disable)-def-auth \
98 $(if $(CONFIG_OPENVPN_$(BUILD_VARIANT)_ENABLE_PF),--enable,--disable)-pf \
99 $(if $(CONFIG_OPENVPN_NOSSL),--disable-ssl --disable-crypto,--enable-ssl --enable-crypto) \
100 $(if $(CONFIG_OPENVPN_OPENSSL),--with-crypto-library=openssl) \
101 $(if $(CONFIG_OPENVPN_MBEDTLS),--with-crypto-library=mbedtls) \
102 )
103 endef
104
105 define Package/openvpn-$(BUILD_VARIANT)/conffiles
106 /etc/config/openvpn
107 endef
108
109 define Package/openvpn-$(BUILD_VARIANT)/install
110 $(INSTALL_DIR) \
111 $(1)/usr/sbin \
112 $(1)/usr/share/openvpn \
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 $(INSTALL_DATA) \
126 files/openvpn.options \
127 $(1)/usr/share/openvpn/openvpn.options
128
129 $(INSTALL_CONF) files/openvpn.config \
130 $(1)/etc/config/openvpn
131
132 $(INSTALL_DATA) \
133 files/openvpn.upgrade \
134 $(1)/lib/upgrade/keep.d/openvpn
135 endef
136
137 $(eval $(call BuildPackage,openvpn-openssl))
138 $(eval $(call BuildPackage,openvpn-mbedtls))
139 $(eval $(call BuildPackage,openvpn-nossl))