Makefile 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. #
  2. # Copyright (C) 2006-2020 OpenWrt.org
  3. #
  4. # This is free software, licensed under the GNU General Public License v2.
  5. # See /LICENSE for more information.
  6. #
  7. include $(TOPDIR)/rules.mk
  8. PKG_NAME:=dropbear
  9. PKG_VERSION:=2020.81
  10. PKG_RELEASE:=2
  11. PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
  12. PKG_SOURCE_URL:= \
  13. http://matt.ucc.asn.au/dropbear/releases/ \
  14. https://dropbear.nl/mirror/releases/
  15. PKG_HASH:=48235d10b37775dbda59341ac0c4b239b82ad6318c31568b985730c788aac53b
  16. PKG_LICENSE:=MIT
  17. PKG_LICENSE_FILES:=LICENSE libtomcrypt/LICENSE libtommath/LICENSE
  18. PKG_CPE_ID:=cpe:/a:matt_johnston:dropbear_ssh_server
  19. PKG_BUILD_PARALLEL:=1
  20. PKG_ASLR_PIE_REGULAR:=1
  21. PKG_USE_MIPS16:=0
  22. PKG_FIXUP:=autoreconf
  23. PKG_FLAGS:=nonshared
  24. PKG_CONFIG_DEPENDS:= \
  25. CONFIG_TARGET_INIT_PATH CONFIG_DROPBEAR_ECC CONFIG_DROPBEAR_ECC_FULL \
  26. CONFIG_DROPBEAR_CURVE25519 CONFIG_DROPBEAR_ZLIB \
  27. CONFIG_DROPBEAR_ED25519 CONFIG_DROPBEAR_CHACHA20POLY1305 \
  28. CONFIG_DROPBEAR_UTMP CONFIG_DROPBEAR_PUTUTLINE \
  29. CONFIG_DROPBEAR_DBCLIENT CONFIG_DROPBEAR_SCP CONFIG_DROPBEAR_ASKPASS \
  30. CONFIG_DROPBEAR_DBCLIENT_AGENTFORWARD CONFIG_DROPBEAR_AGENTFORWARD
  31. include $(INCLUDE_DIR)/package.mk
  32. ifneq ($(DUMP),1)
  33. STAMP_CONFIGURED:=$(strip $(STAMP_CONFIGURED))_$(shell echo $(CONFIG_TARGET_INIT_PATH) | $(MKHASH) md5)
  34. endif
  35. define Package/dropbear/Default
  36. URL:=http://matt.ucc.asn.au/dropbear/
  37. endef
  38. define Package/dropbear/config
  39. source "$(SOURCE)/Config.in"
  40. endef
  41. define Package/dropbear
  42. $(call Package/dropbear/Default)
  43. SECTION:=net
  44. CATEGORY:=Base system
  45. TITLE:=Small SSH2 client/server
  46. DEPENDS:= +DROPBEAR_ZLIB:zlib
  47. ALTERNATIVES:=
  48. $(if $(CONFIG_DROPBEAR_SCP),ALTERNATIVES+= \
  49. 100:/usr/bin/scp:/usr/sbin/dropbear,)
  50. $(if $(CONFIG_DROPBEAR_DBCLIENT),ALTERNATIVES+= \
  51. 100:/usr/bin/ssh:/usr/sbin/dropbear,)
  52. endef
  53. define Package/dropbear/description
  54. A small SSH2 server/client designed for small memory environments.
  55. endef
  56. define Package/dropbear/conffiles
  57. $(if $(CONFIG_DROPBEAR_ED25519),/etc/dropbear/dropbear_ed25519_host_key)
  58. $(if $(CONFIG_DROPBEAR_ECC),/etc/dropbear/dropbear_ecdsa_host_key)
  59. /etc/dropbear/dropbear_rsa_host_key
  60. /etc/config/dropbear
  61. endef
  62. define Package/dropbearconvert
  63. $(call Package/dropbear/Default)
  64. SECTION:=utils
  65. CATEGORY:=Utilities
  66. TITLE:=Utility for converting SSH keys
  67. DEPENDS:= +DROPBEAR_ZLIB:zlib
  68. endef
  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. #
  85. # option|value - add option to localoptions.h
  86. # !!option|value - replace option in sysoptions.h
  87. #
  88. ##############################################################################
  89. # remove protocol idented software version number:
  90. # - LOCAL_IDENT
  91. # disable legacy/unsafe methods and unused functionality:
  92. # - DROPBEAR_CLI_NETCAT
  93. # - DROPBEAR_DSS
  94. # - DO_MOTD
  95. DB_OPT_COMMON = \
  96. DEFAULT_PATH|"$(TARGET_INIT_PATH)" \
  97. !!LOCAL_IDENT|"SSH-2.0-dropbear" \
  98. DROPBEAR_CLI_NETCAT|0 \
  99. DROPBEAR_DSS|0 \
  100. DO_MOTD|0 \
  101. ##############################################################################
  102. #
  103. # option|config|enabled|disabled = add option to localoptions.h
  104. # !!option|config|enabled|disabled = replace option in sysoptions.h
  105. #
  106. # option := (config) ? enabled : disabled
  107. #
  108. ##############################################################################
  109. DB_OPT_CONFIG = \
  110. DROPBEAR_CURVE25519|CONFIG_DROPBEAR_CURVE25519|1|0 \
  111. DROPBEAR_ED25519|CONFIG_DROPBEAR_ED25519|1|0 \
  112. DROPBEAR_CHACHA20POLY1305|CONFIG_DROPBEAR_CHACHA20POLY1305|1|0 \
  113. DROPBEAR_ECDSA|CONFIG_DROPBEAR_ECC|1|0 \
  114. DROPBEAR_ECDH|CONFIG_DROPBEAR_ECC|1|0 \
  115. !!DROPBEAR_ECC_384|CONFIG_DROPBEAR_ECC_FULL|1|0 \
  116. !!DROPBEAR_ECC_521|CONFIG_DROPBEAR_ECC_FULL|1|0 \
  117. DROPBEAR_CLI_ASKPASS_HELPER|CONFIG_DROPBEAR_ASKPASS|1|0 \
  118. DROPBEAR_CLI_AGENTFWD|CONFIG_DROPBEAR_DBCLIENT_AGENTFORWARD|1|0 \
  119. DROPBEAR_SVR_AGENTFWD|CONFIG_DROPBEAR_AGENTFORWARD|1|0 \
  120. TARGET_CFLAGS += -DARGTYPE=3 -ffunction-sections -fdata-sections -flto
  121. TARGET_LDFLAGS += -Wl,--gc-sections -flto=jobserver
  122. db_opt_add =echo '\#define $(1) $(2)' >> $(PKG_BUILD_DIR)/localoptions.h
  123. db_opt_replace =$(ESED) 's,^(\#define $(1)) .*$$$$,\1 $(2),g' $(PKG_BUILD_DIR)/sysoptions.h
  124. define Build/Configure/dropbear_headers
  125. $(strip $(foreach s,$(DB_OPT_COMMON), \
  126. $(if $(filter !!%,$(word 1,$(subst |, ,$(s)))), \
  127. $(call db_opt_replace,$(patsubst !!%,%,$(word 1,$(subst |, ,$(s)))),$(word 2,$(subst |, ,$(s)))), \
  128. $(call db_opt_add,$(word 1,$(subst |, ,$(s))),$(word 2,$(subst |, ,$(s)))) \
  129. ) ; \
  130. ))
  131. $(strip $(foreach s,$(DB_OPT_CONFIG), \
  132. $(if $(filter !!%,$(word 1,$(subst |, ,$(s)))), \
  133. $(call db_opt_replace,$(patsubst !!%,%,$(word 1,$(subst |, ,$(s)))),$(if $($(word 2,$(subst |, ,$(s)))),$(word 3,$(subst |, ,$(s))),$(word 4,$(subst |, ,$(s))))), \
  134. $(call db_opt_add,$(word 1,$(subst |, ,$(s))),$(if $($(word 2,$(subst |, ,$(s)))),$(word 3,$(subst |, ,$(s))),$(word 4,$(subst |, ,$(s))))) \
  135. ) ; \
  136. ))
  137. endef
  138. define Build/Configure
  139. : > $(PKG_BUILD_DIR)/localoptions.h
  140. $(Build/Configure/Default)
  141. $(Build/Configure/dropbear_headers)
  142. # Enforce rebuild of svr-chansession.c
  143. rm -f $(PKG_BUILD_DIR)/svr-chansession.o
  144. # Rebuild them on config change
  145. +$(MAKE) -C $(PKG_BUILD_DIR)/libtomcrypt clean
  146. +$(MAKE) -C $(PKG_BUILD_DIR)/libtommath clean
  147. endef
  148. define Build/Compile
  149. +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
  150. $(TARGET_CONFIGURE_OPTS) \
  151. PROGRAMS="dropbear $(if $(CONFIG_DROPBEAR_DBCLIENT),dbclient,) dropbearkey $(if $(CONFIG_DROPBEAR_SCP),scp,)" \
  152. MULTI=1 SCPPROGRESS=1
  153. +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
  154. $(TARGET_CONFIGURE_OPTS) \
  155. PROGRAMS="dropbearconvert"
  156. endef
  157. define Package/dropbear/install
  158. $(INSTALL_DIR) $(1)/usr/sbin
  159. $(INSTALL_BIN) $(PKG_BUILD_DIR)/dropbearmulti $(1)/usr/sbin/dropbear
  160. $(INSTALL_DIR) $(1)/usr/bin
  161. $(if $(CONFIG_DROPBEAR_DBCLIENT),$(LN) ../sbin/dropbear $(1)/usr/bin/dbclient,)
  162. $(LN) ../sbin/dropbear $(1)/usr/bin/dropbearkey
  163. $(INSTALL_DIR) $(1)/etc/config
  164. $(INSTALL_CONF) ./files/dropbear.config $(1)/etc/config/dropbear
  165. $(INSTALL_DIR) $(1)/etc/init.d
  166. $(INSTALL_BIN) ./files/dropbear.init $(1)/etc/init.d/dropbear
  167. $(INSTALL_DIR) $(1)/usr/lib/opkg/info
  168. $(INSTALL_DIR) $(1)/etc/dropbear
  169. $(INSTALL_DIR) $(1)/lib/preinit
  170. $(INSTALL_DATA) ./files/dropbear.failsafe $(1)/lib/preinit/99_10_failsafe_dropbear
  171. $(if $(CONFIG_DROPBEAR_ED25519),touch $(1)/etc/dropbear/dropbear_ed25519_host_key)
  172. $(if $(CONFIG_DROPBEAR_ECC),touch $(1)/etc/dropbear/dropbear_ecdsa_host_key)
  173. touch $(1)/etc/dropbear/dropbear_rsa_host_key
  174. endef
  175. define Package/dropbearconvert/install
  176. $(INSTALL_DIR) $(1)/usr/bin
  177. $(INSTALL_BIN) $(PKG_BUILD_DIR)/dropbearconvert $(1)/usr/bin/dropbearconvert
  178. endef
  179. $(eval $(call BuildPackage,dropbear))
  180. $(eval $(call BuildPackage,dropbearconvert))