Ensure POSIX desktop builds for all tests use proper CFLAGS

- Previously when compiling against conditionally-included "subdir/foo.o" we would pick up the apple2ix CFLAGS
      (without -DTESTING=1 and other necessary flags)
    - Now when compiling against conditionally-included "subdir/sometestexe-foo.o" we pick up the correct "testexe" CFLAGS
    - Likely there is a less HACKish way to do this, but I lack the google-fu to discover the superior incantation ;P
This commit is contained in:
Aaron Culliney 2016-07-02 13:14:17 -07:00
parent 7af88b3568
commit b0a2a34d6a
2 changed files with 105 additions and 64 deletions

View File

@ -52,14 +52,7 @@ META_SRC = \
src/meta/lintrace.c
# NOTE : selectively enabled through configuration process ...
EXTRA_apple2ix_SOURCES = \
$(ASM_SRC_x86) \
\
$(VIDEO_SRC) \
\
$(AUDIO_SRC) \
\
$(META_SRC)
EXTRA_apple2ix_SOURCES = $(ASM_SRC_x86) $(VIDEO_SRC) $(AUDIO_SRC) $(META_SRC)
apple2ix_SOURCES = src/font.c src/rom.c src/misc.c src/display.c src/vm.c \
src/timing.c src/zlib-helpers.c src/joystick.c src/keys.c src/prefs.c \
@ -88,77 +81,73 @@ src/x86/glue.S: src/cpu-supp.c src/disk.c src/display.c src/vm.c @AUDIO_GLUE_C@
###############################################################################
# Testing
LOG_DRIVER = testcpu ## hack TODO/FIXME ... should be wrapper shell script accepting standard GNU testing API args ...
#LOG_DRIVER = ## hack TODO/FIXME ... should be wrapper shell script accepting standard GNU testing API args ...
A2_TEST_SOURCES = $(apple2ix_SOURCES) src/test/testcommon.c
A2_TEST_CFLAGS = -DTESTING=1 -DCPU_TRACING=1 -DDISK_TRACING=1 -DVM_TRACING=1 -Isrc/test
A2_TEST_CFLAGS = $(apple2ix_CFLAGS) -DTESTING=1 -Isrc/test
TESTS = testcpu testdisplay testvm testdisk testprefs testtrace
check_PROGRAMS = testcpu testdisplay testvm testdisk testprefs testtrace
#######################################
testcpu_SOURCES = src/test/testcpu.c $(A2_TEST_SOURCES) $(META_SRC)
testcpu_CFLAGS = $(apple2ix_CFLAGS) $(A2_TEST_CFLAGS) -DTEST_CPU=1
testcpu_SOURCES = src/test/testcpu.c $(A2_TEST_SOURCES)
testcpu_CFLAGS = $(A2_TEST_CFLAGS) -DTEST_CPU=1
testcpu_CCASFLAGS = $(testcpu_CFLAGS)
testcpu_LDFLAGS = $(apple2ix_LDFLAGS)
testcpu_LDADD = @ASM_O@ @VIDEO_O@ @AUDIO_O@
testcpu_DEPENDENCIES = @ASM_O@ @META_O@ @VIDEO_O@ @AUDIO_O@
EXTRA_testcpu_SOURCES = $(ASM_SRC_x86)
testcpu_LDADD = @testcpu_ASM_O@ @testcpu_VIDEO_O@ @testcpu_AUDIO_O@ @testcpu_META_O@ @X_LIBS@
testcpu_DEPENDENCIES = @testcpu_ASM_O@ @testcpu_VIDEO_O@ @testcpu_AUDIO_O@ @testcpu_META_O@
EXTRA_testcpu_SOURCES = $(ASM_SRC_x86) $(VIDEO_SRC) $(AUDIO_SRC) $(META_SRC)
#######################################
testdisplay_SOURCES = src/test/testdisplay.c $(A2_TEST_SOURCES) $(META_SRC)
testdisplay_CFLAGS = $(apple2ix_CFLAGS) $(A2_TEST_CFLAGS) -DTEST_DISPLAY=1
testdisplay_CCASFLAGS = $(testdisplay_CFLAGS)
testdisplay_LDFLAGS = $(apple2ix_LDFLAGS)
testdisplay_LDADD = @ASM_O@ @VIDEO_O@ @AUDIO_O@
testdisplay_DEPENDENCIES = @ASM_O@ @META_O@ @VIDEO_O@ @AUDIO_O@
EXTRA_testdisplay_SOURCES = $(ASM_SRC_x86) $(VIDEO_SRC)
#######################################
testvm_SOURCES = src/test/testvm.c $(A2_TEST_SOURCES) $(META_SRC)
testvm_CFLAGS = $(apple2ix_CFLAGS) $(A2_TEST_CFLAGS) -DTEST_VM=1
testvm_CCASFLAGS = $(testvm_CFLAGS)
testvm_LDFLAGS = $(apple2ix_LDFLAGS)
# HACK FIXME TODO NOTE: specify TESTVM_ASM_O to force it to rebuild with proper CCASFLAGS ... automake bug?
testvm_LDADD = @TESTVM_ASM_O@ @VIDEO_O@ @AUDIO_O@
testvm_DEPENDENCIES = @TESTVM_ASM_O@ @META_O@ @VIDEO_O@ @AUDIO_O@
EXTRA_testvm_SOURCES = $(ASM_SRC_x86) $(VIDEO_SRC)
#######################################
testdisk_SOURCES = src/test/testdisk.c $(A2_TEST_SOURCES) $(META_SRC)
testdisk_CFLAGS = $(apple2ix_CFLAGS) $(A2_TEST_CFLAGS) -DTEST_DISK=1
testdisk_SOURCES = src/test/testdisk.c $(A2_TEST_SOURCES)
testdisk_CFLAGS = $(A2_TEST_CFLAGS) -DTEST_DISK=1 -DCPU_TRACING=1 -DDISK_TRACING=1 -DVM_TRACING=1
testdisk_CCASFLAGS = $(testdisk_CFLAGS)
testdisk_LDFLAGS = $(apple2ix_LDFLAGS)
# HACK FIXME TODO NOTE: specify testdisk_ASM_O to force it to rebuild with proper CCASFLAGS ... automake bug?
testdisk_LDADD = @TESTDISK_ASM_O@ @VIDEO_O@ @AUDIO_O@
testdisk_DEPENDENCIES = @TESTDISK_ASM_O@ @META_O@ @VIDEO_O@ @AUDIO_O@
EXTRA_testdisk_SOURCES = $(ASM_SRC_x86) $(VIDEO_SRC)
testdisk_LDADD = @testdisk_ASM_O@ @testdisk_VIDEO_O@ @testdisk_AUDIO_O@ @testdisk_META_O@ @X_LIBS@
testdisk_DEPENDENCIES = @testdisk_ASM_O@ @testdisk_VIDEO_O@ @testdisk_AUDIO_O@ @testdisk_META_O@
EXTRA_testdisk_SOURCES = $(ASM_SRC_x86) $(VIDEO_SRC) $(AUDIO_SRC) $(META_SRC)
#######################################
testprefs_SOURCES = src/test/testprefs.c $(A2_TEST_SOURCES) $(META_SRC)
testprefs_CFLAGS = $(apple2ix_CFLAGS) $(A2_TEST_CFLAGS) -DTEST_PREFS=1
testdisplay_SOURCES = src/test/testdisplay.c $(A2_TEST_SOURCES)
testdisplay_CFLAGS = $(A2_TEST_CFLAGS) -DTEST_DISPLAY=1
testdisplay_CCASFLAGS = $(testdisplay_CFLAGS)
testdisplay_LDFLAGS = $(apple2ix_LDFLAGS)
testdisplay_LDADD = @testdisplay_ASM_O@ @testdisplay_VIDEO_O@ @testdisplay_AUDIO_O@ @testdisplay_META_O@ @X_LIBS@
testdisplay_DEPENDENCIES = @testdisplay_ASM_O@ @testdisplay_VIDEO_O@ @testdisplay_AUDIO_O@ @testdisplay_META_O@
EXTRA_testdisplay_SOURCES = $(ASM_SRC_x86) $(VIDEO_SRC) $(AUDIO_SRC) $(META_SRC)
#######################################
testprefs_SOURCES = src/test/testprefs.c $(A2_TEST_SOURCES)
testprefs_CFLAGS = $(A2_TEST_CFLAGS) -DTEST_PREFS=1
testprefs_CCASFLAGS = $(testprefs_CFLAGS)
testprefs_LDFLAGS = $(apple2ix_LDFLAGS)
# HACK FIXME TODO NOTE: specify testprefs_ASM_O to force it to rebuild with proper CCASFLAGS ... automake bug?
testprefs_LDADD = @TESTPREFS_ASM_O@ @VIDEO_O@ @AUDIO_O@
testprefs_DEPENDENCIES = @TESTPREFS_ASM_O@ @META_O@ @VIDEO_O@ @AUDIO_O@
EXTRA_testprefs_SOURCES = $(ASM_SRC_x86) $(VIDEO_SRC)
testprefs_LDADD = @testprefs_ASM_O@ @testprefs_VIDEO_O@ @testprefs_AUDIO_O@ @testprefs_META_O@ @X_LIBS@
testprefs_DEPENDENCIES = @testprefs_ASM_O@ @testprefs_VIDEO_O@ @testprefs_AUDIO_O@ @testprefs_META_O@
EXTRA_testprefs_SOURCES = $(ASM_SRC_x86) $(VIDEO_SRC) $(AUDIO_SRC) $(META_SRC)
#######################################
testtrace_SOURCES = src/test/testtrace.c $(A2_TEST_SOURCES) $(META_SRC)
testtrace_CFLAGS = $(apple2ix_CFLAGS) $(A2_TEST_CFLAGS) -DTEST_TRACE=1
testtrace_SOURCES = src/test/testtrace.c $(A2_TEST_SOURCES)
testtrace_CFLAGS = $(A2_TEST_CFLAGS) -DTEST_TRACE=1 -DCPU_TRACING=1 -DDISK_TRACING=1 -DVM_TRACING=1
testtrace_CCASFLAGS = $(testtrace_CFLAGS)
testtrace_LDFLAGS = $(apple2ix_LDFLAGS)
# HACK FIXME TODO NOTE: specify testtrace_ASM_O to force it to rebuild with proper CCASFLAGS ... automake bug?
testtrace_LDADD = @TESTTRACE_ASM_O@ @VIDEO_O@ @AUDIO_O@
testtrace_DEPENDENCIES = @TESTTRACE_ASM_O@ @META_O@ @VIDEO_O@ @AUDIO_O@
testtrace_LDADD = @testtrace_ASM_O@ @testtrace_VIDEO_O@ @testtrace_AUDIO_O@ @testtrace_META_O@ @X_LIBS@
testtrace_DEPENDENCIES = @testtrace_ASM_O@ @testtrace_VIDEO_O@ @testtrace_AUDIO_O@ @testtrace_META_O@
EXTRA_testtrace_SOURCES = $(ASM_SRC_x86) $(VIDEO_SRC) $(AUDIO_SRC) $(META_SRC)
EXTRA_testtrace_SOURCES = $(ASM_SRC_x86) $(VIDEO_SRC)
#######################################
testvm_SOURCES = src/test/testvm.c $(A2_TEST_SOURCES)
testvm_CFLAGS = $(A2_TEST_CFLAGS) -DTEST_VM=1
testvm_CCASFLAGS = $(testvm_CFLAGS)
testvm_LDFLAGS = $(apple2ix_LDFLAGS)
testvm_LDADD = @testvm_ASM_O@ @testvm_VIDEO_O@ @testvm_AUDIO_O@ @testvm_META_O@ @X_LIBS@
testvm_DEPENDENCIES = @testvm_ASM_O@ @testvm_VIDEO_O@ @testvm_AUDIO_O@ @testvm_META_O@
EXTRA_testvm_SOURCES = $(ASM_SRC_x86) $(VIDEO_SRC) $(AUDIO_SRC) $(META_SRC)
###############################################################################
# Misc & Installation

