working-directory: examples/plugins/c-json-filetype
run: make
- name: Check C json filetype plugin
- run: test -e examples/plugins/c-json-filetype/.libs/json-filetype.so.0.0.0
+ run: test -e examples/plugins/c-json-filetype/filetype.so
- name: Installing headers and library
run: |
make install-headers
make install-library
- - name: Test plugin build with Makefile.example
+ - name: Cleaning source directory for standalone plugin test.
+ run: make clean
+ - name: Test plugin against installed headers
working-directory: examples/plugins/c-json-filetype
- run: PATH=/usr/local/bin:$PATH make -f Makefile.example
+ run: |
+ # First use sed to pretend we are q user following our
+ # directions for building a standalone plugin.
+ sed -i 's/^#LIBSURICATA_CONFIG/LIBSURICATA_CONFIG/' Makefile
+ sed -i 's/^#CPPFLAGS/CPPFLAGS/' Makefile
+ sed -i 's/^CPPFLAGS.*HAVE_CONFIG_H//' Makefile
+
+ # And build.
+ PATH=/usr/local/bin:$PATH make
almalinux-9-templates:
name: AlmaLinux 9 Test Templates
$(SURICATA_UPDATE_DIR) \
lua \
acsite.m4 \
- scripts/generate-images.sh
+ scripts/generate-images.sh \
+ examples
SUBDIRS = $(HTP_DIR) rust src qa rules doc contrib etc python ebpf \
$(SURICATA_UPDATE_DIR)
-DIST_SUBDIRS = examples/plugins/c-json-filetype $(SUBDIRS)
CLEANFILES = stamp-h[0-9]*
+++ /dev/null
-plugindir = ${libdir}/suricata/plugins
-
-if BUILD_SHARED_LIBRARY
-plugin_LTLIBRARIES = json-filetype.la
-json_filetype_la_LDFLAGS = -module -shared
-json_filetype_la_SOURCES = filetype.c
-
-json_filetype_la_CPPFLAGS = -I$(abs_top_srcdir)/rust/gen -I$(abs_top_srcdir)/rust/dist
-
-else
-
-all-local:
- @echo
- @echo "Shared library support must be enabled to build plugins."
- @echo
-
-endif
+++ /dev/null
-SRCS := filetype.c
-
-LIBSURICATA_CONFIG ?= libsuricata-config
-
-CPPFLAGS += `$(LIBSURICATA_CONFIG) --cflags`
-CPPFLAGS += -DSURICATA_PLUGIN -I.
-CPPFLAGS += "-D__SCFILENAME__=\"$(*F)\""
-
-OBJS := $(SRCS:.c=.o)
-
-filetype.so: $(OBJS)
- $(CC) -fPIC -shared -o $@ $(OBJS)
-
-%.o: %.c
- $(CC) -fPIC $(CPPFLAGS) -c -o $@ $<
-
-clean:
- rm -f *.o *.so *~
--- /dev/null
+# If building a plugin out of the Suricata source tree, you can use
+# libsuricata-config --cflags.
+#LIBSURICATA_CONFIG ?= libsuricata-config
+#CPPFLAGS += `$(LIBSURICATA_CONFIG) --cflags`
+
+# But as this is an example in the Suricata source tree we'll look for
+# includes in the source tree.
+CPPFLAGS += -I@top_srcdir@/src -DHAVE_CONFIG_H
+
+# Currently the Suricata logging system requires this to be even for
+# plugins.
+CPPFLAGS += "-D__SCFILENAME__=\"$(*F)\""
+
+all: Makefile filetype.so
+
+filetype.so: filetype.c
+ $(CC) $(CPPFLAGS) -fPIC -shared -o $@ $^
+
+clean:
+ rm -f *.so *.o *.lo
+ rm -rf .deps
+
+distclean: clean
+ rm -f Makefile.am
+
+# Regenerate Makefile on change of Makefile.in since we're not using
+# Makefile.am.
+Makefile: Makefile.in
+ cd @top_builddir@ && ./config.status examples/plugins/c-json-filetype/Makefile
+
+# Dummy rules to satisfy make dist.
+dist distdir:
## Building
If in the Suricata source directory, this plugin can be built by
-running `make` and installed with `make install`.
-
-Note that Suricata must have been built without `--disable-shared`.
+running `make`.
## Building Standalone
-The file `Makefile.example` is an example of how you might build a
-plugin that is distributed separately from the Suricata source code.
+This Makefile is not generated by automake so it can serve as an
+example for plugins created outside of the Suricata source tree.
-It has the following dependencies:
+Building a standalone plugin has the following dependencies:
- Suricata is installed
- The Suricata library is installed: `make install-library`
- The program `libsuricata-config` is in your path (installed with
`make install-library`)
-The run: `make -f Makefile.example`
+Modify the Makefile to use `libsuricata-config`.
Before building this plugin you will need to build and install Suricata from the
git master branch and install the development tools and headers: