dropbear: add missing zlib dependency for dropbearconvert
[openwrt/staging/jow.git] / package / network / services / dropbear / Makefile
1 #
2 # Copyright (C) 2006-2016 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:=dropbear
11 PKG_VERSION:=2019.78
12 PKG_RELEASE:=2
13
14 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
15 PKG_SOURCE_URL:= \
16 http://matt.ucc.asn.au/dropbear/releases/ \
17 https://dropbear.nl/mirror/releases/
18 PKG_HASH:=525965971272270995364a0eb01f35180d793182e63dd0b0c3eb0292291644a4
19
20 PKG_LICENSE:=MIT
21 PKG_LICENSE_FILES:=LICENSE libtomcrypt/LICENSE libtommath/LICENSE
22 PKG_CPE_ID:=cpe:/a:matt_johnston:dropbear_ssh_server
23
24 PKG_BUILD_PARALLEL:=1
25 PKG_USE_MIPS16:=0
26 PKG_FIXUP:=autoreconf
27
28 PKG_CONFIG_DEPENDS:= \
29 CONFIG_TARGET_INIT_PATH CONFIG_DROPBEAR_ECC CONFIG_DROPBEAR_ECC_FULL \
30 CONFIG_DROPBEAR_CURVE25519 CONFIG_DROPBEAR_ZLIB \
31 CONFIG_DROPBEAR_UTMP CONFIG_DROPBEAR_PUTUTLINE \
32 CONFIG_DROPBEAR_DBCLIENT
33
34 include $(INCLUDE_DIR)/package.mk
35
36 ifneq ($(DUMP),1)
37 STAMP_CONFIGURED:=$(strip $(STAMP_CONFIGURED))_$(shell echo $(CONFIG_TARGET_INIT_PATH) | mkhash md5)
38 endif
39
40 define Package/dropbear/Default
41 URL:=http://matt.ucc.asn.au/dropbear/
42 endef
43
44 define Package/dropbear/config
45 source "$(SOURCE)/Config.in"
46 endef
47
48 define Package/dropbear
49 $(call Package/dropbear/Default)
50 SECTION:=net
51 CATEGORY:=Base system
52 TITLE:=Small SSH2 client/server
53 DEPENDS:= +DROPBEAR_ZLIB:zlib
54 ALTERNATIVES:=\
55 100:/usr/bin/ssh:/usr/sbin/dropbear \
56 100:/usr/bin/scp:/usr/sbin/dropbear \
57
58 endef
59
60 define Package/dropbear/description
61 A small SSH2 server/client designed for small memory environments.
62 endef
63
64 define Package/dropbear/conffiles
65 $(if $(CONFIG_DROPBEAR_ECC),/etc/dropbear/dropbear_ecdsa_host_key)
66 /etc/dropbear/dropbear_rsa_host_key
67 /etc/config/dropbear
68 endef
69
70 define Package/dropbearconvert
71 $(call Package/dropbear/Default)
72 SECTION:=utils
73 CATEGORY:=Utilities
74 TITLE:=Utility for converting SSH keys
75 DEPENDS:= +DROPBEAR_ZLIB:zlib
76 endef
77
78 CONFIGURE_ARGS += \
79 --disable-pam \
80 --enable-openpty \
81 --enable-syslog \
82 --disable-lastlog \
83 --disable-utmpx \
84 $(if $(CONFIG_DROPBEAR_UTMP),,--disable-utmp) \
85 --disable-wtmp \
86 --disable-wtmpx \
87 --disable-loginfunc \
88 $(if $(CONFIG_DROPBEAR_PUTUTLINE),,--disable-pututline) \
89 --disable-pututxline \
90 $(if $(CONFIG_DROPBEAR_ZLIB),,--disable-zlib) \
91 --enable-bundled-libtom
92
93 TARGET_CFLAGS += -DARGTYPE=3 -ffunction-sections -fdata-sections -flto
94 TARGET_LDFLAGS += -Wl,--gc-sections -flto=jobserver
95
96 define Build/Configure
97 : > $(PKG_BUILD_DIR)/localoptions.h
98
99 $(Build/Configure/Default)
100
101 echo '#define DEFAULT_PATH "$(TARGET_INIT_PATH)"' >> \
102 $(PKG_BUILD_DIR)/localoptions.h
103
104 echo '#define DROPBEAR_CURVE25519 $(if $(CONFIG_DROPBEAR_CURVE25519),1,0)' >> \
105 $(PKG_BUILD_DIR)/localoptions.h
106
107 for OPTION in DROPBEAR_ECDSA DROPBEAR_ECDH; do \
108 echo "#define $$$$OPTION $(if $(CONFIG_DROPBEAR_ECC),1,0)" >> \
109 $(PKG_BUILD_DIR)/localoptions.h; \
110 done
111
112 # remove protocol idented software version number
113 $(ESED) 's,^(#define LOCAL_IDENT) .*$$$$,\1 "SSH-2.0-dropbear",g' \
114 $(PKG_BUILD_DIR)/sysoptions.h
115
116 # disable legacy/unsafe methods and unused functionality
117 for OPTION in INETD_MODE DROPBEAR_CLI_NETCAT \
118 DROPBEAR_3DES DROPBEAR_DSS DROPBEAR_ENABLE_CBC_MODE \
119 DROPBEAR_SHA1_96_HMAC DROPBEAR_USE_PASSWORD_ENV; do \
120 echo "#define $$$$OPTION 0" >> \
121 $(PKG_BUILD_DIR)/localoptions.h; \
122 done
123
124 # enable nistp384 and nistp521 only if full ECC support was requested
125 for OPTION in DROPBEAR_ECC_384 DROPBEAR_ECC_521; do \
126 $(ESED) 's,^(#define '$$$$OPTION') .*$$$$,\1 $(if $(CONFIG_DROPBEAR_ECC_FULL),1,0),g' \
127 $(PKG_BUILD_DIR)/sysoptions.h; \
128 done
129
130 # Enforce rebuild of svr-chansession.c
131 rm -f $(PKG_BUILD_DIR)/svr-chansession.o
132
133 # Rebuild them on config change
134 +$(MAKE) -C $(PKG_BUILD_DIR)/libtomcrypt clean
135 +$(MAKE) -C $(PKG_BUILD_DIR)/libtommath clean
136 endef
137
138 define Build/Compile
139 +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
140 $(TARGET_CONFIGURE_OPTS) \
141 PROGRAMS="dropbear $(if $(CONFIG_DROPBEAR_DBCLIENT),dbclient,) dropbearkey scp" \
142 MULTI=1 SCPPROGRESS=1
143 +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
144 $(TARGET_CONFIGURE_OPTS) \
145 PROGRAMS="dropbearconvert"
146 endef
147
148 define Package/dropbear/install
149 $(INSTALL_DIR) $(1)/usr/sbin
150 $(INSTALL_BIN) $(PKG_BUILD_DIR)/dropbearmulti $(1)/usr/sbin/dropbear
151 $(INSTALL_DIR) $(1)/usr/bin
152 $(if $(CONFIG_DROPBEAR_DBCLIENT),$(LN) ../sbin/dropbear $(1)/usr/bin/dbclient,)
153 $(LN) ../sbin/dropbear $(1)/usr/bin/dropbearkey
154 $(INSTALL_DIR) $(1)/etc/config
155 $(INSTALL_CONF) ./files/dropbear.config $(1)/etc/config/dropbear
156 $(INSTALL_DIR) $(1)/etc/init.d
157 $(INSTALL_BIN) ./files/dropbear.init $(1)/etc/init.d/dropbear
158 $(INSTALL_DIR) $(1)/usr/lib/opkg/info
159 $(INSTALL_DIR) $(1)/etc/dropbear
160 $(if $(CONFIG_DROPBEAR_ECC),touch $(1)/etc/dropbear/dropbear_ecdsa_host_key)
161 touch $(1)/etc/dropbear/dropbear_rsa_host_key
162 endef
163
164 define Package/dropbearconvert/install
165 $(INSTALL_DIR) $(1)/usr/bin
166 $(INSTALL_BIN) $(PKG_BUILD_DIR)/dropbearconvert $(1)/usr/bin/dropbearconvert
167 endef
168
169 $(eval $(call BuildPackage,dropbear))
170 $(eval $(call BuildPackage,dropbearconvert))