Makefile 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  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. include $(TOPDIR)/rules.mk
  8. PKG_NAME:=dropbear
  9. PKG_VERSION:=2019.78
  10. PKG_RELEASE:=4
  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:=525965971272270995364a0eb01f35180d793182e63dd0b0c3eb0292291644a4
  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_CONFIG_DEPENDS:= \
  24. CONFIG_TARGET_INIT_PATH CONFIG_DROPBEAR_ECC CONFIG_DROPBEAR_ECC_FULL \
  25. CONFIG_DROPBEAR_CURVE25519 CONFIG_DROPBEAR_ZLIB \
  26. CONFIG_DROPBEAR_UTMP CONFIG_DROPBEAR_PUTUTLINE \
  27. CONFIG_DROPBEAR_DBCLIENT
  28. include $(INCLUDE_DIR)/package.mk
  29. ifneq ($(DUMP),1)
  30. STAMP_CONFIGURED:=$(strip $(STAMP_CONFIGURED))_$(shell echo $(CONFIG_TARGET_INIT_PATH) | mkhash md5)
  31. endif
  32. define Package/dropbear/Default
  33. URL:=http://matt.ucc.asn.au/dropbear/
  34. endef
  35. define Package/dropbear/config
  36. source "$(SOURCE)/Config.in"
  37. endef
  38. define Package/dropbear
  39. $(call Package/dropbear/Default)
  40. SECTION:=net
  41. CATEGORY:=Base system
  42. TITLE:=Small SSH2 client/server
  43. DEPENDS:= +DROPBEAR_ZLIB:zlib
  44. ALTERNATIVES:=\
  45. 100:/usr/bin/ssh:/usr/sbin/dropbear \
  46. 100:/usr/bin/scp:/usr/sbin/dropbear \
  47. endef
  48. define Package/dropbear/description
  49. A small SSH2 server/client designed for small memory environments.
  50. endef
  51. define Package/dropbear/conffiles
  52. $(if $(CONFIG_DROPBEAR_ECC),/etc/dropbear/dropbear_ecdsa_host_key)
  53. /etc/dropbear/dropbear_rsa_host_key
  54. /etc/config/dropbear
  55. endef
  56. define Package/dropbearconvert
  57. $(call Package/dropbear/Default)
  58. SECTION:=utils
  59. CATEGORY:=Utilities
  60. TITLE:=Utility for converting SSH keys
  61. DEPENDS:= +DROPBEAR_ZLIB:zlib
  62. endef
  63. CONFIGURE_ARGS += \
  64. --disable-pam \
  65. --enable-openpty \
  66. --enable-syslog \
  67. --disable-lastlog \
  68. --disable-utmpx \
  69. $(if $(CONFIG_DROPBEAR_UTMP),,--disable-utmp) \
  70. --disable-wtmp \
  71. --disable-wtmpx \
  72. --disable-loginfunc \
  73. $(if $(CONFIG_DROPBEAR_PUTUTLINE),,--disable-pututline) \
  74. --disable-pututxline \
  75. $(if $(CONFIG_DROPBEAR_ZLIB),,--disable-zlib) \
  76. --enable-bundled-libtom
  77. TARGET_CFLAGS += -DARGTYPE=3 -ffunction-sections -fdata-sections -flto
  78. TARGET_LDFLAGS += -Wl,--gc-sections -flto=jobserver
  79. define Build/Configure
  80. : > $(PKG_BUILD_DIR)/localoptions.h
  81. $(Build/Configure/Default)
  82. echo '#define DEFAULT_PATH "$(TARGET_INIT_PATH)"' >> \
  83. $(PKG_BUILD_DIR)/localoptions.h
  84. echo '#define DROPBEAR_CURVE25519 $(if $(CONFIG_DROPBEAR_CURVE25519),1,0)' >> \
  85. $(PKG_BUILD_DIR)/localoptions.h
  86. for OPTION in DROPBEAR_ECDSA DROPBEAR_ECDH; do \
  87. echo "#define $$$$OPTION $(if $(CONFIG_DROPBEAR_ECC),1,0)" >> \
  88. $(PKG_BUILD_DIR)/localoptions.h; \
  89. done
  90. # remove protocol idented software version number
  91. $(ESED) 's,^(#define LOCAL_IDENT) .*$$$$,\1 "SSH-2.0-dropbear",g' \
  92. $(PKG_BUILD_DIR)/sysoptions.h
  93. # disable legacy/unsafe methods and unused functionality
  94. for OPTION in INETD_MODE DROPBEAR_CLI_NETCAT \
  95. DROPBEAR_3DES DROPBEAR_DSS DROPBEAR_ENABLE_CBC_MODE \
  96. DROPBEAR_SHA1_96_HMAC DROPBEAR_USE_PASSWORD_ENV; do \
  97. echo "#define $$$$OPTION 0" >> \
  98. $(PKG_BUILD_DIR)/localoptions.h; \
  99. done
  100. # enable nistp384 and nistp521 only if full ECC support was requested
  101. for OPTION in DROPBEAR_ECC_384 DROPBEAR_ECC_521; do \
  102. $(ESED) 's,^(#define '$$$$OPTION') .*$$$$,\1 $(if $(CONFIG_DROPBEAR_ECC_FULL),1,0),g' \
  103. $(PKG_BUILD_DIR)/sysoptions.h; \
  104. done
  105. # Enforce rebuild of svr-chansession.c
  106. rm -f $(PKG_BUILD_DIR)/svr-chansession.o
  107. # Rebuild them on config change
  108. +$(MAKE) -C $(PKG_BUILD_DIR)/libtomcrypt clean
  109. +$(MAKE) -C $(PKG_BUILD_DIR)/libtommath clean
  110. endef
  111. define Build/Compile
  112. +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
  113. $(TARGET_CONFIGURE_OPTS) \
  114. PROGRAMS="dropbear $(if $(CONFIG_DROPBEAR_DBCLIENT),dbclient,) dropbearkey scp" \
  115. MULTI=1 SCPPROGRESS=1
  116. +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
  117. $(TARGET_CONFIGURE_OPTS) \
  118. PROGRAMS="dropbearconvert"
  119. endef
  120. define Package/dropbear/install
  121. $(INSTALL_DIR) $(1)/usr/sbin
  122. $(INSTALL_BIN) $(PKG_BUILD_DIR)/dropbearmulti $(1)/usr/sbin/dropbear
  123. $(INSTALL_DIR) $(1)/usr/bin
  124. $(if $(CONFIG_DROPBEAR_DBCLIENT),$(LN) ../sbin/dropbear $(1)/usr/bin/dbclient,)
  125. $(LN) ../sbin/dropbear $(1)/usr/bin/dropbearkey
  126. $(INSTALL_DIR) $(1)/etc/config
  127. $(INSTALL_CONF) ./files/dropbear.config $(1)/etc/config/dropbear
  128. $(INSTALL_DIR) $(1)/etc/init.d
  129. $(INSTALL_BIN) ./files/dropbear.init $(1)/etc/init.d/dropbear
  130. $(INSTALL_DIR) $(1)/usr/lib/opkg/info
  131. $(INSTALL_DIR) $(1)/etc/dropbear
  132. $(INSTALL_DIR) $(1)/lib/preinit
  133. $(INSTALL_DATA) ./files/dropbear.failsafe $(1)/lib/preinit/99_10_failsafe_dropbear
  134. $(if $(CONFIG_DROPBEAR_ECC),touch $(1)/etc/dropbear/dropbear_ecdsa_host_key)
  135. touch $(1)/etc/dropbear/dropbear_rsa_host_key
  136. endef
  137. define Package/dropbearconvert/install
  138. $(INSTALL_DIR) $(1)/usr/bin
  139. $(INSTALL_BIN) $(PKG_BUILD_DIR)/dropbearconvert $(1)/usr/bin/dropbearconvert
  140. endef
  141. $(eval $(call BuildPackage,dropbear))
  142. $(eval $(call BuildPackage,dropbearconvert))