]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
build: use a static convenience library for C code
authorJason Ish <jason.ish@oisf.net>
Thu, 26 Nov 2020 22:27:36 +0000 (16:27 -0600)
committerJason Ish <jason.ish@oisf.net>
Tue, 16 Feb 2021 17:43:26 +0000 (11:43 -0600)
With the circular reference gone, we can now make use
of a convenience library for the Suricata program
as well as any other programs that depend on the same
source such as the fuzzer.

While its not a libtool convenience library, it serves
the same purpose and is a common idiom in Make and CMake
projects whereas the COMMON_SOURCES approach was more
of a hack we had to resort to until the circular
reference was resolved.

src/Makefile.am

index 137f3101082e9801e0c584e80d5eac09c39cae10..8620840548b3f3bed8a9803905272b6516ac99d2 100755 (executable)
@@ -585,17 +585,24 @@ EXTRA_DIST = tests
 # set the include path found by configure
 AM_CPPFLAGS = $(all_includes)
 
-suricata_SOURCES = main.c $(COMMON_SOURCES)
+noinst_LIBRARIES = libsuricata_c.a
+libsuricata_c_a_SOURCES = $(COMMON_SOURCES)
+
+suricata_SOURCES = main.c
 
 # the library search path.
 suricata_LDFLAGS = $(all_libraries) ${SECLDFLAGS}
-suricata_LDADD = $(HTP_LDADD) $(RUST_LDADD)
-suricata_DEPENDENCIES = $(RUST_SURICATA_LIB)
+suricata_LDADD = libsuricata_c.a $(HTP_LDADD) $(RUST_LDADD)
+suricata_DEPENDENCIES = libsuricata_c.a
 
 if BUILD_FUZZTARGETS
-nodist_fuzz_applayerprotodetectgetproto_SOURCES = tests/fuzz/fuzz_applayerprotodetectgetproto.c $(COMMON_SOURCES)
-fuzz_applayerprotodetectgetproto_LDFLAGS = $(all_libraries) ${SECLDFLAGS}
-fuzz_applayerprotodetectgetproto_LDADD = $(RUST_SURICATA_LIB) $(HTP_LDADD) $(RUST_LDADD)
+
+LDFLAGS_FUZZ = $(all_libraries) $(SECLDFLAGS)
+LDADD_FUZZ = libsuricata_c.a $(HTP_LDADD) $(RUST_LDADD)
+
+nodist_fuzz_applayerprotodetectgetproto_SOURCES = tests/fuzz/fuzz_applayerprotodetectgetproto.c
+fuzz_applayerprotodetectgetproto_LDFLAGS = $(LDFLAGS_FUZZ)
+fuzz_applayerprotodetectgetproto_LDADD = $(LDADD_FUZZ)
 if HAS_FUZZLDFLAGS
     fuzz_applayerprotodetectgetproto_LDFLAGS += $(LIB_FUZZING_ENGINE)
 else
@@ -604,9 +611,9 @@ endif
 # force usage of CXX for linker
 nodist_EXTRA_fuzz_applayerprotodetectgetproto_SOURCES = force-cxx-linking.cxx
 
-nodist_fuzz_applayerparserparse_SOURCES = tests/fuzz/fuzz_applayerparserparse.c $(COMMON_SOURCES)
-fuzz_applayerparserparse_LDFLAGS = $(all_libraries) ${SECLDFLAGS}
-fuzz_applayerparserparse_LDADD = $(RUST_SURICATA_LIB) $(HTP_LDADD) $(RUST_LDADD)
+nodist_fuzz_applayerparserparse_SOURCES = tests/fuzz/fuzz_applayerparserparse.c
+fuzz_applayerparserparse_LDFLAGS = $(LDFLAGS_FUZZ)
+fuzz_applayerparserparse_LDADD = $(LDADD_FUZZ)
 if HAS_FUZZLDFLAGS
     fuzz_applayerparserparse_LDFLAGS += $(LIB_FUZZING_ENGINE)
 else
@@ -615,9 +622,9 @@ endif
 # force usage of CXX for linker
 nodist_EXTRA_fuzz_applayerparserparse_SOURCES = force-cxx-linking.cxx
 
-nodist_fuzz_siginit_SOURCES = tests/fuzz/fuzz_siginit.c $(COMMON_SOURCES)
-fuzz_siginit_LDFLAGS = $(all_libraries) ${SECLDFLAGS}
-fuzz_siginit_LDADD = $(RUST_SURICATA_LIB) $(HTP_LDADD) $(RUST_LDADD)
+nodist_fuzz_siginit_SOURCES = tests/fuzz/fuzz_siginit.c
+fuzz_siginit_LDFLAGS = $(LDFLAGS_FUZZ)
+fuzz_siginit_LDADD = $(LDADD_FUZZ)
 if HAS_FUZZLDFLAGS
     fuzz_siginit_LDFLAGS += $(LIB_FUZZING_ENGINE)
 else
