simpler makefile generation
diff --git a/tests/tests-c-compiler/Makefile.am b/tests/tests-c-compiler/Makefile.am
index 1eaf911..3102a68 100644
--- a/tests/tests-c-compiler/Makefile.am
+++ b/tests/tests-c-compiler/Makefile.am
@@ -44,7 +44,6 @@
TESTS += check-src/check-41.-fwide-types.c
TESTS += check-src/check-41.c
TESTS += check-src/check-42.c
-TESTS += check-src/check-42.-fwide-types.cc
TESTS += check-src/check-43.c
TESTS += check-src/check-44.c
TESTS += check-src/check-46.c
@@ -72,8 +71,7 @@
data-119 \
data-126 \
check-src/check64-134.-gen-PER.c \
- check-src/check64-136.-gen-OER.c \
- check-src/check-42.-fwide-types.cc
+ check-src/check64-136.-gen-OER.c
clean-local:
rm -rf test-*
diff --git a/tests/tests-c-compiler/check-assembly.sh b/tests/tests-c-compiler/check-assembly.sh
index 55eacd3..299f833 100755
--- a/tests/tests-c-compiler/check-assembly.sh
+++ b/tests/tests-c-compiler/check-assembly.sh
@@ -28,26 +28,10 @@
source_short=$(echo "$source_full" | sed -e 's/.*\///')
testno=$(echo "$source_short" | cut -f2 -d'-' | cut -f1 -d'.')
-CODECS_FLAGS=""
-has_oer=$(echo "$source_short" | grep "gen-OER" || :)
-if [ ! "$has_oer" ]; then
- CODECS_FLAGS="${CODECS_FLAGS} -DASN_DISABLE_OER_SUPPORT"
-fi
-has_per=$(echo "$source_short" | grep "gen-PER" || :)
-if [ ! "$has_per" ]; then
- CODECS_FLAGS="${CODECS_FLAGS} -DASN_DISABLE_PER_SUPPORT"
-fi
-
args=$(echo "$source_short" | sed -E -e 's/\.c+$//')
source_obj=$(echo "$source_short" | sed -E -e 's/\.c+$/.o/')
ext=$(echo "$source_short" | sed -E -e 's/.*\.(c+)$/\1/')
-if [ "$ext" = "cc" ]; then
- COMPILER='$(CXX) $(CXX_CFLAGS)'
-else
- COMPILER='$(CC)'
-fi
-
OFS=$IFS
IFS="."
set $args
@@ -84,25 +68,25 @@
AUTOGENERATED="# This file is autogenerated by $0 ${source_full} ${AFLAGS}"
# Create a common Makefile for the project
-cat <<TARGETS > "${testdir}/Makefile.targets"
+cat <<END_MAKEFILE > "${testdir}/Makefile"
${AUTOGENERATED}
-
COMMON_FLAGS= -I.
CFLAGS = \${COMMON_FLAGS} ${CFLAGS:-} -g -O1
-CFLAGS += -DSRCDIR=../${srcdir} ${CODECS_FLAGS}
+CFLAGS += -DSRCDIR=../${srcdir}
CXXFLAGS = \${CFLAGS} ${CXXFLAGS}
LIBFUZZER_CFLAGS = ${LIBFUZZER_CFLAGS}
LDFLAGS = ${LDFLAGS:-}
+ASN_PROGRAM = check-program
+ASN_PROGRAM_SOURCES = ${source_short}
+
CC ?= ${CC}
CXX ?= ${CXX}
-all: compiled-module
- \$(MAKE) check-executable
+-include Makefile.am.example
-check-executable: \$(OBJS)
- @rm -f *.core
- ${COMPILER} \$(CFLAGS) \$(LDFLAGS) -o check-executable \$(OBJS) -lm
+all: compiled-module
+ \$(MAKE) check-program
# Compile the corresponding .asn1 spec.
compiled-module: ${asn_module} ${abs_top_builddir}/asn1c/asn1c
@@ -113,33 +97,30 @@
rm -f converter-example.c
@touch compiled-module
-TARGETS
+END_MAKEFILE
if [ "${MAKE_FUZZER}" != "yes" ]; then
CHECK_FUZZER="@echo \"No fuzzer defined, skipping.\""
-cat <<TARGETS >> "${testdir}/Makefile.targets"
+cat <<END_MAKEFILE >> "${testdir}/Makefile"
.PHONY: check-fuzzer
check-fuzzer:
-TARGETS
+END_MAKEFILE
else
CHECK_FUZZER="ASAN_OPTIONS=detect_leaks=1 UBSAN_OPTIONS=print_stacktrace=1 ./check-fuzzer -timeout=3 -max_total_time=60 -max_len=512 ${OPT_DATA_DIR}"
-cat <<TARGETS >> "${testdir}/Makefile.targets"
-check-fuzzer: \$(OBJS)
- rm -f ${source_obj}
- ${COMPILER} \$(CFLAGS) \$(LIBFUZZER_CFLAGS) -c -o ${source_obj} ${source_short}
- ${COMPILER} \$(CFLAGS) \$(LIBFUZZER_CFLAGS) \$(LDFLAGS) -o check-fuzzer \$(OBJS)
- rm -f ${source_obj}
-TARGETS
+cat <<END_MAKEFILE >> "${testdir}/Makefile"
+check-fuzzer: ${source_short} \$(ASN_LIBRARY)
+ ${CC} \$(CFLAGS) \$(LIBFUZZER_CFLAGS) \$(LDFLAGS) -o check-fuzzer \$^
+END_MAKEFILE
fi
-cat <<TARGETS >> "${testdir}/Makefile.targets"
+cat <<END_MAKEFILE >> "${testdir}/Makefile"
-check-succeeded: compiled-module
- \$(MAKE) check-executable
+check-succeeded: compiled-module \$(ASN_LIBRARY) ${source_short}
+ \$(MAKE) check-program
\$(MAKE) check-fuzzer
@rm -f check-succeeded
- ./check-executable
+ ./check-program
\$(MAKE) fuzz
@touch check-succeeded
@echo "OK: ${source_full}"
@@ -150,43 +131,10 @@
check: check-succeeded
-clean:
- @rm -f *.o check-executable
-TARGETS
-
-# Create a BSD- or GNU-specific Makefile for the project.
-produce_specific_makefile() {
- local make_type=$1
- local make_file="$testdir/${make_type}makefile"
-
- if [ ${make_type} = "BSD" ]; then
- cat <<-OBJECTS > ${make_file}
- ${AUTOGENERATED}
- SRCS_C!=find . -name \*.c
- SRCS_CXX!=find . -name \*.cc
- SRCS=\$(SRCS_C) \$(SRCS_CXX)
- OBJS=\${SRCS_C:.c=.o} \${SRCS_CXX:.cc=.o}
- include Makefile.targets
- OBJECTS
- else
- cat <<-OBJECTS > ${make_file}
- ${AUTOGENERATED}
- SRCS_C := \$(wildcard *.c)
- SRCS_CXX := \$(wildcard *.cc)
- SRCS = \$(SRCS_C) \$(SRCS_CXX)
- OBJS =\$(patsubst %.c,%.o,\$(SRCS_C))
- OBJS+=\$(patsubst %.cc,%.o,\$(SRCS_CXX))
- include Makefile.targets
- OBJECTS
- fi
-
-}
-
-produce_specific_makefile BSD
-produce_specific_makefile GNU
+END_MAKEFILE
# Perform building and checking
-${TEST_DRIVER} make -C "$testdir" check
+${TEST_DRIVER} ${MAKE:-make} -C "${testdir}" check
# Make sure the test is not marked as failed any longer.
rm -f "${testdir}-FAILED"