diff options
author | Andrea Canciani <ranma42@gmail.com> | 2011-09-04 20:07:42 +0200 |
---|---|---|
committer | Andrea Canciani <ranma42@gmail.com> | 2011-09-14 07:03:34 -0700 |
commit | efdf65c0c4fff551fb3cd9104deda9adb6261e22 (patch) | |
tree | fb950d13933817733ec50b0f950b1b8df3e3f880 | |
parent | a4f95d083b1aa644923d79e7b61df6c2eacca7c2 (diff) |
build: Reuse test sources
Makefile.am and Makefile.win32 should not duplicate content, as this
leads to breaking the build when they are not kept in sync.
This can be avoided by listing sources, headers and common build
variables/rules in a Makefile.sources file.
In order to further simplify the test makefiles, the utility functions
are now in a static library, which gets linked to all the tests and
benchmarks.
-rw-r--r-- | test/Makefile.am | 47 | ||||
-rw-r--r-- | test/Makefile.sources | 36 | ||||
-rw-r--r-- | test/Makefile.win32 | 64 |
3 files changed, 58 insertions, 89 deletions
diff --git a/test/Makefile.am b/test/Makefile.am index 6687bed3..4268cd7c 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -1,50 +1,13 @@ +include $(top_srcdir)/test/Makefile.sources + AM_CFLAGS = @OPENMP_CFLAGS@ AM_LDFLAGS = @OPENMP_CFLAGS@ @TESTPROGS_EXTRA_LDFLAGS@ -LDADD = $(top_builddir)/pixman/libpixman-1.la -lm @PNG_LIBS@ +LDADD = $(top_builddir)/pixman/libpixman-1.la libutils.la -lm @PNG_LIBS@ INCLUDES = -I$(top_srcdir)/pixman -I$(top_builddir)/pixman @PNG_CFLAGS@ -TESTPROGRAMS = \ - a1-trap-test \ - pdf-op-test \ - region-test \ - region-translate-test \ - fetch-test \ - oob-test \ - trap-crasher \ - alpha-loop \ - scaling-crash-test \ - scaling-helpers-test \ - gradient-crash-test \ - region-contains-test \ - alphamap \ - stress-test \ - composite-traps-test \ - blitters-test \ - scaling-test \ - affine-test \ - composite - -pdf_op_test_SOURCES = pdf-op-test.c utils.c utils.h -region_test_SOURCES = region-test.c utils.c utils.h -blitters_test_SOURCES = blitters-test.c utils.c utils.h -region_contains_test_SOURCES = region-contains-test.c utils.c utils.h -composite_traps_test_SOURCES = composite-traps-test.c utils.c utils.h -scaling_test_SOURCES = scaling-test.c utils.c utils.h -affine_test_SOURCES = affine-test.c utils.c utils.h -alphamap_SOURCES = alphamap.c utils.c utils.h -alpha_loop_SOURCES = alpha-loop.c utils.c utils.h -composite_SOURCES = composite.c utils.c utils.h -gradient_crash_test_SOURCES = gradient-crash-test.c utils.c utils.h -stress_test_SOURCES = stress-test.c utils.c utils.h -scaling_helpers_test_SOURCES = scaling-helpers-test.c utils.c utils.h - -# Benchmarks - -BENCHMARKS = \ - lowlevel-blt-bench - -lowlevel_blt_bench_SOURCES = lowlevel-blt-bench.c utils.c utils.h +libutils_la_SOURCES = $(libutils_sources) $(libutils_headers) +noinst_LTLIBRARIES = libutils.la noinst_PROGRAMS = $(TESTPROGRAMS) $(BENCHMARKS) TESTS = $(TESTPROGRAMS) diff --git a/test/Makefile.sources b/test/Makefile.sources new file mode 100644 index 00000000..99eb705a --- /dev/null +++ b/test/Makefile.sources @@ -0,0 +1,36 @@ +# Tests (sorted by expected completion time) +TESTPROGRAMS = \ + a1-trap-test \ + pdf-op-test \ + region-test \ + region-translate-test \ + fetch-test \ + oob-test \ + trap-crasher \ + alpha-loop \ + scaling-crash-test \ + scaling-helpers-test \ + gradient-crash-test \ + region-contains-test \ + alphamap \ + stress-test \ + composite-traps-test \ + blitters-test \ + scaling-test \ + affine-test \ + composite \ + $(NULL) + +# Benchmarks +BENCHMARKS = \ + lowlevel-blt-bench \ + $(NULL) + +# Utility functions +libutils_sources = \ + utils.c \ + $(NULL) + +libutils_headers = \ + utils.h \ + $(NULL) diff --git a/test/Makefile.win32 b/test/Makefile.win32 index a62b6fc3..215fb046 100644 --- a/test/Makefile.win32 +++ b/test/Makefile.win32 @@ -1,3 +1,8 @@ +default: all + +top_srcdir = .. +include $(top_srcdir)/test/Makefile.sources + CC = cl LINK = link @@ -7,7 +12,7 @@ CFG_VAR=release endif CFLAGS = -MD -nologo -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE -D_BIND_TO_CURRENT_VCLIBS_VERSION -D_MT -I../pixman -I. -I../ -TEST_LDADD = ../pixman/$(CFG_VAR)/pixman-1.lib +TEST_LDADD = ../pixman/$(CFG_VAR)/pixman-1.lib $(CFG_VAR)/libutils.lib INCLUDES = -I../pixman -I$(top_builddir)/pixman # optimization flags @@ -17,60 +22,25 @@ else CFLAGS += -O2 endif -SOURCES = \ - a1-trap-test.c \ - pdf-op-test.c \ - region-test.c \ - region-translate-test.c \ - fetch-test.c \ - oob-test.c \ - trap-crasher.c \ - alpha-loop.c \ - scaling-crash-test.c \ - gradient-crash-test.c \ - alphamap.c \ - stress-test.c \ - composite-traps-test.c \ - blitters-test.c \ - scaling-test.c \ - affine-test.c \ - composite.c \ - lowlevel-blt-bench.c \ - utils.c +libutils_OBJECTS = $(patsubst %.c, $(CFG_VAR)/%.obj, $(libutils_sources)) -TESTS = \ - $(CFG_VAR)/a1-trap-test.exe \ - $(CFG_VAR)/pdf-op-test.exe \ - $(CFG_VAR)/region-test.exe \ - $(CFG_VAR)/region-translate-test.exe \ - $(CFG_VAR)/fetch-test.exe \ - $(CFG_VAR)/oob-test.exe \ - $(CFG_VAR)/trap-crasher.exe \ - $(CFG_VAR)/alpha-loop.exe \ - $(CFG_VAR)/scaling-crash-test.exe \ - $(CFG_VAR)/gradient-crash-test.exe \ - $(CFG_VAR)/alphamap.exe \ - $(CFG_VAR)/stress-test.exe \ - $(CFG_VAR)/composite-traps-test.exe \ - $(CFG_VAR)/blitters-test.exe \ - $(CFG_VAR)/scaling-test.exe \ - $(CFG_VAR)/affine-test.exe \ - $(CFG_VAR)/composite.exe +SOURCES = $(patsubst %, %.c, $(TESTPROGRAMS) $(BENCHMARKS)) +OBJECTS = $(patsubst %.c, $(CFG_VAR)/%.obj, $(SOURCES)) +TESTS = $(patsubst %, $(CFG_VAR)/%.exe, $(TESTPROGRAMS)) +BENCHS = $(patsubst %, $(CFG_VAR)/%.exe, $(BENCHMARKS)) -BENCHMARKS = \ - $(CFG_VAR)/lowlevel-blt-bench.exe -OBJECTS = $(patsubst %.c, $(CFG_VAR)/%.obj, $(SOURCES)) +all: $(TESTS) $(BENCHS) + +$(CFG_VAR)/libutils.lib: $(libutils_OBJECTS) + @lib -NOLOGO -OUT:$@ $^ || exit 0 $(CFG_VAR)/%.obj: %.c @mkdir -p $(CFG_VAR) @$(CC) -c $(CFLAGS) -Fo"$@" $< -$(CFG_VAR)/%.exe: $(CFG_VAR)/%.obj - $(LINK) /NOLOGO /OUT:$@ $< $(CFG_VAR)/utils.obj $(TEST_LDADD) - -all: $(OBJECTS) $(TESTS) $(BENCHMARKS) - @exit 0 +$(CFG_VAR)/%.exe: $(CFG_VAR)/%.obj $(TEST_LDADD) + @$(LINK) /NOLOGO /OUT:$@ $^ clean: @rm -f $(CFG_VAR)/*.obj $(CFG_VAR)/*.pdb || exit 0 |