dropbear: make ssh compression support configurable
[openwrt/openwrt.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:=2017.75
12 PKG_RELEASE:=4
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:=6cbc1dcb1c9709d226dff669e5604172a18cf5dbf9a201474d5618ae4465098c
19
20 PKG_LICENSE:=MIT
21 PKG_LICENSE_FILES:=LICENSE libtomcrypt/LICENSE libtommath/LICENSE
22
23 PKG_BUILD_PARALLEL:=1
24 PKG_USE_MIPS16:=0
25
26 PKG_CONFIG_DEPENDS:=CONFIG_TARGET_INIT_PATH CONFIG_DROPBEAR_ECC CONFIG_DROPBEAR_CURVE25519 CONFIG_DROPBEAR_ZLIB
27
28 include $(INCLUDE_DIR)/package.mk
29
30 ifneq ($(DUMP),1)
31 STAMP_CONFIGURED:=$(strip $(STAMP_CONFIGURED))_$(shell echo $(CONFIG_TARGET_INIT_PATH) | mkhash md5)
32 endif
33
34 define Package/dropbear/Default
35 URL:=http://matt.ucc.asn.au/dropbear/
36 endef
37
38 define Package/dropbear/config
39 source "$(SOURCE)/Config.in"
40 endef
41
42 define Package/dropbear
43 $(call Package/dropbear/Default)
44 SECTION:=net
45 CATEGORY:=Base system
46 TITLE:=Small SSH2 client/server
47 DEPENDS:= +DROPBEAR_ZLIB:zlib
48 endef
49
50 define Package/dropbear/description
51 A small SSH2 server/client designed for small memory environments.
52 endef
53
54 define Package/dropbear/conffiles
55 /etc/dropbear/dropbear_rsa_host_key
56 /etc/config/dropbear
57 endef
58
59 define Package/dropbearconvert
60 $(call Package/dropbear/Default)
61 SECTION:=utils
62 CATEGORY:=Utilities
63 TITLE:=Utility for converting SSH keys
64 endef
65
66 CONFIGURE_ARGS += \
67 --disable-pam \
68 --enable-openpty \
69 --enable-syslog \
70 --disable-lastlog \
71 --disable-utmpx \
72 $(if $(CONFIG_DROPBEAR_UTMP),,--disable-utmp) \
73 --disable-wtmp \
74 --disable-wtmpx \
75 --disable-loginfunc \
76 $(if $(CONFIG_DROPBEAR_PUTUTLINE),,--disable-pututline) \
77 --disable-pututxline \
78 $(if $(CONFIG_DROPBEAR_ZLIB),,--disable-zlib) \
79 --enable-bundled-libtom
80
81 TARGET_CFLAGS += -DARGTYPE=3 -ffunction-sections -fdata-sections
82 TARGET_LDFLAGS += -Wl,--gc-sections
83
84 define Build/Configure
85 $(Build/Configure/Default)
86
87 $(SED) 's,^#define DEFAULT_PATH .*$$$$,#define DEFAULT_PATH "$(TARGET_INIT_PATH)",g' \
88 $(PKG_BUILD_DIR)/options.h
89
90 awk 'BEGIN { rc = 1 } \
91 /'DROPBEAR_CURVE25519'/ { $$$$0 = "$(if $(CONFIG_DROPBEAR_CURVE25519),,// )#define 'DROPBEAR_CURVE25519'"; rc = 0 } \
92 { print } \
93 END { exit(rc) }' $(PKG_BUILD_DIR)/options.h \
94 >$(PKG_BUILD_DIR)/options.h.new && \
95 mv $(PKG_BUILD_DIR)/options.h.new $(PKG_BUILD_DIR)/options.h
96
97 # Enforce that all replacements are made, otherwise options.h has changed
98 # format and this logic is broken.
99 for OPTION in DROPBEAR_ECDSA DROPBEAR_ECDH; do \
100 awk 'BEGIN { rc = 1 } \
101 /'$$$$OPTION'/ { $$$$0 = "$(if $(CONFIG_DROPBEAR_ECC),,// )#define '$$$$OPTION'"; rc = 0 } \
102 { print } \
103 END { exit(rc) }' $(PKG_BUILD_DIR)/options.h \
104 >$(PKG_BUILD_DIR)/options.h.new && \
105 mv $(PKG_BUILD_DIR)/options.h.new $(PKG_BUILD_DIR)/options.h || exit 1; \
106 done
107
108 # remove protocol idented software version number
109 $(SED) 's,^#define LOCAL_IDENT .*$$$$,#define LOCAL_IDENT "SSH-2.0-dropbear",g' \
110 $(PKG_BUILD_DIR)/sysoptions.h
111
112 # Enforce rebuild of svr-chansession.c
113 rm -f $(PKG_BUILD_DIR)/svr-chansession.o
114 endef
115
116 define Build/Compile
117 +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
118 $(TARGET_CONFIGURE_OPTS) \
119 PROGRAMS="dropbear dbclient dropbearkey scp" \
120 MULTI=1 SCPPROGRESS=1
121 +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
122 $(TARGET_CONFIGURE_OPTS) \
123 PROGRAMS="dropbearconvert"
124 endef
125
126 define Package/dropbear/install
127 $(INSTALL_DIR) $(1)/usr/sbin
128 $(INSTALL_BIN) $(PKG_BUILD_DIR)/dropbearmulti $(1)/usr/sbin/dropbear
129 $(INSTALL_DIR) $(1)/usr/bin
130 $(LN) ../sbin/dropbear $(1)/usr/bin/scp
131 $(LN) ../sbin/dropbear $(1)/usr/bin/ssh
132 $(LN) ../sbin/dropbear $(1)/usr/bin/dbclient
133 $(LN) ../sbin/dropbear $(1)/usr/bin/dropbearkey
134 $(INSTALL_DIR) $(1)/etc/config
135 $(INSTALL_DATA) ./files/dropbear.config $(1)/etc/config/dropbear
136 $(INSTALL_DIR) $(1)/etc/init.d
137 $(INSTALL_BIN) ./files/dropbear.init $(1)/etc/init.d/dropbear
138 $(INSTALL_DIR) $(1)/usr/lib/opkg/info
139 $(INSTALL_DIR) $(1)/etc/dropbear
140 touch $(1)/etc/dropbear/dropbear_rsa_host_key
141 endef
142
143 define Package/dropbearconvert/install
144 $(INSTALL_DIR) $(1)/usr/bin
145 $(INSTALL_BIN) $(PKG_BUILD_DIR)/dropbearconvert $(1)/usr/bin/dropbearconvert
146 endef
147
148 $(eval $(call BuildPackage,dropbear))
149 $(eval $(call BuildPackage,dropbearconvert))