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