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