Makefile 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  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. include $(INCLUDE_DIR)/package.mk
  31. ifneq ($(DUMP),1)
  32. STAMP_CONFIGURED:=$(strip $(STAMP_CONFIGURED))_$(shell echo $(CONFIG_TARGET_INIT_PATH) | $(MKHASH) md5)
  33. endif
  34. define Package/dropbear/Default
  35. URL:=http://matt.ucc.asn.au/dropbear/
  36. endef
  37. define Package/dropbear/config
  38. source "$(SOURCE)/Config.in"
  39. endef
  40. define Package/dropbear
  41. $(call Package/dropbear/Default)
  42. SECTION:=net
  43. CATEGORY:=Base system
  44. TITLE:=Small SSH2 client/server
  45. DEPENDS:= +DROPBEAR_ZLIB:zlib
  46. ALTERNATIVES:=
  47. $(if $(CONFIG_DROPBEAR_SCP),ALTERNATIVES+= \
  48. 100:/usr/bin/scp:/usr/sbin/dropbear,)
  49. $(if $(CONFIG_DROPBEAR_DBCLIENT),ALTERNATIVES+= \
  50. 100:/usr/bin/ssh:/usr/sbin/dropbear,)
  51. endef
  52. define Package/dropbear/description
  53. A small SSH2 server/client designed for small memory environments.
  54. endef
  55. define Package/dropbear/conffiles
  56. $(if $(CONFIG_DROPBEAR_ED25519),/etc/dropbear/dropbear_ed25519_host_key)
  57. $(if $(CONFIG_DROPBEAR_ECC),/etc/dropbear/dropbear_ecdsa_host_key)
  58. /etc/dropbear/dropbear_rsa_host_key
  59. /etc/config/dropbear
  60. endef
  61. define Package/dropbearconvert
  62. $(call Package/dropbear/Default)
  63. SECTION:=utils
  64. CATEGORY:=Utilities
  65. TITLE:=Utility for converting SSH keys
  66. DEPENDS:= +DROPBEAR_ZLIB:zlib
  67. endef
  68. CONFIGURE_ARGS += \
  69. --disable-pam \
  70. --enable-openpty \
  71. --enable-syslog \
  72. --disable-lastlog \
  73. --disable-utmpx \
  74. $(if $(CONFIG_DROPBEAR_UTMP),,--disable-utmp) \
  75. --disable-wtmp \
  76. --disable-wtmpx \
  77. --disable-loginfunc \
  78. $(if $(CONFIG_DROPBEAR_PUTUTLINE),,--disable-pututline) \
  79. --disable-pututxline \
  80. $(if $(CONFIG_DROPBEAR_ZLIB),,--disable-zlib) \
  81. --enable-bundled-libtom
  82. ##############################################################################
  83. #
  84. # option|value - add option to localoptions.h
  85. # !!option|value - replace option in sysoptions.h
  86. #
  87. ##############################################################################
  88. # remove protocol idented software version number:
  89. # - LOCAL_IDENT
  90. # disable legacy/unsafe methods and unused functionality:
  91. # - DROPBEAR_CLI_NETCAT
  92. # - DROPBEAR_DSS
  93. # - DO_MOTD
  94. DB_OPT_COMMON = \
  95. DEFAULT_PATH|"$(TARGET_INIT_PATH)" \
  96. !!LOCAL_IDENT|"SSH-2.0-dropbear" \
  97. DROPBEAR_CLI_NETCAT|0 \
  98. DROPBEAR_DSS|0 \
  99. DO_MOTD|0 \
  100. ##############################################################################
  101. #
  102. # option|config|enabled|disabled = add option to localoptions.h
  103. # !!option|config|enabled|disabled = replace option in sysoptions.h
  104. #
  105. # option := (config) ? enabled : disabled
  106. #
  107. ##############################################################################
  108. DB_OPT_CONFIG = \
  109. DROPBEAR_CURVE25519|CONFIG_DROPBEAR_CURVE25519|1|0 \
  110. DROPBEAR_ED25519|CONFIG_DROPBEAR_ED25519|1|0 \
  111. DROPBEAR_CHACHA20POLY1305|CONFIG_DROPBEAR_CHACHA20POLY1305|1|0 \
  112. DROPBEAR_ECDSA|CONFIG_DROPBEAR_ECC|1|0 \
  113. DROPBEAR_ECDH|CONFIG_DROPBEAR_ECC|1|0 \
  114. !!DROPBEAR_ECC_384|CONFIG_DROPBEAR_ECC_FULL|1|0 \
  115. !!DROPBEAR_ECC_521|CONFIG_DROPBEAR_ECC_FULL|1|0 \
  116. DROPBEAR_CLI_ASKPASS_HELPER|CONFIG_DROPBEAR_ASKPASS|1|0 \
  117. TARGET_CFLAGS += -DARGTYPE=3 -ffunction-sections -fdata-sections -flto
  118. TARGET_LDFLAGS += -Wl,--gc-sections -flto=jobserver
  119. db_opt_add =echo '\#define $(1) $(2)' >> $(PKG_BUILD_DIR)/localoptions.h
  120. db_opt_replace =$(ESED) 's,^(\#define $(1)) .*$$$$,\1 $(2),g' $(PKG_BUILD_DIR)/sysoptions.h
  121. define Build/Configure/dropbear_headers
  122. $(strip $(foreach s,$(DB_OPT_COMMON), \
  123. $(if $(filter !!%,$(word 1,$(subst |, ,$(s)))), \
  124. $(call db_opt_replace,$(patsubst !!%,%,$(word 1,$(subst |, ,$(s)))),$(word 2,$(subst |, ,$(s)))), \
  125. $(call db_opt_add,$(word 1,$(subst |, ,$(s))),$(word 2,$(subst |, ,$(s)))) \
  126. ) ; \
  127. ))
  128. $(strip $(foreach s,$(DB_OPT_CONFIG), \
  129. $(if $(filter !!%,$(word 1,$(subst |, ,$(s)))), \
  130. $(call db_opt_replace,$(patsubst !!%,%,$(word 1,$(subst |, ,$(s)))),$(if $($(word 2,$(subst |, ,$(s)))),$(word 3,$(subst |, ,$(s))),$(word 4,$(subst |, ,$(s))))), \
  131. $(call db_opt_add,$(word 1,$(subst |, ,$(s))),$(if $($(word 2,$(subst |, ,$(s)))),$(word 3,$(subst |, ,$(s))),$(word 4,$(subst |, ,$(s))))) \
  132. ) ; \
  133. ))
  134. endef
  135. define Build/Configure
  136. : > $(PKG_BUILD_DIR)/localoptions.h
  137. $(Build/Configure/Default)
  138. $(Build/Configure/dropbear_headers)
  139. # Enforce rebuild of svr-chansession.c
  140. rm -f $(PKG_BUILD_DIR)/svr-chansession.o
  141. # Rebuild them on config change
  142. +$(MAKE) -C $(PKG_BUILD_DIR)/libtomcrypt clean
  143. +$(MAKE) -C $(PKG_BUILD_DIR)/libtommath clean
  144. endef
  145. define Build/Compile
  146. +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
  147. $(TARGET_CONFIGURE_OPTS) \
  148. PROGRAMS="dropbear $(if $(CONFIG_DROPBEAR_DBCLIENT),dbclient,) dropbearkey $(if $(CONFIG_DROPBEAR_SCP),scp,)" \
  149. MULTI=1 SCPPROGRESS=1
  150. +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
  151. $(TARGET_CONFIGURE_OPTS) \
  152. PROGRAMS="dropbearconvert"
  153. endef
  154. define Package/dropbear/install
  155. $(INSTALL_DIR) $(1)/usr/sbin
  156. $(INSTALL_BIN) $(PKG_BUILD_DIR)/dropbearmulti $(1)/usr/sbin/dropbear
  157. $(INSTALL_DIR) $(1)/usr/bin
  158. $(if $(CONFIG_DROPBEAR_DBCLIENT),$(LN) ../sbin/dropbear $(1)/usr/bin/dbclient,)
  159. $(LN) ../sbin/dropbear $(1)/usr/bin/dropbearkey
  160. $(INSTALL_DIR) $(1)/etc/config
  161. $(INSTALL_CONF) ./files/dropbear.config $(1)/etc/config/dropbear
  162. $(INSTALL_DIR) $(1)/etc/init.d
  163. $(INSTALL_BIN) ./files/dropbear.init $(1)/etc/init.d/dropbear
  164. $(INSTALL_DIR) $(1)/usr/lib/opkg/info
  165. $(INSTALL_DIR) $(1)/etc/dropbear
  166. $(INSTALL_DIR) $(1)/lib/preinit
  167. $(INSTALL_DATA) ./files/dropbear.failsafe $(1)/lib/preinit/99_10_failsafe_dropbear
  168. $(if $(CONFIG_DROPBEAR_ED25519),touch $(1)/etc/dropbear/dropbear_ed25519_host_key)
  169. $(if $(CONFIG_DROPBEAR_ECC),touch $(1)/etc/dropbear/dropbear_ecdsa_host_key)
  170. touch $(1)/etc/dropbear/dropbear_rsa_host_key
  171. endef
  172. define Package/dropbearconvert/install
  173. $(INSTALL_DIR) $(1)/usr/bin
  174. $(INSTALL_BIN) $(PKG_BUILD_DIR)/dropbearconvert $(1)/usr/bin/dropbearconvert
  175. endef
  176. $(eval $(call BuildPackage,dropbear))
  177. $(eval $(call BuildPackage,dropbearconvert))