Based on OpenWrt suricata package works by @Grommish , At first compilation are going through but suddenly I am stuck at probably “rustc” is not being found when compiling suricata 7 :
)
OpenWrt-libtool: link: (cd .libs/libhtp.lax/liblzma-c.a && x86_64-openwrt-linux-gnu-gcc-ar x "/home/username/works/openwrt/build_dir/target-x86_64_glibc_custom/suricata-7.0.2/libhtp/htp/lzma/.libs/liblzma-c.a")
OpenWrt-libtool: link: x86_64-openwrt-linux-gnu-gcc-ar cr .libs/libhtp.a .libs/libhtp.lax/libhtp-c.a/bstr.o .libs/libhtp.lax/libhtp-c.a/bstr_builder.o .libs/libhtp.lax/libhtp-c.a/htp_base64.o .libs/libhtp.lax/libhtp-c.a/htp_config.o .libs/libhtp.lax/libhtp-c.a/htp_connection.o .libs/libhtp.lax/libhtp-c.a/htp_connection_parser.o .libs/libhtp.lax/libhtp-c.a/htp_content_handlers.o .libs/libhtp.lax/libhtp-c.a/htp_cookies.o .libs/libhtp.lax/libhtp-c.a/htp_decompressors.o .libs/libhtp.lax/libhtp-c.a/htp_hooks.o .libs/libhtp.lax/libhtp-c.a/htp_list.o .libs/libhtp.lax/libhtp-c.a/htp_multipart.o .libs/libhtp.lax/libhtp-c.a/htp_parsers.o .libs/libhtp.lax/libhtp-c.a/htp_php.o .libs/libhtp.lax/libhtp-c.a/htp_request.o .libs/libhtp.lax/libhtp-c.a/htp_request_apache_2_2.o .libs/libhtp.lax/libhtp-c.a/htp_request_generic.o .libs/libhtp.lax/libhtp-c.a/htp_request_parsers.o .libs/libhtp.lax/libhtp-c.a/htp_response.o .libs/libhtp.lax/libhtp-c.a/htp_response_generic.o .libs/libhtp.lax/libhtp-c.a/htp_table.o .libs/libhtp.lax/libhtp-c.a/htp_transaction.o .libs/libhtp.lax/libhtp-c.a/htp_transcoder.o .libs/libhtp.lax/libhtp-c.a/htp_urlencoded.o .libs/libhtp.lax/libhtp-c.a/htp_utf8_decoder.o .libs/libhtp.lax/libhtp-c.a/htp_util.o .libs/libhtp.lax/libhtp-c.a/strlcat.o .libs/libhtp.lax/libhtp-c.a/strlcpy.o .libs/libhtp.lax/liblzma-c.a/LzFind.o .libs/libhtp.lax/liblzma-c.a/LzmaDec.o
OpenWrt-libtool: link: x86_64-openwrt-linux-gnu-gcc-ranlib .libs/libhtp.a
OpenWrt-libtool: link: rm -fr .libs/libhtp.lax
OpenWrt-libtool: link: ( cd ".libs" && rm -f "libhtp.la" && ln -s "../libhtp.la" "libhtp.la" )
make[7]: Leaving directory '/home/username/works/openwrt/build_dir/target-x86_64_glibc_custom/suricata-7.0.2/libhtp/htp'
make[6]: Leaving directory '/home/username/works/openwrt/build_dir/target-x86_64_glibc_custom/suricata-7.0.2/libhtp/htp'
Making all in test
make[6]: Entering directory '/home/username/works/openwrt/build_dir/target-x86_64_glibc_custom/suricata-7.0.2/libhtp/test'
make[6]: Nothing to be done for 'all'.
make[6]: Leaving directory '/home/username/works/openwrt/build_dir/target-x86_64_glibc_custom/suricata-7.0.2/libhtp/test'
Making all in docs
make[6]: Entering directory '/home/username/works/openwrt/build_dir/target-x86_64_glibc_custom/suricata-7.0.2/libhtp/docs'
make[6]: Nothing to be done for 'all'.
make[6]: Leaving directory '/home/username/works/openwrt/build_dir/target-x86_64_glibc_custom/suricata-7.0.2/libhtp/docs'
make[6]: Entering directory '/home/username/works/openwrt/build_dir/target-x86_64_glibc_custom/suricata-7.0.2/libhtp'
make[6]: Leaving directory '/home/username/works/openwrt/build_dir/target-x86_64_glibc_custom/suricata-7.0.2/libhtp'
make[5]: Leaving directory '/home/username/works/openwrt/build_dir/target-x86_64_glibc_custom/suricata-7.0.2/libhtp'
make[4]: Leaving directory '/home/username/works/openwrt/build_dir/target-x86_64_glibc_custom/suricata-7.0.2/libhtp'
Making all in rust
make[4]: Entering directory '/home/username/works/openwrt/build_dir/target-x86_64_glibc_custom/suricata-7.0.2/rust'
\
CARGO_HOME="/home/username/works/openwrt/staging_dir/target-x86_64_glibc_custom/host/cargo" \
CARGO_TARGET_DIR="/home/username/works/openwrt/build_dir/target-x86_64_glibc_custom/suricata-7.0.2/rust/target" \
/home/username/works/openwrt/staging_dir/target-x86_64_glibc_custom/host/cargo/bin/cargo build \
--features "lua debug "
warning: Both `/home/username/works/openwrt/staging_dir/target-x86_64_glibc_custom/host/cargo/config` and `/home/username/works/openwrt/staging_dir/target-x86_64_glibc_custom/host/cargo/config.toml` exist. Using `/home/username/works/openwrt/staging_dir/target-x86_64_glibc_custom/host/cargo/config`
error: could not execute process `rustc -vV` (never executed)
Caused by:
No such file or directory (os error 2)
make[4]: *** [Makefile:545: all-local] Error 101
make[4]: Leaving directory '/home/username/works/openwrt/build_dir/target-x86_64_glibc_custom/suricata-7.0.2/rust'
make[3]: *** [Makefile:491: all-recursive] Error 1
make[3]: Leaving directory '/home/username/works/openwrt/build_dir/target-x86_64_glibc_custom/suricata-7.0.2'
make[2]: *** [Makefile:188: /home/username/works/openwrt/build_dir/target-x86_64_glibc_custom/suricata-7.0.2/.built] Error 2
make[2]: Leaving directory '/home/username/works/openwrt/feeds/packages/net/suricata'
time: package/feeds/packages/suricata/compile#58.37#39.06#100.12
ERROR: package/feeds/packages/suricata failed to build.
make[1]: *** [package/Makefile:120: package/feeds/packages/suricata/compile] Error 1
make[1]: Leaving directory '/home/username/works/openwrt'
make: *** [/home/username/works/openwrt/include/toplevel.mk:232: package/suricata/compile] Error 2
While in my config.log , rustc & cargo is already being detected and found :
configure:29779: checking for rustc
configure:29815: result: /home/username/works/openwrt/staging_dir/target-x86_64_glibc_custom/host/cargo/bin/rustc
configure:29838: checking for cargo
configure:29874: result: /home/username/works/openwrt/staging_dir/target-x86_64_glibc_custom/host/cargo/bin/cargo
configure:29907: checking for Rust version 1.63.0 or newer
configure:29925: result: yes
My Suricata 7 OpenWrt Makefile :
# SPDX-License-Identifier: GPL-2.0-only
include $(TOPDIR)/rules.mk
PKG_NAME:=suricata
PKG_VERSION:=7.0.2
PKG_RELEASE:=1
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL=https://github.com/OISF/suricata.git
PKG_SOURCE_DATE:=2023-08-30
PKG_SOURCE_VERSION:=af4bb917dc9842229445683b5ce2f955faa464c2
PKG_FIXUP:=autoreconf
#PKG_REMOVE_FILES:=autogen.sh
PKG_FIXUP:=patch-libtool
PKG_BUILD_DEPENDS:=rust/host python3/host
include $(INCLUDE_DIR)/package.mk
include ../../lang/rust/rust-values.mk
PKG_CONFIG_DEPENDS:= \
CONFIG_SURICATA_ENABLE_LUAJIT \
CONFIG_SURICATA_ENABLE_PYTON \
CONFIG_SURICATA_ENABLE_GCCPROTECT \
CONFIG_SURICATA_ENABLE_GCCPROFILE \
CONFIG_SURICATA_ENABLE_PROFILING \
CONFIG_SURICATA_ENABLE_NFQUEUE \
CONFIG_SURICATA_ENABLE_NFLOG \
CONFIG_SURICATA_ENABLE_GEOIP \
CONFIG_SURICATA_ENABLE_LIBMAGIC \
CONFIG_SURICATA_ENABLE_DEBUG \
CONFIG_SURICATA_ENABLE_HIREDIS \
CONFIG_SURICATA_ENABLE_EBPF \
define Package/suricata/config
source "$(SOURCE)/Config.in"
endef
CONFIGURE_VARS += \
CARGO_HOME="$(STAGING_DIR)/host/cargo" \
CLANG="$(STAGING_DIR_HOST)/llvm-bpf/bin/clang" \
LLC="$(STAGING_DIR_HOST)/llvm-bpf/bin/llc" \
ac_cv_path_CARGO="$(STAGING_DIR)/host/cargo/bin/cargo" \
ac_cv_path_RUSTC="$(STAGING_DIR)/host/cargo/bin/rustc" \
ac_cv_path_CBINDGEN="$(STAGING_DIR)/host/cargo/bin/cbindgen"\
CONFIGURE_ARGS += \
--target=$(RUSTC_TARGET_ARCH) \
--host=$(RUSTC_TARGET_ARCH) \
--build=$(RUSTC_HOST_ARCH) \
--enable-shared \
--disable-gccmarch-native \
--with-gnu-ld \
--with-sysroot=$(STAGING_DIR_HOST)
# --enable-non-bundled-htp \
# --with-libhtp-includes=$(STAGING_DIR_HOSTPKG)/include \
# --with-libhtp-libraries=$(STAGING_DIR_HOSTPKG)/lib
# --with-sysroot=$(TOOLCHAIN_DIR)
ifeq ($(CONFIG_SURICATA_ENABLE_PYTHON),y)
CONFIGURE_ARGS += --enable-python
endif
ifeq ($(CONFIG_SURICATA_ENABLE_LUAJIT),y)
CONFIGURE_ARGS += --enable-luajit
endif
ifeq ($(CONFIG_SURICATA_ENABLE_GCCPROTECT),y)
CONFIGURE_ARGS += --enable-gccprotect
endif
ifeq ($(CONFIG_SURICATA_ENABLE_GCCPROFILE),y)
CONFIGURE_ARGS += --enable-gccprofile
endif
# For now, x86_64 targets can't use PIE
ifneq ($(CONFIG_TARGET_x86),y)
ifeq ($(CONFIG_PKG_ASLR_PIE_ALL),y)
CONFIGURE_ARGS += --enable-pie
else
ifeq ($(CONFIG_PKG_ASLR_PIE_REGULAR),y)
CONFIGURE_ARGS += --enable-pie
endif
endif
endif
ifeq ($(CONFIG_SURICATA_ENABLE_NFQUEUE),y)
CONFIGURE_ARGS += --enable-nfqueue
endif
ifeq ($(CONFIG_SURICATA_ENABLE_GEOIP),y)
CONFIGURE_ARGS += --enable-geoip
endif
ifeq ($(CONFIG_SURICATA_ENABLE_LIBMAGIC),n)
CONFIGURE_ARGS += --disable-libmagic
endif
ifeq ($(CONFIG_SURICATA_ENABLE_DEBUG),y)
TARGET_CXXFLAGS += -ggdb3
CONFIGURE_ARGS += --enable-debug
endif
ifeq ($(CONFIG_SURICATA_ENABLE_HIREDIS),y)
CONFIGURE_ARGS += --enable-hiredis
endif
ifeq ($(CONFIG_SURICATA_ENABLE_EBPF),y)
CONFIGURE_ARGS += --enable-ebpf-build
endif
ifeq ($(CONFIG_SURICATA_ENABLE_NFLOG),y)
CONFIGURE_ARGS += --enable-nflog
endif
define Build/Prepare
$(call Build/Prepare/Default)
( \
export PATH="$(CARGO_HOME)/bin:$(STAGING_DIR_HOST)/llvm-bpf/bin:$(PATH)" ; \
export CARGO_HOME:=$(STAGING_DIR)/host/cargo ; \
cd $(PKG_BUILD_DIR) ; \
git clone https://github.com/OISF/libhtp.git ; \
$(CONFIGURE_VARS) cargo install --root=$(CARGO_HOME) cbindgen ; \
cd $(PKG_BUILD_DIR) && $(CONFIGURE_VARS) ./autogen.sh ; \
)
endef
define Package/suricata
SUBMENU:=Firewall
SECTION:=net
CATEGORY:=Network
DEPENDS:=@!SMALL_FLASH @!LOW_MEMORY_FOOTPRINT +libexpat +jansson +libelf +libbpf +libbsd +libpcre +libyaml +libpcap +libcap-ng \
+nspr +libnss +liblz4 +libatomic +libnet-1.2.x \
+CONFIG_SURICATA_ENABLE_NFLOG:libnetfilter-log \
+CONFIG_SURICATA_ENABLE_NFQUEUE:libnetfilter-queue +CONFIG_SURICATA_ENABLE_NFQUEUE:iptables-mod-nfqueue \
+CONFIG_SURICATA_ENABLE_HIREDIS:libhiredis +CONFIG_SURICATA_ENABLE_HIREDIS:libevent2 \
+CONFIG_SURICATA_ENABLE_LIBMAGIC:file \
+CONFIG_SURICATA_ENABLE_GEOIP:libmaxminddb \
+CONFIG_SURICATA_ENABLE_PYTHON:python3 +CONFIG_SURICATA_ENABLE_PYTHON:python3-yaml \
@HAS_LUAJIT_ARCH +luajit
TITLE:=OISF Suricata IDS
URL:=https://www.openinfosecfoundation.org/
MENU:=1
endef
define Package/suricata/description
Suricata is an open source-based intrusion detection system (IDS), intrusion
prevention system (IPS), and Network Monitoring System (NMS)
endef
define Package/suricata/conffiles
/etc/config/suricata
/etc/suricata/
endef
define Package/suricata/install
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/suricata $(1)/usr/bin/suricata
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/suricatactl $(1)/usr/bin/suricatactl
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/suricatasc $(1)/usr/bin/suricatasc
$(INSTALL_DIR) $(1)/usr/lib
$(CP) -r $(PKG_INSTALL_DIR)/usr/lib/* $(1)/usr/lib/
$(INSTALL_DIR) $(1)/usr/include
$(CP) -r $(PKG_INSTALL_DIR)/usr/include/* $(1)/usr/include/
$(INSTALL_DIR) $(1)/etc/suricata
$(CP) $(PKG_BUILD_DIR)/suricata.yaml \
$(PKG_BUILD_DIR)/etc/classification.config \
$(PKG_BUILD_DIR)/threshold.config \
$(PKG_BUILD_DIR)/etc/reference.config \
$(1)/etc/suricata/
$(INSTALL_DIR) $(1)/usr/share/suricata/rules
$(CP) $(PKG_INSTALL_DIR)/usr/share/suricata/rules/* $(1)/usr/share/suricata/rules/
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_DIR) $(1)/etc/config
$(INSTALL_BIN) ./files/etc/init.d/suricata $(1)/etc/init.d/suricata
$(INSTALL_CONF) ./files/etc/config/suricata $(1)/etc/config/suricata
endef
$(eval $(call BuildPackage,suricata))
[EDIT]
In addition when configuring Suricata 7, rustc and cargo is also properly identified and detected :
Rust support: yes
Rust strict mode: no
Rust compiler path: /home/username/works/openwrt/staging_dir/target-x86_64_glibc_custom/host/cargo/bin/rustc
Rust compiler version: rustc 1.72.1 (d5c2e9c34 2023-09-13) (built from a source tarball)
Cargo path: /home/username/works/openwrt/staging_dir/target-x86_64_glibc_custom/host/cargo/bin/cargo
Cargo version: cargo 1.72.1