From: Jason Ish Date: Thu, 26 Nov 2020 22:27:36 +0000 (-0600) Subject: build: use a static convenience library for C code X-Git-Tag: suricata-7.0.0-beta1~1805 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e99dde0078d6fe15da0e1c7e66c982507e5fa804;p=thirdparty%2Fsuricata.git build: use a static convenience library for C code 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. --- diff --git a/src/Makefile.am b/src/Makefile.am index 137f310108..8620840548 100755 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -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