mirror of https://github.com/OISF/suricata
examples/plugin: simplify Makefile
Simplify the Makefile by avoiding automake and providing our own Makefile.in that is suitable for in-tree builds of the plugin and can also serve as an example for standalone plugins. But the bigger benefit of this is to allow building the example plugin even with --disable-shared provided to configure, as this is just a phony limitation imposed by automake/libtool.pull/10469/head
parent
1fdf3f644e
commit
6d792f017b
@ -1,2 +1,3 @@
|
||||
!/Makefile.in
|
||||
*.so
|
||||
*.la
|
||||
|
||||
@ -1,17 +0,0 @@
|
||||
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
|
||||
@ -1,18 +0,0 @@
|
||||
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 *~
|
||||
@ -0,0 +1,32 @@
|
||||
# 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:
|
||||
Loading…
Reference in New Issue