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