9d8f047613ddd41a954c49d12dc544fbb05188e7
[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.4
13 PKG_RELEASE:=1
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:=96cd1b8fe1e8cb2920f07c3fd3985faea756e16fdeebd11d3e146d5bd2b04a80
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
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)
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)-ssl \
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_SOCKS),--enable,--disable)-socks \
92 $(if $(CONFIG_OPENVPN_$(BUILD_VARIANT)_ENABLE_HTTP),--enable,--disable)-http-proxy \
93 $(if $(CONFIG_OPENVPN_$(BUILD_VARIANT)_ENABLE_FRAGMENT),--enable,--disable)-fragment \
94 $(if $(CONFIG_OPENVPN_$(BUILD_VARIANT)_ENABLE_MULTIHOME),--enable,--disable)-multihome \
95 $(if $(CONFIG_OPENVPN_$(BUILD_VARIANT)_ENABLE_IPROUTE2),--enable,--disable)-iproute2 \
96 $(if $(CONFIG_OPENVPN_$(BUILD_VARIANT)_ENABLE_DEF_AUTH),--enable,--disable)-def-auth \
97 $(if $(CONFIG_OPENVPN_$(BUILD_VARIANT)_ENABLE_PF),--enable,--disable)-pf \
98 $(if $(CONFIG_OPENVPN_NOSSL),--disable-ssl --disable-crypto,--enable-ssl --enable-crypto) \
99 $(if $(CONFIG_OPENVPN_OPENSSL),--with-crypto-library=openssl) \
100 $(if $(CONFIG_OPENVPN_MBEDTLS),--with-crypto-library=mbedtls) \
101 )
102 endef
103
104 define Package/openvpn-$(BUILD_VARIANT)/conffiles
105 /etc/config/openvpn
106 endef
107
108 define Package/openvpn-$(BUILD_VARIANT)/install
109 $(INSTALL_DIR) \
110 $(1)/usr/sbin \
111 $(1)/usr/share/openvpn \
112 $(1)/etc/init.d \
113 $(1)/etc/config \
114 $(1)/etc/openvpn \
115 $(1)/lib/upgrade/keep.d
116
117 $(INSTALL_BIN) \
118 $(PKG_INSTALL_DIR)/usr/sbin/openvpn \
119 $(1)/usr/sbin/
120
121 $(INSTALL_BIN) \
122 files/openvpn.init \
123 $(1)/etc/init.d/openvpn
124 $(INSTALL_DATA) \
125 files/openvpn.options \
126 $(1)/usr/share/openvpn/openvpn.options
127
128 $(INSTALL_CONF) files/openvpn.config \
129 $(1)/etc/config/openvpn
130
131 $(INSTALL_DATA) \
132 files/openvpn.upgrade \
133 $(1)/lib/upgrade/keep.d/openvpn
134 endef
135
136 $(eval $(call BuildPackage,openvpn-openssl))
137 $(eval $(call BuildPackage,openvpn-mbedtls))
138 $(eval $(call BuildPackage,openvpn-nossl))