@@ -626,9 +633,9 @@ endif
 # force usage of CXX for linker
 nodist_EXTRA_fuzz_siginit_SOURCES = force-cxx-linking.cxx
 
-nodist_fuzz_confyamlloadstring_SOURCES = tests/fuzz/fuzz_confyamlloadstring.c $(COMMON_SOURCES)
-fuzz_confyamlloadstring_LDFLAGS = $(all_libraries) ${SECLDFLAGS}
-fuzz_confyamlloadstring_LDADD = $(RUST_SURICATA_LIB) $(HTP_LDADD) $(RUST_LDADD)
+nodist_fuzz_confyamlloadstring_SOURCES = tests/fuzz/fuzz_confyamlloadstring.c
+fuzz_confyamlloadstring_LDFLAGS = $(LDFLAGS_FUZZ)
+fuzz_confyamlloadstring_LDADD = $(LDADD_FUZZ)
 if HAS_FUZZLDFLAGS
     fuzz_confyamlloadstring_LDFLAGS += $(LIB_FUZZING_ENGINE)
 else
@@ -637,9 +644,9 @@ endif
 # force usage of CXX for linker
 nodist_EXTRA_fuzz_confyamlloadstring_SOURCES = force-cxx-linking.cxx
 
-nodist_fuzz_decodepcapfile_SOURCES = tests/fuzz/fuzz_decodepcapfile.c $(COMMON_SOURCES)
-fuzz_decodepcapfile_LDFLAGS = $(all_libraries) ${SECLDFLAGS}
-fuzz_decodepcapfile_LDADD = $(RUST_SURICATA_LIB) $(HTP_LDADD) $(RUST_LDADD)
+nodist_fuzz_decodepcapfile_SOURCES = tests/fuzz/fuzz_decodepcapfile.c
+fuzz_decodepcapfile_LDFLAGS = $(LDFLAGS_FUZZ)
+fuzz_decodepcapfile_LDADD = $(LDADD_FUZZ)
 if HAS_FUZZLDFLAGS
     fuzz_decodepcapfile_LDFLAGS += $(LIB_FUZZING_ENGINE)
 else
@@ -648,9 +655,9 @@ endif
 # force usage of CXX for linker
 nodist_EXTRA_fuzz_decodepcapfile_SOURCES = force-cxx-linking.cxx
 
-nodist_fuzz_sigpcap_SOURCES = tests/fuzz/fuzz_sigpcap.c $(COMMON_SOURCES)
-fuzz_sigpcap_LDFLAGS = $(all_libraries) ${SECLDFLAGS}
-fuzz_sigpcap_LDADD = $(RUST_SURICATA_LIB) $(HTP_LDADD) $(RUST_LDADD)
+nodist_fuzz_sigpcap_SOURCES = tests/fuzz/fuzz_sigpcap.c
+fuzz_sigpcap_LDFLAGS = $(LDFLAGS_FUZZ)
+fuzz_sigpcap_LDADD = $(LDADD_FUZZ)
 if HAS_FUZZLDFLAGS
     fuzz_sigpcap_LDFLAGS += $(LIB_FUZZING_ENGINE)
 else
@@ -659,9 +666,9 @@ endif
 # force usage of CXX for linker
 nodist_EXTRA_fuzz_sigpcap_SOURCES = force-cxx-linking.cxx
 
-nodist_fuzz_mimedecparseline_SOURCES = tests/fuzz/fuzz_mimedecparseline.c $(COMMON_SOURCES)
-fuzz_mimedecparseline_LDFLAGS = $(all_libraries) ${SECLDFLAGS}
-fuzz_mimedecparseline_LDADD = $(RUST_SURICATA_LIB) $(HTP_LDADD) $(RUST_LDADD)
+nodist_fuzz_mimedecparseline_SOURCES = tests/fuzz/fuzz_mimedecparseline.c
+fuzz_mimedecparseline_LDFLAGS = $(LDFLAGS_FUZZ)
+fuzz_mimedecparseline_LDADD = $(LDADD_FUZZ)
 if HAS_FUZZLDFLAGS
     fuzz_mimedecparseline_LDFLAGS += $(LIB_FUZZING_ENGINE)
 else