Makefile 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  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. # - INETD_MODE
  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. INETD_MODE|0 \
  99. DROPBEAR_CLI_NETCAT|0 \
  100. DROPBEAR_DSS|0 \
  101. DO_MOTD|0 \
  102. ##############################################################################
  103. #
  104. # option|config|enabled|disabled = add option to localoptions.h
  105. # !!option|config|enabled|disabled = replace option in sysoptions.h
  106. #
  107. # option := (config) ? enabled : disabled
  108. #
  109. ##############################################################################
  110. DB_OPT_CONFIG = \
  111. DROPBEAR_CURVE25519|CONFIG_DROPBEAR_CURVE25519|1|0 \
  112. DROPBEAR_ED25519|CONFIG_DROPBEAR_ED25519|1|0 \
  113. DROPBEAR_CHACHA20POLY1305|CONFIG_DROPBEAR_CHACHA20POLY1305|1|0 \
  114. DROPBEAR_ECDSA|CONFIG_DROPBEAR_ECC|1|0 \
  115. DROPBEAR_ECDH|CONFIG_DROPBEAR_ECC|1|0 \
  116. !!DROPBEAR_ECC_384|CONFIG_DROPBEAR_ECC_FULL|1|0 \
  117. !!DROPBEAR_ECC_521|CONFIG_DROPBEAR_ECC_FULL|1|0 \
  118. DROPBEAR_CLI_ASKPASS_HELPER|CONFIG_DROPBEAR_ASKPASS|1|0 \
  119. TARGET_CFLAGS += -DARGTYPE=3 -ffunction-sections -fdata-sections -flto
  120. TARGET_LDFLAGS += -Wl,--gc-sections -flto=jobserver
  121. db_opt_add =echo '\#define $(1) $(2)' >> $(PKG_BUILD_DIR)/localoptions.h
  122. db_opt_replace =$(ESED) 's,^(\#define $(1)) .*$$$$,\1 $(2),g' $(PKG_BUILD_DIR)/sysoptions.h
  123. define Build/Configure/dropbear_headers
  124. $(strip $(foreach s,$(DB_OPT_COMMON), \
  125. $(if $(filter !!%,$(word 1,$(subst |, ,$(s)))), \
  126. $(call db_opt_replace,$(patsubst !!%,%,$(word 1,$(subst |, ,$(s)))),$(word 2,$(subst |, ,$(s)))), \
  127. $(call db_opt_add,$(word 1,$(subst |, ,$(s))),$(word 2,$(subst |, ,$(s)))) \
  128. ) ; \
  129. ))
  130. $(strip $(foreach s,$(DB_OPT_CONFIG), \
  131. $(if $(filter !!%,$(word 1,$(subst |, ,$(s)))), \
  132. $(call db_opt_replace,$(patsubst !!%,%,$(word 1,$(subst |, ,$(s)))),$(if $($(word 2,$(subst |, ,$(s)))),$(word 3,$(subst |, ,$(s))),$(word 4,$(subst |, ,$(s))))), \
  133. $(call db_opt_add,$(word 1,$(subst |, ,$(s))),$(if $($(word 2,$(subst |, ,$(s)))),$(word 3,$(subst |, ,$(s))),$(word 4,$(subst |, ,$(s))))) \
  134. ) ; \
  135. ))
  136. endef
  137. define Build/Configure
  138. : > $(PKG_BUILD_DIR)/localoptions.h
  139. $(Build/Configure/Default)
  140. $(Build/Configure/dropbear_headers)
  141. # Enforce rebuild of svr-chansession.c
  142. rm -f $(PKG_BUILD_DIR)/svr-chansession.o
  143. # Rebuild them on config change
  144. +$(MAKE) -C $(PKG_BUILD_DIR)/libtomcrypt clean
  145. +$(MAKE) -C $(PKG_BUILD_DIR)/libtommath clean
  146. endef
  147. define Build/Compile
  148. +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
  149. $(TARGET_CONFIGURE_OPTS) \
  150. PROGRAMS="dropbear $(if $(CONFIG_DROPBEAR_DBCLIENT),dbclient,) dropbearkey $(if $(CONFIG_DROPBEAR_SCP),scp,)" \
  151. MULTI=1 SCPPROGRESS=1
  152. +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
  153. $(TARGET_CONFIGURE_OPTS) \
  154. PROGRAMS="dropbearconvert"
  155. endef
  156. define Package/dropbear/install
  157. $(INSTALL_DIR) $(1)/usr/sbin
  158. $(INSTALL_BIN) $(PKG_BUILD_DIR)/dropbearmulti $(1)/usr/sbin/dropbear
  159. $(INSTALL_DIR) $(1)/usr/bin
  160. $(if $(CONFIG_DROPBEAR_DBCLIENT),$(LN) ../sbin/dropbear $(1)/usr/bin/dbclient,)
  161. $(LN) ../sbin/dropbear $(1)/usr/bin/dropbearkey
  162. $(INSTALL_DIR) $(1)/etc/config
  163. $(INSTALL_CONF) ./files/dropbear.config $(1)/etc/config/dropbear
  164. $(INSTALL_DIR) $(1)/etc/init.d
  165. $(INSTALL_BIN) ./files/dropbear.init $(1)/etc/init.d/dropbear
  166. $(INSTALL_DIR) $(1)/usr/lib/opkg/info
  167. $(INSTALL_DIR) $(1)/etc/dropbear
  168. $(INSTALL_DIR) $(1)/lib/preinit
  169. $(INSTALL_DATA) ./files/dropbear.failsafe $(1)/lib/preinit/99_10_failsafe_dropbear
  170. $(if $(CONFIG_DROPBEAR_ED25519),touch $(1)/etc/dropbear/dropbear_ed25519_host_key)
  171. $(if $(CONFIG_DROPBEAR_ECC),touch $(1)/etc/dropbear/dropbear_ecdsa_host_key)
  172. touch $(1)/etc/dropbear/dropbear_rsa_host_key
  173. endef
  174. define Package/dropbearconvert/install
  175. $(INSTALL_DIR) $(1)/usr/bin
  176. $(INSTALL_BIN) $(PKG_BUILD_DIR)/dropbearconvert $(1)/usr/bin/dropbearconvert
  177. endef
  178. $(eval $(call BuildPackage,dropbear))
  179. $(eval $(call BuildPackage,dropbearconvert))