View File

@ -20,10 +20,13 @@ dnl ---------------------------------------------------------------------------
dnl Arch checks
ASM_O="src/x86/glue.o src/x86/cpu.o"
TESTVM_ASM_O="src/x86/testvm-glue.o src/x86/testvm-cpu.o"
TESTDISK_ASM_O="src/x86/testdisk-glue.o src/x86/testdisk-cpu.o"
TESTPREFS_ASM_O="src/x86/testprefs-glue.o src/x86/testprefs-cpu.o"
TESTTRACE_ASM_O="src/x86/testtrace-glue.o src/x86/testtrace-cpu.o"
dnl HACK there's gotta be a better way ... without this verbosity, CFLAGS are not correct (lacking -DTESTING=1 , etc) if we don't specify specific obj files for test binaries
testcpu_ASM_O="src/x86/testcpu-glue.o src/x86/testcpu-cpu.o"
testdisk_ASM_O="src/x86/testdisk-glue.o src/x86/testdisk-cpu.o"
testdisplay_ASM_O="src/x86/testdisplay-glue.o src/x86/testdisplay-cpu.o"
testprefs_ASM_O="src/x86/testprefs-glue.o src/x86/testprefs-cpu.o"
testtrace_ASM_O="src/x86/testtrace-glue.o src/x86/testtrace-cpu.o"
testvm_ASM_O="src/x86/testvm-glue.o src/x86/testvm-cpu.o"
arch=''
case $target in
x86_64-*-*)
@ -77,10 +80,13 @@ if test "$arch" = "x86" ; then
fi
AC_SUBST(ASM_O)
AC_SUBST(TESTVM_ASM_O)
AC_SUBST(TESTDISK_ASM_O)
AC_SUBST(TESTPREFS_ASM_O)
AC_SUBST(TESTTRACE_ASM_O)
AC_SUBST(testcpu_ASM_O)
AC_SUBST(testdisk_ASM_O)
AC_SUBST(testdisplay_ASM_O)
AC_SUBST(testprefs_ASM_O)
AC_SUBST(testtrace_ASM_O)
AC_SUBST(testvm_ASM_O)
AC_SUBST([AM_CFLAGS])
@ -174,6 +180,13 @@ AC_ARG_ENABLE([opengl], AS_HELP_STRING([--disable-opengl], [Disable OpenGL video
AC_DEFINE(VIDEO_OPENGL, 1, [Use OpenGL])
AC_DEFINE(USE_GLUT, 1, [Use GLUT library])
VIDEO_O="src/video/glvideo.o src/video/glnode.o src/video/glalert.o src/video/glhudmodel.o src/video/glutinput.o src/video_util/matrixUtil.o src/video_util/modelUtil.o src/video_util/sourceUtil.o src/video_util/vectorUtil.o"
dnl HACK there's gotta be a better way ... without this verbosity, CFLAGS are not correct (lacking -DTESTING=1 , etc) if we don't specify specific obj files for test binaries
testcpu_VIDEO_O="src/video/testcpu-glvideo.o src/video/testcpu-glnode.o src/video/testcpu-glalert.o src/video/testcpu-glhudmodel.o src/video/testcpu-glutinput.o src/video_util/testcpu-matrixUtil.o src/video_util/testcpu-modelUtil.o src/video_util/testcpu-sourceUtil.o src/video_util/testcpu-vectorUtil.o"
testdisk_VIDEO_O="src/video/testdisk-glvideo.o src/video/testdisk-glnode.o src/video/testdisk-glalert.o src/video/testdisk-glhudmodel.o src/video/testdisk-glutinput.o src/video_util/testdisk-matrixUtil.o src/video_util/testdisk-modelUtil.o src/video_util/testdisk-sourceUtil.o src/video_util/testdisk-vectorUtil.o"
testdisplay_VIDEO_O="src/video/testdisplay-glvideo.o src/video/testdisplay-glnode.o src/video/testdisplay-glalert.o src/video/testdisplay-glhudmodel.o src/video/testdisplay-glutinput.o src/video_util/testdisplay-matrixUtil.o src/video_util/testdisplay-modelUtil.o src/video_util/testdisplay-sourceUtil.o src/video_util/testdisplay-vectorUtil.o"
testprefs_VIDEO_O="src/video/testprefs-glvideo.o src/video/testprefs-glnode.o src/video/testprefs-glalert.o src/video/testprefs-glhudmodel.o src/video/testprefs-glutinput.o src/video_util/testprefs-matrixUtil.o src/video_util/testprefs-modelUtil.o src/video_util/testprefs-sourceUtil.o src/video_util/testprefs-vectorUtil.o"
testtrace_VIDEO_O="src/video/testtrace-glvideo.o src/video/testtrace-glnode.o src/video/testtrace-glalert.o src/video/testtrace-glhudmodel.o src/video/testtrace-glutinput.o src/video_util/testtrace-matrixUtil.o src/video_util/testtrace-modelUtil.o src/video_util/testtrace-sourceUtil.o src/video_util/testtrace-vectorUtil.o"
testvm_VIDEO_O="src/video/testvm-glvideo.o src/video/testvm-glnode.o src/video/testvm-glalert.o src/video/testvm-glhudmodel.o src/video/testvm-glutinput.o src/video_util/testvm-matrixUtil.o src/video_util/testvm-modelUtil.o src/video_util/testvm-sourceUtil.o src/video_util/testvm-vectorUtil.o"
AC_MSG_RESULT([Building emulator with OpenGL support, w00t!])
], [
AC_MSG_WARN([Did not find OpenGL GLEW library...])
@ -207,6 +220,13 @@ AS_IF([test "x$opengl_supported" = "xyes"], [
AC_MSG_WARN([Building emulator without support of X11 MITSHM extension...])
], [-lX11])
VIDEO_O="src/video/xvideo.o"
dnl HACK there's gotta be a better way ... without this verbosity, CFLAGS are not correct (lacking -DTESTING=1 , etc) if we don't specify specific obj files for test binaries
testcpu_VIDEO_O="src/video/testcpu-xvideo.o"
testdisk_VIDEO_O="src/video/testdisk-xvideo.o"
testdisplay_VIDEO_O="src/video/testdisplay-xvideo.o"
testprefs_VIDEO_O="src/video/testprefs-xvideo.o"
testtrace_VIDEO_O="src/video/testtrace-xvideo.o"
testvm_VIDEO_O="src/video/testvm-xvideo.o"
], [
AC_MSG_ERROR([Did not find OpenGL nor X11 libraries...])
], [-LX11])
@ -216,6 +236,12 @@ AS_IF([test "x$opengl_supported" = "xyes"], [
])
AC_SUBST(VIDEO_O)
AC_SUBST(testcpu_VIDEO_O)
AC_SUBST(testdisk_VIDEO_O)
AC_SUBST(testdisplay_VIDEO_O)
AC_SUBST(testprefs_VIDEO_O)
AC_SUBST(testtrace_VIDEO_O)
AC_SUBST(testvm_VIDEO_O)
dnl ---------------------------------------------------------------------------
dnl Sound ...
@ -233,6 +259,13 @@ AC_ARG_ENABLE([audio], AS_HELP_STRING([--disable-audio], [Disable emulator audio
AC_DEFINE(AUDIO_ENABLED, 1, [Enable sound module])
AUDIO_GLUE_C="src/audio/speaker.c src/audio/mockingboard.c src/audio/playqueue.c"
AUDIO_O="src/audio/soundcore.o src/audio/soundcore-openal.o src/audio/speaker.o src/audio/playqueue.o src/audio/alhelpers.o src/audio/mockingboard.o src/audio/AY8910.o"
dnl HACK there's gotta be a better way ... without this verbosity, CFLAGS are not correct (lacking -DTESTING=1 , etc) if we don't specify specific obj files for test binaries
testcpu_AUDIO_O="src/audio/testcpu-soundcore.o src/audio/testcpu-soundcore-openal.o src/audio/testcpu-speaker.o src/audio/testcpu-playqueue.o src/audio/testcpu-alhelpers.o src/audio/testcpu-mockingboard.o src/audio/testcpu-AY8910.o"
testdisk_AUDIO_O="src/audio/testdisk-soundcore.o src/audio/testdisk-soundcore-openal.o src/audio/testdisk-speaker.o src/audio/testdisk-playqueue.o src/audio/testdisk-alhelpers.o src/audio/testdisk-mockingboard.o src/audio/testdisk-AY8910.o"
testdisplay_AUDIO_O="src/audio/testdisplay-soundcore.o src/audio/testdisplay-soundcore-openal.o src/audio/testdisplay-speaker.o src/audio/testdisplay-playqueue.o src/audio/testdisplay-alhelpers.o src/audio/testdisplay-mockingboard.o src/audio/testdisplay-AY8910.o"
testprefs_AUDIO_O="src/audio/testprefs-soundcore.o src/audio/testprefs-soundcore-openal.o src/audio/testprefs-speaker.o src/audio/testprefs-playqueue.o src/audio/testprefs-alhelpers.o src/audio/testprefs-mockingboard.o src/audio/testprefs-AY8910.o"
testtrace_AUDIO_O="src/audio/testtrace-soundcore.o src/audio/testtrace-soundcore-openal.o src/audio/testtrace-speaker.o src/audio/testtrace-playqueue.o src/audio/testtrace-alhelpers.o src/audio/testtrace-mockingboard.o src/audio/testtrace-AY8910.o"
testvm_AUDIO_O="src/audio/testvm-soundcore.o src/audio/testvm-soundcore-openal.o src/audio/testvm-speaker.o src/audio/testvm-playqueue.o src/audio/testvm-alhelpers.o src/audio/testvm-mockingboard.o src/audio/testvm-AY8910.o"
], [
AC_MSG_WARN([Could not find OpenAL libraries, sound will be disabled])
], [])
@ -251,6 +284,12 @@ AC_ARG_ENABLE([audio], AS_HELP_STRING([--disable-audio], [Disable emulator audio
])
AC_SUBST(AUDIO_GLUE_C)
AC_SUBST(AUDIO_O)
AC_SUBST(testcpu_AUDIO_O)
AC_SUBST(testdisk_AUDIO_O)
AC_SUBST(testdisplay_AUDIO_O)
AC_SUBST(testprefs_AUDIO_O)
AC_SUBST(testtrace_AUDIO_O)
AC_SUBST(testvm_AUDIO_O)
AS_IF([test "x$openal_supported" = "xyes"], [
], [
@ -266,8 +305,21 @@ dnl Debugger & classic interface ...
AC_ARG_ENABLE([debugger], AS_HELP_STRING([--disable-debugger], [Disable 6502 debugging console]), [], [
AC_DEFINE(DEBUGGER, 1, [Enable 6502 debugger module])
META_O="src/meta/debug.o src/meta/debugger.o src/meta/opcodes.o src/test/sha1.o"
dnl HACK there's gotta be a better way ... without this verbosity, CFLAGS are not correct (lacking -DTESTING=1 , etc) if we don't specify specific obj files for test binaries
testcpu_META_O="src/meta/testcpu-debug.o src/meta/testcpu-debugger.o src/meta/testcpu-opcodes.o src/test/testcpu-sha1.o"
testdisk_META_O="src/meta/testdisk-debug.o src/meta/testdisk-debugger.o src/meta/testdisk-opcodes.o src/test/testdisk-sha1.o"
testdisplay_META_O="src/meta/testdisplay-debug.o src/meta/testdisplay-debugger.o src/meta/testdisplay-opcodes.o src/test/testdisplay-sha1.o"
testprefs_META_O="src/meta/testprefs-debug.o src/meta/testprefs-debugger.o src/meta/testprefs-opcodes.o src/test/testprefs-sha1.o"
testtrace_META_O="src/meta/testtrace-debug.o src/meta/testtrace-debugger.o src/meta/testtrace-opcodes.o src/test/testtrace-sha1.o"
testvm_META_O="src/meta/testvm-debug.o src/meta/testvm-debugger.o src/meta/testvm-opcodes.o src/test/testvm-sha1.o"
])
AC_SUBST(META_O)
AC_SUBST(testcpu_META_O)
AC_SUBST(testdisk_META_O)
AC_SUBST(testdisplay_META_O)
AC_SUBST(testprefs_META_O)
AC_SUBST(testtrace_META_O)
AC_SUBST(testvm_META_O)
AC_DEFINE(INTERFACE_CLASSIC, 1, [Use the classic menu interface])