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