Makefile 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. #
  2. # Copyright (c) 2018-2025 Nick Peng ([email protected])
  3. # This is free software, licensed under the GNU General Public License v3.
  4. #
  5. include $(TOPDIR)/rules.mk
  6. PKG_NAME:=smartdns
  7. PKG_VERSION:=1.2025.46.2
  8. PKG_RELEASE:=3
  9. PKG_SOURCE_PROTO:=git
  10. PKG_SOURCE_URL:=https://www.github.com/pymumu/smartdns.git
  11. PKG_SOURCE_VERSION:=64fc9f20fba0e14cb118fe7f145557971cafd858
  12. PKG_MIRROR_HASH:=skip
  13. SMARTDNS_WEBUI_VERSION:=1.0.0
  14. SMAETDNS_WEBUI_SOURCE_PROTO:=git
  15. SMARTDNS_WEBUI_SOURCE_URL:=https://github.com/pymumu/smartdns-webui.git
  16. SMARTDNS_WEBUI_SOURCE_VERSION:=35cbf4a1940f5dd32670c69bd5cc02437ad073e7
  17. SMARTDNS_WEBUI_FILE:=smartdns-webui-$(SMARTDNS_WEBUI_VERSION).tar.gz
  18. PKG_MAINTAINER:=Nick Peng <[email protected]>
  19. PKG_LICENSE:=GPL-3.0-or-later
  20. PKG_LICENSE_FILES:=LICENSE
  21. PKG_BUILD_PARALLEL:=1
  22. # node compile is slow, so do not use it, download node manually.
  23. # PACKAGE_smartdns-ui:node/host
  24. PKG_BUILD_DEPENDS:=PACKAGE_smartdns-ui:rust/host
  25. include ../../lang/rust/rust-package.mk
  26. include $(INCLUDE_DIR)/package.mk
  27. MAKE_VARS += VER=$(PKG_VERSION)
  28. MAKE_PATH:=src
  29. define Package/smartdns/default
  30. SECTION:=net
  31. CATEGORY:=Network
  32. SUBMENU:=IP Addresses and Names
  33. URL:=https://www.github.com/pymumu/smartdns/
  34. endef
  35. define Package/smartdns
  36. $(Package/smartdns/default)
  37. TITLE:=smartdns server
  38. DEPENDS:=+libpthread +libopenssl +libatomic
  39. endef
  40. define Package/smartdns/description
  41. SmartDNS is a local DNS server which accepts DNS query requests from local network clients,
  42. gets DNS query results from multiple upstream DNS servers concurrently, and returns the fastest IP to clients.
  43. Unlike dnsmasq's all-servers, smartdns returns the fastest IP, and encrypt DNS queries with DoT or DoH.
  44. endef
  45. define Package/smartdns/conffiles
  46. /etc/config/smartdns
  47. /etc/smartdns/address.conf
  48. /etc/smartdns/blacklist-ip.conf
  49. /etc/smartdns/custom.conf
  50. /etc/smartdns/domain-block.list
  51. /etc/smartdns/domain-forwarding.list
  52. endef
  53. define Package/smartdns/install
  54. $(INSTALL_DIR) $(1)/usr/sbin $(1)/etc/config $(1)/etc/init.d
  55. $(INSTALL_DIR) $(1)/etc/smartdns $(1)/etc/smartdns/domain-set $(1)/etc/smartdns/conf.d/
  56. $(INSTALL_BIN) $(PKG_BUILD_DIR)/src/smartdns $(1)/usr/sbin/smartdns
  57. $(INSTALL_BIN) $(PKG_BUILD_DIR)/package/openwrt/files/etc/init.d/smartdns $(1)/etc/init.d/smartdns
  58. $(INSTALL_CONF) $(PKG_BUILD_DIR)/package/openwrt/address.conf $(1)/etc/smartdns/address.conf
  59. $(INSTALL_CONF) $(PKG_BUILD_DIR)/package/openwrt/blacklist-ip.conf $(1)/etc/smartdns/blacklist-ip.conf
  60. $(INSTALL_CONF) $(PKG_BUILD_DIR)/package/openwrt/custom.conf $(1)/etc/smartdns/custom.conf
  61. $(INSTALL_CONF) $(PKG_BUILD_DIR)/package/openwrt/files/etc/config/smartdns $(1)/etc/config/smartdns
  62. endef
  63. define Package/smartdns-ui
  64. $(Package/smartdns/default)
  65. TITLE:=smartdns dashboard
  66. DEPENDS:=+smartdns $(RUST_ARCH_DEPENDS)
  67. endef
  68. define Package/smartdns-ui/description
  69. A dashboard ui for smartdns server.
  70. endef
  71. define Package/smartdns-ui/conffiles
  72. /etc/config/smartdns
  73. endef
  74. define Package/smartdns-ui/install
  75. $(INSTALL_DIR) $(1)/usr/lib
  76. $(INSTALL_DIR) $(1)/etc/smartdns/conf.d/
  77. $(INSTALL_DIR) $(1)/usr/share/smartdns/wwwroot
  78. $(INSTALL_BIN) $(PKG_BUILD_DIR)/plugin/smartdns-ui/target/smartdns_ui.so $(1)/usr/lib/smartdns_ui.so
  79. $(CP) $(PKG_BUILD_DIR)/smartdns-webui/out/* $(1)/usr/share/smartdns/wwwroot
  80. endef
  81. define Build/Compile/smartdns-webui
  82. which npm || (echo "npm not found, please install npm first" && exit 1)
  83. npm install --prefix $(PKG_BUILD_DIR)/smartdns-webui/
  84. npm run build --prefix $(PKG_BUILD_DIR)/smartdns-webui/
  85. endef
  86. define Build/Compile/smartdns-ui
  87. cargo install --force --locked bindgen-cli
  88. CARGO_BUILD_ARGS="$(if $(strip $(RUST_PKG_FEATURES)),--features "$(strip $(RUST_PKG_FEATURES))") --profile $(CARGO_PKG_PROFILE)"
  89. +$(CARGO_PKG_VARS) CARGO_BUILD_ARGS="$(CARGO_BUILD_ARGS)" CC=$(TARGET_CC) \
  90. PATH="$$(PATH):$(CARGO_HOME)/bin" \
  91. make -C $(PKG_BUILD_DIR)/plugin/smartdns-ui
  92. endef
  93. define Download/smartdns-webui
  94. FILE:=$(SMARTDNS_WEBUI_FILE)
  95. PROTO:=$(SMAETDNS_WEBUI_SOURCE_PROTO)
  96. URL:=$(SMARTDNS_WEBUI_SOURCE_URL)
  97. MIRROR_HASH:=b3f4f73b746ee169708f6504c52b33d9bbeb7c269b731bd7de4f61d0ad212d74
  98. VERSION:=$(SMARTDNS_WEBUI_SOURCE_VERSION)
  99. HASH:=$(SMARTDNS_WEBUI_HASH)
  100. SUBDIR:=smartdns-webui
  101. endef
  102. $(eval $(call Download,smartdns-webui))
  103. ifdef CONFIG_PACKAGE_smartdns-ui
  104. define Build/Prepare
  105. $(call Build/Prepare/Default)
  106. $(TAR) -C $(PKG_BUILD_DIR)/ -xf $(DL_DIR)/$(SMARTDNS_WEBUI_FILE)
  107. endef
  108. endif
  109. define Build/Compile
  110. $(call Build/Compile/Default,smartdns)
  111. ifdef CONFIG_PACKAGE_smartdns-ui
  112. $(call Build/Compile/smartdns-ui)
  113. $(call Build/Compile/smartdns-webui)
  114. endif
  115. endef
  116. $(eval $(call BuildPackage,smartdns))
  117. $(eval $(call RustBinPackage,smartdns-ui))
  118. $(eval $(call BuildPackage,smartdns-ui))