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