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