Makefile 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  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:=2017.75
  10. PKG_RELEASE:=9
  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:=6cbc1dcb1c9709d226dff669e5604172a18cf5dbf9a201474d5618ae4465098c
  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_USE_MIPS16:=0
  21. PKG_CONFIG_DEPENDS:= \
  22. CONFIG_TARGET_INIT_PATH CONFIG_DROPBEAR_ECC \
  23. CONFIG_DROPBEAR_CURVE25519 CONFIG_DROPBEAR_ZLIB \
  24. CONFIG_DROPBEAR_UTMP CONFIG_DROPBEAR_PUTUTLINE
  25. include $(INCLUDE_DIR)/package.mk
  26. ifneq ($(DUMP),1)
  27. STAMP_CONFIGURED:=$(strip $(STAMP_CONFIGURED))_$(shell echo $(CONFIG_TARGET_INIT_PATH) | mkhash md5)
  28. endif
  29. define Package/dropbear/Default
  30. URL:=http://matt.ucc.asn.au/dropbear/
  31. endef
  32. define Package/dropbear/config
  33. source "$(SOURCE)/Config.in"
  34. endef
  35. define Package/dropbear
  36. $(call Package/dropbear/Default)
  37. SECTION:=net
  38. CATEGORY:=Base system
  39. TITLE:=Small SSH2 client/server
  40. DEPENDS:= +DROPBEAR_ZLIB:zlib
  41. ALTERNATIVES:=\
  42. 100:/usr/bin/ssh:/usr/sbin/dropbear \
  43. 100:/usr/bin/scp:/usr/sbin/dropbear \
  44. endef
  45. define Package/dropbear/description
  46. A small SSH2 server/client designed for small memory environments.
  47. endef
  48. define Package/dropbear/conffiles
  49. /etc/dropbear/dropbear_rsa_host_key
  50. /etc/config/dropbear
  51. endef
  52. define Package/dropbearconvert
  53. $(call Package/dropbear/Default)
  54. SECTION:=utils
  55. CATEGORY:=Utilities
  56. TITLE:=Utility for converting SSH keys
  57. endef
  58. CONFIGURE_ARGS += \
  59. --disable-pam \
  60. --enable-openpty \
  61. --enable-syslog \
  62. --disable-lastlog \
  63. --disable-utmpx \
  64. $(if $(CONFIG_DROPBEAR_UTMP),,--disable-utmp) \
  65. --disable-wtmp \
  66. --disable-wtmpx \
  67. --disable-loginfunc \
  68. $(if $(CONFIG_DROPBEAR_PUTUTLINE),,--disable-pututline) \
  69. --disable-pututxline \
  70. $(if $(CONFIG_DROPBEAR_ZLIB),,--disable-zlib) \
  71. --enable-bundled-libtom
  72. TARGET_CFLAGS += -DARGTYPE=3 -ffunction-sections -fdata-sections -flto
  73. TARGET_LDFLAGS += -Wl,--gc-sections -flto=jobserver
  74. define Build/Configure
  75. $(Build/Configure/Default)
  76. $(SED) 's,^#define DEFAULT_PATH .*$$$$,#define DEFAULT_PATH "$(TARGET_INIT_PATH)",g' \
  77. $(PKG_BUILD_DIR)/options.h
  78. awk 'BEGIN { rc = 1 } \
  79. /'DROPBEAR_CURVE25519'/ { $$$$0 = "$(if $(CONFIG_DROPBEAR_CURVE25519),,// )#define 'DROPBEAR_CURVE25519'"; rc = 0 } \
  80. { print } \
  81. END { exit(rc) }' $(PKG_BUILD_DIR)/options.h \
  82. >$(PKG_BUILD_DIR)/options.h.new && \
  83. mv $(PKG_BUILD_DIR)/options.h.new $(PKG_BUILD_DIR)/options.h
  84. # Enforce that all replacements are made, otherwise options.h has changed
  85. # format and this logic is broken.
  86. for OPTION in DROPBEAR_ECDSA DROPBEAR_ECDH; do \
  87. awk 'BEGIN { rc = 1 } \
  88. /'$$$$OPTION'/ { $$$$0 = "$(if $(CONFIG_DROPBEAR_ECC),,// )#define '$$$$OPTION'"; rc = 0 } \
  89. { print } \
  90. END { exit(rc) }' $(PKG_BUILD_DIR)/options.h \
  91. >$(PKG_BUILD_DIR)/options.h.new && \
  92. mv $(PKG_BUILD_DIR)/options.h.new $(PKG_BUILD_DIR)/options.h || exit 1; \
  93. done
  94. # remove protocol idented software version number
  95. $(SED) 's,^#define LOCAL_IDENT .*$$$$,#define LOCAL_IDENT "SSH-2.0-dropbear",g' \
  96. $(PKG_BUILD_DIR)/sysoptions.h
  97. # Enforce rebuild of svr-chansession.c
  98. rm -f $(PKG_BUILD_DIR)/svr-chansession.o
  99. endef
  100. define Build/Compile
  101. +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
  102. $(TARGET_CONFIGURE_OPTS) \
  103. PROGRAMS="dropbear dbclient dropbearkey scp" \
  104. MULTI=1 SCPPROGRESS=1
  105. +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
  106. $(TARGET_CONFIGURE_OPTS) \
  107. PROGRAMS="dropbearconvert"
  108. endef
  109. define Package/dropbear/install
  110. $(INSTALL_DIR) $(1)/usr/sbin
  111. $(INSTALL_BIN) $(PKG_BUILD_DIR)/dropbearmulti $(1)/usr/sbin/dropbear
  112. $(INSTALL_DIR) $(1)/usr/bin
  113. $(LN) ../sbin/dropbear $(1)/usr/bin/dbclient
  114. $(LN) ../sbin/dropbear $(1)/usr/bin/dropbearkey
  115. $(INSTALL_DIR) $(1)/etc/config
  116. $(INSTALL_CONF) ./files/dropbear.config $(1)/etc/config/dropbear
  117. $(INSTALL_DIR) $(1)/etc/init.d
  118. $(INSTALL_BIN) ./files/dropbear.init $(1)/etc/init.d/dropbear
  119. $(INSTALL_DIR) $(1)/usr/lib/opkg/info
  120. $(INSTALL_DIR) $(1)/etc/dropbear
  121. touch $(1)/etc/dropbear/dropbear_rsa_host_key
  122. endef
  123. define Package/dropbearconvert/install
  124. $(INSTALL_DIR) $(1)/usr/bin
  125. $(INSTALL_BIN) $(PKG_BUILD_DIR)/dropbearconvert $(1)/usr/bin/dropbearconvert
  126. endef
  127. $(eval $(call BuildPackage,dropbear))
  128. $(eval $(call BuildPackage,dropbearconvert))