768cc813fa1f2664597cf78f1ea65336334a00ec
[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:=2019.77
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:=d91f78ebe633be1d071fd1b7e5535b9693794048b019e9f4bea257e1992b458d
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 /etc/dropbear/dropbear_rsa_host_key
65 /etc/config/dropbear
66 endef
67
68 define Package/dropbearconvert
69 $(call Package/dropbear/Default)
70 SECTION:=utils
71 CATEGORY:=Utilities
72 TITLE:=Utility for converting SSH keys
73 endef
74
75 CONFIGURE_ARGS += \
76 --disable-pam \
77 --enable-openpty \
78 --enable-syslog \
79 --disable-lastlog \
80 --disable-utmpx \
81 $(if $(CONFIG_DROPBEAR_UTMP),,--disable-utmp) \
82 --disable-wtmp \
83 --disable-wtmpx \
84 --disable-loginfunc \
85 $(if $(CONFIG_DROPBEAR_PUTUTLINE),,--disable-pututline) \
86 --disable-pututxline \
87 $(if $(CONFIG_DROPBEAR_ZLIB),,--disable-zlib) \
88 --enable-bundled-libtom
89
90 TARGET_CFLAGS += -DARGTYPE=3 -ffunction-sections -fdata-sections -flto
91 TARGET_LDFLAGS += -Wl,--gc-sections -flto=jobserver
92
93 define Build/Configure
94 : > $(PKG_BUILD_DIR)/localoptions.h
95
96 $(Build/Configure/Default)
97
98 echo '#define DEFAULT_PATH "$(TARGET_INIT_PATH)"' >> \
99 $(PKG_BUILD_DIR)/localoptions.h
100
101 echo '#define DROPBEAR_CURVE25519 $(if $(CONFIG_DROPBEAR_CURVE25519),1,0)' >> \
102 $(PKG_BUILD_DIR)/localoptions.h
103
104 for OPTION in DROPBEAR_ECDSA DROPBEAR_ECDH; do \
105 echo "#define $$$$OPTION $(if $(CONFIG_DROPBEAR_ECC),1,0)" >> \
106 $(PKG_BUILD_DIR)/localoptions.h; \
107 done
108
109 # remove protocol idented software version number
110 $(ESED) 's,^(#define LOCAL_IDENT) .*$$$$,\1 "SSH-2.0-dropbear",g' \
111 $(PKG_BUILD_DIR)/sysoptions.h
112
113 # disable legacy/unsafe methods and unused functionality
114 for OPTION in INETD_MODE DROPBEAR_CLI_NETCAT \
115 DROPBEAR_3DES DROPBEAR_DSS DROPBEAR_ENABLE_CBC_MODE \
116 DROPBEAR_SHA1_96_HMAC DROPBEAR_USE_PASSWORD_ENV; do \
117 echo "#define $$$$OPTION 0" >> \
118 $(PKG_BUILD_DIR)/localoptions.h; \
119 done
120
121 # Enforce rebuild of svr-chansession.c
122 rm -f $(PKG_BUILD_DIR)/svr-chansession.o
123 endef
124
125 define Build/Compile
126 +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
127 $(TARGET_CONFIGURE_OPTS) \
128 PROGRAMS="dropbear dbclient dropbearkey scp" \
129 MULTI=1 SCPPROGRESS=1
130 +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
131 $(TARGET_CONFIGURE_OPTS) \
132 PROGRAMS="dropbearconvert"
133 endef
134
135 define Package/dropbear/install
136 $(INSTALL_DIR) $(1)/usr/sbin
137 $(INSTALL_BIN) $(PKG_BUILD_DIR)/dropbearmulti $(1)/usr/sbin/dropbear
138 $(INSTALL_DIR) $(1)/usr/bin
139 $(LN) ../sbin/dropbear $(1)/usr/bin/dbclient
140 $(LN) ../sbin/dropbear $(1)/usr/bin/dropbearkey
141 $(INSTALL_DIR) $(1)/etc/config
142 $(INSTALL_CONF) ./files/dropbear.config $(1)/etc/config/dropbear
143 $(INSTALL_DIR) $(1)/etc/init.d
144 $(INSTALL_BIN) ./files/dropbear.init $(1)/etc/init.d/dropbear
145 $(INSTALL_DIR) $(1)/usr/lib/opkg/info
146 $(INSTALL_DIR) $(1)/etc/dropbear
147 touch $(1)/etc/dropbear/dropbear_rsa_host_key
148 endef
149
150 define Package/dropbearconvert/install
151 $(INSTALL_DIR) $(1)/usr/bin
152 $(INSTALL_BIN) $(PKG_BUILD_DIR)/dropbearconvert $(1)/usr/bin/dropbearconvert
153 endef
154
155 $(eval $(call BuildPackage,dropbear))
156 $(eval $(call BuildPackage,dropbearconvert))