openvpn: let all openvpn variants provide a virtual openvpn package
[openwrt/staging/yousong.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.0
13 PKG_RELEASE:=2
14
15 PKG_SOURCE_URL:=http://swupdate.openvpn.net/community/releases
16 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
17 PKG_HASH:=6f23ba49a1dbeb658f49c7ae17d9ea979de6d92c7357de3d55cd4525e1b2f87e
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 PKG_LICENSE:=GPL-2.0
25
26 include $(INCLUDE_DIR)/package.mk
27
28 define Package/openvpn/Default
29 TITLE:=Open source VPN solution using $(2)
30 SECTION:=net
31 CATEGORY:=Network
32 URL:=http://openvpn.net
33 SUBMENU:=VPN
34 MENU:=1
35 DEPENDS:=+kmod-tun +OPENVPN_$(1)_ENABLE_LZO:liblzo +OPENVPN_$(1)_ENABLE_IPROUTE2:ip $(3)
36 VARIANT:=$(1)
37 PROVIDES:=openvpn
38 MAINTAINER:=Mirko Vogt <mirko@openwrt.org>
39 endef
40
41 Package/openvpn-openssl=$(call Package/openvpn/Default,openssl,OpenSSL,+PACKAGE_openvpn-openssl:libopenssl)
42 Package/openvpn-mbedtls=$(call Package/openvpn/Default,mbedtls,mbedTLS,+PACKAGE_openvpn-mbedtls:libmbedtls)
43 Package/openvpn-nossl=$(call Package/openvpn/Default,nossl,plaintext (no SSL))
44
45 define Package/openvpn/config/Default
46 source "$(SOURCE)/Config-$(1).in"
47 endef
48
49 Package/openvpn-openssl/config=$(call Package/openvpn/config/Default,openssl)
50 Package/openvpn-mbedtls/config=$(call Package/openvpn/config/Default,mbedtls)
51 Package/openvpn-nossl/config=$(call Package/openvpn/config/Default,nossl)
52
53 ifeq ($(BUILD_VARIANT),mbedtls)
54 CONFIG_OPENVPN_MBEDTLS:=y
55 endif
56 ifeq ($(BUILD_VARIANT),openssl)
57 CONFIG_OPENVPN_OPENSSL:=y
58 endif
59 ifeq ($(BUILD_VARIANT),nossl)
60 CONFIG_OPENVPN_NOSSL:=y
61 endif
62
63 CONFIGURE_VARS += \
64 IFCONFIG=/sbin/ifconfig \
65 ROUTE=/sbin/route \
66 IPROUTE=/sbin/ip \
67 NETSTAT=/sbin/netstat
68
69 TARGET_CFLAGS += -ffunction-sections -fdata-sections
70 TARGET_LDFLAGS += -Wl,--gc-sections
71
72 define Build/Configure
73 $(call Build/Configure/Default, \
74 $(if $(CONFIG_OPENVPN_$(BUILD_VARIANT)_ENABLE_SMALL),--enable-small) \
75 --disable-selinux \
76 --disable-systemd \
77 --disable-plugins \
78 --disable-debug \
79 --disable-pkcs11 \
80 $(if $(CONFIG_OPENVPN_$(BUILD_VARIANT)_ENABLE_LZO),--enable,--disable)-lzo \
81 $(if $(CONFIG_OPENVPN_$(BUILD_VARIANT)_ENABLE_LZ4),--enable,--disable)-lz4 \
82 $(if $(CONFIG_OPENVPN_$(BUILD_VARIANT)_ENABLE_X509_ALT_USERNAME),enable,disable-x509-alt-username)-ssl \
83 $(if $(CONFIG_OPENVPN_$(BUILD_VARIANT)_ENABLE_SERVER),--enable,--disable)-server \
84 $(if $(CONFIG_OPENVPN_$(BUILD_VARIANT)_ENABLE_MANAGEMENT),--enable,--disable)-management \
85 $(if $(CONFIG_OPENVPN_$(BUILD_VARIANT)_ENABLE_SOCKS),--enable,--disable)-socks \
86 $(if $(CONFIG_OPENVPN_$(BUILD_VARIANT)_ENABLE_HTTP),--enable,--disable)-http-proxy \
87 $(if $(CONFIG_OPENVPN_$(BUILD_VARIANT)_ENABLE_FRAGMENT),--enable,--disable)-fragment \
88 $(if $(CONFIG_OPENVPN_$(BUILD_VARIANT)_ENABLE_MULTIHOME),--enable,--disable)-multihome \
89 $(if $(CONFIG_OPENVPN_$(BUILD_VARIANT)_ENABLE_IPROUTE2),--enable,--disable)-iproute2 \
90 $(if $(CONFIG_OPENVPN_$(BUILD_VARIANT)_ENABLE_DEF_AUTH),--enable,--disable)-def-auth \
91 $(if $(CONFIG_OPENVPN_$(BUILD_VARIANT)_ENABLE_PF),--enable,--disable)-pf \
92 $(if $(CONFIG_OPENVPN_NOSSL),--disable-ssl --disable-crypto,--enable-ssl --enable-crypto) \
93 $(if $(CONFIG_OPENVPN_OPENSSL),--with-crypto-library=openssl) \
94 $(if $(CONFIG_OPENVPN_MBEDTLS),--with-crypto-library=mbedtls) \
95 )
96 endef
97
98 define Package/openvpn-$(BUILD_VARIANT)/conffiles
99 /etc/config/openvpn
100 endef
101
102 define Package/openvpn-$(BUILD_VARIANT)/install
103 $(INSTALL_DIR) \
104 $(1)/usr/sbin \
105 $(1)/etc/init.d \
106 $(1)/etc/config \
107 $(1)/etc/openvpn \
108 $(1)/lib/upgrade/keep.d
109
110 $(INSTALL_BIN) \
111 $(PKG_INSTALL_DIR)/usr/sbin/openvpn \
112 $(1)/usr/sbin/
113
114 $(INSTALL_BIN) \
115 files/openvpn.init \
116 $(1)/etc/init.d/openvpn
117
118 $(INSTALL_CONF) files/openvpn.config \
119 $(1)/etc/config/openvpn
120
121 $(INSTALL_DATA) \
122 files/openvpn.upgrade \
123 $(1)/lib/upgrade/keep.d/openvpn
124 endef
125
126 $(eval $(call BuildPackage,openvpn-openssl))
127 $(eval $(call BuildPackage,openvpn-mbedtls))
128 $(eval $(call BuildPackage,openvpn-nossl))