4515165ad428480f346fe2832b6182db7cd25d3f
[15.05/openwrt.git] / package / network / services / dropbear / Makefile
1 #
2 # Copyright (C) 2006-2014 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:=2015.68
12 PKG_RELEASE:=3
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_MD5SUM:=7664ac10f7cc2301c530eb80c756fc5d
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_DROPBEAR_ECC
27
28 include $(INCLUDE_DIR)/package.mk
29
30 define Package/dropbear/Default
31   URL:=http://matt.ucc.asn.au/dropbear/
32 endef
33
34 define Package/dropbear/config
35         source "$(SOURCE)/Config.in"
36 endef
37
38 define Package/dropbear
39   $(call Package/dropbear/Default)
40   SECTION:=net
41   CATEGORY:=Base system
42   TITLE:=Small SSH2 client/server
43 endef
44
45 define Package/dropbear/description
46  A small SSH2 server/client designed for small memory environments.
47 endef
48
49 define Package/dropbear/conffiles
50 /etc/dropbear/dropbear_rsa_host_key
51 /etc/config/dropbear 
52 endef
53
54 define Package/dropbearconvert
55   $(call Package/dropbear/Default)
56   SECTION:=utils
57   CATEGORY:=Utilities
58   TITLE:=Utility for converting SSH keys
59 endef
60
61 CONFIGURE_ARGS += \
62         --disable-pam \
63         --enable-openpty \
64         --enable-syslog \
65         $(if $(CONFIG_SHADOW_PASSWORDS),,--disable-shadow) \
66         --disable-lastlog \
67         --disable-utmp \
68         --disable-utmpx \
69         --disable-wtmp \
70         --disable-wtmpx \
71         --disable-loginfunc \
72         --disable-pututline \
73         --disable-pututxline \
74         --disable-zlib \
75         --enable-bundled-libtom
76
77 TARGET_CFLAGS += -DARGTYPE=3 -ffunction-sections -fdata-sections
78 TARGET_LDFLAGS += -Wl,--gc-sections
79
80 define Build/Configure
81         $(Build/Configure/Default)
82
83         # Enforce that all replacements are made, otherwise options.h has changed
84         # format and this logic is broken.
85         for OPTION in DROPBEAR_ECDSA DROPBEAR_ECDH DROPBEAR_CURVE25519; do \
86           awk 'BEGIN { rc = 1 } \
87                /'$$$$OPTION'/ { $$$$0 = "$(if $(CONFIG_DROPBEAR_ECC),,// )#define '$$$$OPTION'"; rc = 0 } \
88                { print } \
89                END { exit(rc) }' $(PKG_BUILD_DIR)/options.h \
90                >$(PKG_BUILD_DIR)/options.h.new && \
91           mv $(PKG_BUILD_DIR)/options.h.new $(PKG_BUILD_DIR)/options.h || exit 1; \
92         done
93 endef
94
95 define Build/Compile
96         +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
97                 $(TARGET_CONFIGURE_OPTS) \
98                 PROGRAMS="dropbear dbclient dropbearkey scp" \
99                 MULTI=1 SCPPROGRESS=1
100         +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
101                 $(TARGET_CONFIGURE_OPTS) \
102                 PROGRAMS="dropbearconvert"
103 endef
104
105 define Package/dropbear/install
106         $(INSTALL_DIR) $(1)/usr/sbin
107         $(INSTALL_BIN) $(PKG_BUILD_DIR)/dropbearmulti $(1)/usr/sbin/dropbear
108         $(INSTALL_DIR) $(1)/usr/bin
109         $(LN) ../sbin/dropbear $(1)/usr/bin/scp
110         $(LN) ../sbin/dropbear $(1)/usr/bin/ssh
111         $(LN) ../sbin/dropbear $(1)/usr/bin/dbclient
112         $(LN) ../sbin/dropbear $(1)/usr/bin/dropbearkey
113         $(INSTALL_DIR) $(1)/etc/config
114         $(INSTALL_DATA) ./files/dropbear.config $(1)/etc/config/dropbear
115         $(INSTALL_DIR) $(1)/etc/init.d
116         $(INSTALL_BIN) ./files/dropbear.init $(1)/etc/init.d/dropbear
117         $(INSTALL_DIR) $(1)/usr/lib/opkg/info
118         $(INSTALL_DIR) $(1)/etc/dropbear
119         touch $(1)/etc/dropbear/dropbear_rsa_host_key
120 endef
121
122 define Package/dropbearconvert/install
123         $(INSTALL_DIR) $(1)/usr/bin
124         $(INSTALL_BIN) $(PKG_BUILD_DIR)/dropbearconvert $(1)/usr/bin/dropbearconvert
125 endef
126
127 $(eval $(call BuildPackage,dropbear))
128 $(eval $(call BuildPackage,dropbearconvert))