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