Merge Makefile.am into a single file (#1811)

Benefits
- Changes that result in a rebuild of libyara will also cause test
  programs to be rebuilt
- Avoid repeating flag definitions
This commit is contained in:
Hilko Bengen
2022-12-19 20:31:00 +01:00
committed by GitHub
parent 2dd6526f50
commit 1b2989eee3
5 changed files with 251 additions and 310 deletions
+1 -1
View File
@@ -53,7 +53,7 @@ stamp-h1
/yarac
/libyara/modules/.dirstamp
libyara/proc/.dirstamp
libyara/yara.pc
/yara.pc
/tests/.dirstamp
# Linux and Mac files
+249 -30
View File
@@ -1,11 +1,23 @@
AM_CFLAGS=-Wall -I$(srcdir)/libyara/include
ABI_VERSION = 9:0:1
AM_CFLAGS=-Wall -D_GNU_SOURCE -I$(srcdir)/libyara/include
#
# When bison is used in POSIX yacc emulation mode (-y/--yacc option) it
# produces warnings if we use Bison-specific features that are not supported
# by yacc. With -Wno-yacc we turn off those warnings. Ideally we should call
# bison without the -y/--yacc option, but autoconf insists on using bison in
# yacc compatibility mode because of AC_PROG_YACC, and AC_PROG_BISON doesn't
# exist.
#
AM_YFLAGS=-d -Wno-yacc
if GCOV
check:
@tests/gcov-summary
MOSTLYCLEANFILES = {cli,tests}/*.gc{no,da,ov}
MOSTLYCLEANFILES = {cli,tests,libyara,libyara/proc,libyara/modules/*}/*.gc{no,da,ov}
AM_CFLAGS+=-O0 -g -ftest-coverage -fprofile-arcs
else
@@ -30,12 +42,221 @@ if UB_SANITIZER
AM_CFLAGS+=-fsanitize=undefined -fno-sanitize-recover=undefined
endif
# Build the library in the hand subdirectory first.
SUBDIRS = libyara
DIST_SUBDIRS = libyara
ACLOCAL_AMFLAGS=-I m4
# Rules for generating YARA modules from .proto files. For each .proto file
# three files are generated: .c, .pb-c.c, and .pb-c.h. The .c file is generated
# by protoc-gen-yara and the other two by protoc-gen-c. This is done only if
# protoc is found, if not, files already in the repository are used instead
# of generating fresh ones from the .proto file.
#
if PROTOC
# SUFFIXES = .proto .pb-c.c .pb-c.h .c
.proto.pb-c.c:
$(PROTOC) --c_out=$(builddir) $^ -Ilibyara/pb/ -I=$(srcdir)
.proto.pb-c.h:
$(PROTOC) --c_out=$(builddir) $^ -Ilibyara/pb/ -I=$(srcdir)
.proto.c:
$(PROTOC) --c_out=$(builddir) $^ -Ilibyara/pb/ -I=$(srcdir)
endif
MODULES = libyara/modules/tests/tests.c
MODULES += libyara/modules/elf/elf.c
MODULES += libyara/modules/math/math.c
MODULES += libyara/modules/time/time.c
MODULES += libyara/modules/pe/pe.c
MODULES += libyara/modules/pe/pe_utils.c
MODULES += libyara/modules/console/console.c
MODULES += libyara/modules/string/string.c
if CUCKOO_MODULE
MODULES += libyara/modules/cuckoo/cuckoo.c
endif
if MAGIC_MODULE
MODULES += libyara/modules/magic/magic.c
endif
if HASH_MODULE
MODULES += libyara/modules/hash/hash.c
endif
if DOTNET_MODULE
MODULES += libyara/modules/dotnet/dotnet.c
endif
if MACHO_MODULE
MODULES += libyara/modules/macho/macho.c
endif
if DEX_MODULE
MODULES += libyara/modules/dex/dex.c
endif
if PB_TESTS_MODULE
MODULES += libyara/modules/pb_tests/pb_tests.c
MODULES += libyara/modules/pb_tests/pb_tests.pb-c.c
endif
if AUTHENTICODE_MODULE
MODULES += libyara/modules/pe/authenticode-parser/authenticode.c
MODULES += libyara/modules/pe/authenticode-parser/certificate.c
MODULES += libyara/modules/pe/authenticode-parser/helper.c
MODULES += libyara/modules/pe/authenticode-parser/countersignature.c
MODULES += libyara/modules/pe/authenticode-parser/structs.c
endif
#
# Add your modules here:
#
# MODULES += libyara/modules/yourmodule.c
#
include_HEADERS = libyara/include/yara.h
yaraincludedir = $(includedir)/yara
yarainclude_HEADERS = \
libyara/include/yara/ahocorasick.h \
libyara/include/yara/arena.h \
libyara/include/yara/atoms.h \
libyara/include/yara/base64.h \
libyara/include/yara/bitmask.h \
libyara/include/yara/compiler.h \
libyara/include/yara/error.h \
libyara/include/yara/exec.h \
libyara/include/yara/exefiles.h \
libyara/include/yara/filemap.h \
libyara/include/yara/hash.h \
libyara/include/yara/integers.h \
libyara/include/yara/libyara.h \
libyara/include/yara/limits.h \
libyara/include/yara/mem.h \
libyara/include/yara/modules.h \
libyara/include/yara/notebook.h \
libyara/include/yara/object.h \
libyara/include/yara/parser.h \
libyara/include/yara/proc.h \
libyara/include/yara/re.h \
libyara/include/yara/rules.h \
libyara/include/yara/scan.h \
libyara/include/yara/scanner.h \
libyara/include/yara/simple_str.h \
libyara/include/yara/sizedstr.h \
libyara/include/yara/stack.h \
libyara/include/yara/stopwatch.h \
libyara/include/yara/stream.h \
libyara/include/yara/strutils.h \
libyara/include/yara/threading.h \
libyara/include/yara/types.h \
libyara/include/yara/unaligned.h \
libyara/include/yara/utils.h
noinst_HEADERS = \
libyara/crypto.h \
libyara/exception.h \
libyara/include/yara/dotnet.h \
libyara/include/yara/elf.h \
libyara/include/yara/endian.h \
libyara/include/yara/globals.h \
libyara/include/yara/hex_lexer.h \
libyara/include/yara/lexer.h \
libyara/include/yara/pe.h \
libyara/include/yara/pe_utils.h \
libyara/include/yara/re_lexer.h \
libyara/modules/module_list
dist_noinst_DATA = libyara/pb/yara.proto
lib_LTLIBRARIES = libyara.la
libyara_la_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/libyara
libyara_la_LDFLAGS = -version-number $(ABI_VERSION)
BUILT_SOURCES = \
libyara/lexer.c \
libyara/hex_lexer.c \
libyara/re_lexer.c \
libyara/grammar.c libyara/grammar.h \
libyara/hex_grammar.c libyara/hex_grammar.h \
libyara/re_grammar.c libyara/re_grammar.h
libyara_la_SOURCES = \
$(MODULES) \
libyara/grammar.y \
libyara/ahocorasick.c \
libyara/arena.c \
libyara/atoms.c \
libyara/base64.c \
libyara/bitmask.c \
libyara/compiler.c \
libyara/endian.c \
libyara/exec.c \
libyara/exefiles.c \
libyara/filemap.c \
libyara/hash.c \
libyara/hex_grammar.y \
libyara/hex_lexer.l \
libyara/lexer.l \
libyara/libyara.c \
libyara/mem.c \
libyara/modules.c \
libyara/notebook.c \
libyara/object.c \
libyara/parser.c \
libyara/proc.c \
libyara/re.c \
libyara/re_grammar.y \
libyara/re_lexer.l \
libyara/rules.c \
libyara/scan.c \
libyara/scanner.c \
libyara/simple_str.c \
libyara/sizedstr.c \
libyara/stack.c \
libyara/stopwatch.c \
libyara/strutils.c \
libyara/stream.c \
libyara/tlshc/tlsh.c \
libyara/tlshc/tlsh_impl.c \
libyara/tlshc/tlsh_util.c \
libyara/threading.c
if USE_WINDOWS_PROC
libyara_la_SOURCES += libyara/proc/windows.c
endif
if USE_LINUX_PROC
libyara_la_SOURCES += libyara/proc/linux.c
endif
if USE_FREEBSD_PROC
libyara_la_SOURCES += libyara/proc/freebsd.c
endif
if USE_OPENBSD_PROC
libyara_la_SOURCES += libyara/proc/openbsd.c
endif
if USE_MACH_PROC
libyara_la_SOURCES += libyara/proc/mach.c
endif
if USE_NO_PROC
libyara_la_SOURCES += libyara/proc/none.c
endif
pkgconfigdir = $(libdir)/pkgconfig
nodist_pkgconfig_DATA = yara.pc
bin_PROGRAMS = yara yarac
yara_SOURCES = \
@@ -47,8 +268,7 @@ yara_SOURCES = \
cli/threading.h \
cli/yara.c
yara_LDADD = -Llibyara/.libs -lyara
yara_DEPENDENCIES = libyara/.libs/libyara.la
yara_LDADD = libyara.la
yarac_SOURCES = \
cli/args.c \
@@ -57,43 +277,42 @@ yarac_SOURCES = \
cli/common.h \
cli/yarac.c
yarac_LDADD = -Llibyara/.libs -lyara
yarac_DEPENDENCIES = libyara/.libs/libyara.la
yarac_LDADD = libyara.la
tests_mapper_SOURCES = tests/mapper.c
tests_mapper_CFLAGS = -O0
test_alignment_SOURCES = tests/test-alignment.c tests/util.c
test_alignment_LDADD = libyara/.libs/libyara.a
test_alignment_LDADD = libyara.la
test_arena_SOURCES = tests/test-arena.c tests/util.c
test_arena_LDADD = libyara/.libs/libyara.a
test_arena_LDADD = libyara.la
test_atoms_SOURCES = tests/test-atoms.c tests/util.c
test_atoms_LDADD = libyara/.libs/libyara.a
test_atoms_LDADD = libyara.la
test_rules_SOURCES = tests/test-rules.c tests/util.c
test_rules_LDADD = libyara/.libs/libyara.a
test_rules_LDADD = libyara.la
if POSIX
EXTRA_test_rules_DEPENDENCIES = tests/mapper$(EXEEXT)
endif
test_pe_SOURCES = tests/test-pe.c tests/util.c
test_pe_LDADD = libyara/.libs/libyara.a
test_pe_LDADD = libyara.la
test_elf_SOURCES = tests/test-elf.c tests/util.c
test_elf_LDADD = libyara/.libs/libyara.a
test_elf_LDADD = libyara.la
test_version_SOURCES = tests/test-version.c tests/util.c
test_version_LDADD = libyara/.libs/libyara.a
test_version_LDADD = libyara.la
test_api_SOURCES = tests/test-api.c tests/util.c
test_api_LDADD = libyara/.libs/libyara.a
test_api_LDADD = libyara.la
test_bitmask_SOURCES = tests/test-bitmask.c tests/util.c
test_bitmask_LDADD = libyara/.libs/libyara.a
test_bitmask_LDADD = libyara.la
test_math_SOURCES = tests/test-math.c tests/util.c
test_math_LDADD = libyara/.libs/libyara.a
test_math_LDADD = libyara.la
test_string_SOURCES = tests/test-string.c tests/util.c
test_string_LDADD = libyara/.libs/libyara.a
test_string_LDADD = libyara.la
test_stack_SOURCES = tests/test-stack.c tests/util.c
test_stack_LDADD = libyara/.libs/libyara.a
test_stack_LDADD = libyara.la
test_re_split_SOURCES = tests/test-re-split.c tests/util.c
test_re_split_LDADD = libyara/.libs/libyara.a
test_re_split_LDADD = libyara.la
test_async_SOURCES = tests/test-async.c tests/util.c
test_async_LDADD = libyara/.libs/libyara.a
test_async_LDADD = libyara.la
TESTS = $(check_PROGRAMS)
TESTS_ENVIRONMENT = TOP_SRCDIR=$(top_srcdir) TOP_BUILDDIR=$(top_builddir)
@@ -123,38 +342,38 @@ if POSIX
if !ADDRESS_SANITIZER
check_PROGRAMS+=test-exception
test_exception_SOURCES = tests/test-exception.c tests/util.c
test_exception_LDADD = libyara/.libs/libyara.a
test_exception_LDADD = libyara.la
endif
endif
if MACHO_MODULE
check_PROGRAMS+=test-macho
test_macho_SOURCES = tests/test-macho.c tests/util.c
test_macho_LDADD = libyara/.libs/libyara.a
test_macho_LDADD = libyara.la
endif
if DEX_MODULE
check_PROGRAMS+=test-dex
test_dex_SOURCES = tests/test-dex.c tests/util.c
test_dex_LDADD = libyara/.libs/libyara.a
test_dex_LDADD = libyara.la
endif
if DOTNET_MODULE
check_PROGRAMS+=test-dotnet
test_dotnet_SOURCES = tests/test-dotnet.c tests/util.c
test_dotnet_LDADD = libyara/.libs/libyara.a
test_dotnet_LDADD = libyara.la
endif
if MAGIC_MODULE
check_PROGRAMS+=test-magic
test_magic_SOURCES = tests/test-magic.c tests/util.c
test_magic_LDADD = libyara/.libs/libyara.a
test_magic_LDADD = libyara.la
endif
if PB_TESTS_MODULE
check_PROGRAMS+=test-pb
test_pb_SOURCES = tests/test-pb.c tests/util.c
test_pb_LDADD = libyara/.libs/libyara.a
test_pb_LDADD = libyara.la
endif
# man pages
+1 -2
View File
@@ -376,7 +376,6 @@ AC_SUBST([PC_REQUIRES_PRIVATE])
AC_SUBST([PC_LIBS_PRIVATE])
AC_CONFIG_FILES([Makefile])
AC_CONFIG_FILES([libyara/Makefile])
AC_CONFIG_FILES([libyara/yara.pc])
AC_CONFIG_FILES([yara.pc])
AC_OUTPUT
-277
View File
@@ -1,277 +0,0 @@
# ABI_VERSION is passed to libtool as --version-number $(ABI_VERSION). This is
# not related to YARA's release version, this is used for tracking changes in
# the ABI, not in the project as a whole.
#
# The three number mean [current]:[revision]:[age], and they should updated as
# follow:
#
# 1. With every release increment "revision".
#
# 2. If any interfaces have been added, removed, or changed since the last
# update, increment "current" and set "revision" to 0.
#
# 3. If the changes in the interface were backward compatible (i.e: only adding
# new APIs) increment "age", or set it to 0 if otherwise.
#
# See https://autotools.io/libtool/version.html for more details.
#
ABI_VERSION = 9:0:1
# Rules for generating YARA modules from .proto files. For each .proto file
# three files are generated: .c, .pb-c.c, and .pb-c.h. The .c file is generated
# by protoc-gen-yara and the other two by protoc-gen-c. This is done only if
# protoc is found, if not, files already in the repository are used instead
# of generating fresh ones from the .proto file.
#
if PROTOC
SUFFIXES = .proto .pb-c.c .pb-c.h .c
.proto.pb-c.c:
$(PROTOC) --c_out=$(builddir) $^ -Ipb/ -I=$(srcdir)
.proto.pb-c.h:
$(PROTOC) --c_out=$(builddir) $^ -Ipb/ -I=$(srcdir)
.proto.c:
$(PROTOC) --c_out=$(builddir) $^ -Ipb/ -I=$(srcdir)
endif
MODULES = modules/tests/tests.c
MODULES += modules/elf/elf.c
MODULES += modules/math/math.c
MODULES += modules/time/time.c
MODULES += modules/pe/pe.c
MODULES += modules/pe/pe_utils.c
MODULES += modules/console/console.c
MODULES += modules/string/string.c
if CUCKOO_MODULE
MODULES += modules/cuckoo/cuckoo.c
endif
if MAGIC_MODULE
MODULES += modules/magic/magic.c
endif
if HASH_MODULE
MODULES += modules/hash/hash.c
endif
if DOTNET_MODULE
MODULES += modules/dotnet/dotnet.c
endif
if MACHO_MODULE
MODULES += modules/macho/macho.c
endif
if DEX_MODULE
MODULES += modules/dex/dex.c
endif
if PB_TESTS_MODULE
MODULES += modules/pb_tests/pb_tests.c
MODULES += modules/pb_tests/pb_tests.pb-c.c
endif
if AUTHENTICODE_MODULE
MODULES += modules/pe/authenticode-parser/authenticode.c
MODULES += modules/pe/authenticode-parser/certificate.c
MODULES += modules/pe/authenticode-parser/helper.c
MODULES += modules/pe/authenticode-parser/countersignature.c
MODULES += modules/pe/authenticode-parser/structs.c
endif
#
# Add your modules here:
#
# MODULES += modules/yourmodule.c
#
#
# When bison is used in POSIX yacc emulation mode (-y/--yacc option) it
# produces warnings if we use Bison-specific features that are not supported
# by yacc. With -Wno-yacc we turn off those warnings. Ideally we should call
# bison without the -y/--yacc option, but autoconf insists on using bison in
# yacc compatibility mode because of AC_PROG_YACC, and AC_PROG_BISON doesn't
# exist.
#
AM_YFLAGS=-d -Wno-yacc
AM_CFLAGS=-Wall -Wno-deprecated-declarations \
-D_GNU_SOURCE \
-I$(srcdir)/include
if GCOV
MOSTLYCLEANFILES = {.,proc,modules/*}/*.gc{no,da,ov}
AM_CFLAGS+=-O0 -g -ftest-coverage -fprofile-arcs
else
if DEBUG
AM_CFLAGS+=-g
endif
if OPTIMIZATION
AM_CFLAGS+=-O3
else
AM_CFLAGS+=-O0
endif
endif
if ADDRESS_SANITIZER
AM_CFLAGS+=-fsanitize=address
endif
if UB_SANITIZER
AM_CFLAGS+=-fsanitize=undefined -fno-sanitize-recover=undefined
endif
if GCC
AM_CFLAGS+=-fvisibility=hidden
endif
ACLOCAL_AMFLAGS=-I m4
include_HEADERS = include/yara.h
yaraincludedir = $(includedir)/yara
yarainclude_HEADERS = \
include/yara/ahocorasick.h \
include/yara/arena.h \
include/yara/atoms.h \
include/yara/base64.h \
include/yara/bitmask.h \
include/yara/compiler.h \
include/yara/error.h \
include/yara/exec.h \
include/yara/exefiles.h \
include/yara/filemap.h \
include/yara/hash.h \
include/yara/integers.h \
include/yara/libyara.h \
include/yara/limits.h \
include/yara/mem.h \
include/yara/modules.h \
include/yara/notebook.h \
include/yara/object.h \
include/yara/parser.h \
include/yara/proc.h \
include/yara/re.h \
include/yara/rules.h \
include/yara/scan.h \
include/yara/scanner.h \
include/yara/simple_str.h \
include/yara/sizedstr.h \
include/yara/stack.h \
include/yara/stopwatch.h \
include/yara/stream.h \
include/yara/strutils.h \
include/yara/threading.h \
include/yara/types.h \
include/yara/unaligned.h \
include/yara/utils.h
noinst_HEADERS = \
crypto.h \
exception.h \
include/yara/dotnet.h \
include/yara/elf.h \
include/yara/endian.h \
include/yara/globals.h \
include/yara/hex_lexer.h \
include/yara/lexer.h \
include/yara/pe.h \
include/yara/pe_utils.h \
include/yara/re_lexer.h \
modules/module_list
dist_noinst_DATA = pb/yara.proto
lib_LTLIBRARIES = libyara.la
libyara_la_LDFLAGS = -version-number $(ABI_VERSION)
BUILT_SOURCES = \
lexer.c \
hex_lexer.c \
re_lexer.c \
grammar.c \
hex_grammar.c \
re_grammar.c
libyara_la_SOURCES = \
$(MODULES) \
grammar.y \
ahocorasick.c \
arena.c \
atoms.c \
base64.c \
bitmask.c \
compiler.c \
endian.c \
exec.c \
exefiles.c \
filemap.c \
hash.c \
hex_grammar.y \
hex_lexer.l \
lexer.l \
libyara.c \
mem.c \
modules.c \
notebook.c \
object.c \
parser.c \
proc.c \
re.c \
re_grammar.y \
re_lexer.l \
rules.c \
scan.c \
scanner.c \
simple_str.c \
sizedstr.c \
stack.c \
stopwatch.c \
strutils.c \
stream.c \
tlshc/tlsh.c \
tlshc/tlsh_impl.c \
tlshc/tlsh_util.c \
threading.c
if USE_WINDOWS_PROC
libyara_la_SOURCES += proc/windows.c
endif
if USE_LINUX_PROC
libyara_la_SOURCES += proc/linux.c
endif
if USE_FREEBSD_PROC
libyara_la_SOURCES += proc/freebsd.c
endif
if USE_OPENBSD_PROC
libyara_la_SOURCES += proc/openbsd.c
endif
if USE_MACH_PROC
libyara_la_SOURCES += proc/mach.c
endif
if USE_NO_PROC
libyara_la_SOURCES += proc/none.c
endif
pkgconfigdir = $(libdir)/pkgconfig
nodist_pkgconfig_DATA = yara.pc
View File