1# Copyright (c) 2010 Red Hat, Inc. 2# 3# Authors: Angus Salkeld <asalkeld@redhat.com> 4# 5# This file is part of libqb. 6# 7# libqb is free software: you can redistribute it and/or modify 8# it under the terms of the GNU Lesser General Public License as published by 9# the Free Software Foundation, either version 2.1 of the License, or 10# (at your option) any later version. 11# 12# libqb is distributed in the hope that it will be useful, 13# but WITHOUT ANY WARRANTY; without even the implied warranty of 14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15# GNU Lesser General Public License for more details. 16# 17# You should have received a copy of the GNU Lesser General Public License 18# along with libqb. If not, see <http://www.gnu.org/licenses/>. 19# 20MAINTAINERCLEANFILES = Makefile.in 21EXTRA_DIST = 22CLEANFILES = 23 24export SOCKETDIR 25 26AM_CPPFLAGS = -I$(top_builddir)/include -I$(top_srcdir)/include 27 28noinst_PROGRAMS = bmc bmcpt bms rbreader rbwriter \ 29 bench-log format_compare_speed loop print_ver \ 30 $(check_PROGRAMS) 31 32noinst_HEADERS = check_common.h 33 34format_compare_speed_SOURCES = format_compare_speed.c $(top_builddir)/include/qb/qbutil.h 35format_compare_speed_LDADD = $(top_builddir)/lib/libqb.la 36 37bmc_SOURCES = bmc.c 38bmc_LDADD = $(top_builddir)/lib/libqb.la 39 40bmcpt_SOURCES = bmcpt.c 41bmcpt_LDADD = $(top_builddir)/lib/libqb.la 42 43bms_SOURCES = bms.c 44bms_CFLAGS = $(GLIB_CFLAGS) 45bms_LDADD = $(top_builddir)/lib/libqb.la $(GLIB_LIBS) 46 47rbwriter_SOURCES = rbwriter.c 48rbwriter_LDADD = $(top_builddir)/lib/libqb.la 49 50rbreader_SOURCES = rbreader.c 51rbreader_LDADD = $(top_builddir)/lib/libqb.la 52 53loop_SOURCES = loop.c 54loop_LDADD = $(top_builddir)/lib/libqb.la 55 56inc_dir = $(top_srcdir)/include/qb 57public_headers = $(sort $(patsubst %.in,%,$(subst $(inc_dir)/,,$(shell \ 58 printf 'include $(inc_dir)/Makefile.am\n\n%%.var:\n\t@echo $$($$*)' \ 59 | MAKEFLAGS= ${MAKE} --no-print-directory -f- inst_HEADERS.var \ 60 || echo $(inc_dir)/qb*.h*)))) 61auto_c_files = $(patsubst %.h,auto_check_header_%.c,$(public_headers)) 62CLEANFILES += $(auto_c_files) 63 64# this works for both non/generated headers thanks to VPATH being 65# automatically set to $(top_srcdir)/tests and $(top_builddir) 66# being resolved to ".." by automake 67# ($(top_srcdir)/tests/../include/qb/%.h = $(top_srcdir)/include/qb/%.h) 68auto_check_header_%.c: $(top_builddir)/include/qb/%.h 69 @name=$$(echo "$<" | sed "s|.*qb/qb||" | sed "s|\.h||") ;\ 70 NAME=$$(echo $$name | tr [:lower:] [:upper:]) ;\ 71 echo "#include <qb/qb$$name.h>" > $@_ ;\ 72 echo "#ifndef QB_$${NAME}_H_DEFINED" >> $@_ ;\ 73 echo "#error no header protector in file qb$$name.h" >> $@_ ;\ 74 echo "#endif" >> $@_ ;\ 75 echo "int main(void) {return 0;}" >> $@_ 76 $(AM_V_GEN)mv $@_ $@ 77 78check: check-headers 79 80# rely on implicit automake rule to include right (local) includes 81.PHONY: check-headers 82check-headers: $(auto_c_files:.c=.o) $(auto_c_files:.c=.opp) 83 84# this is to check basic sanity of using libqb from C++ code, if possible 85%.opp: %.c 86if HAVE_GXX 87 $(AM_V_GEN)$(CXX) $(AM_CPPFLAGS) -c $(CPPFLAGS) $(CXXFLAGS) -o $@ $< 88else 89 @echo "C++ compatibility tests not run" 90endif 91 92CLEANFILES += ${auto_c_files:.c=.opp} 93 94distclean-local: 95 rm -rf auto_*.c 96 rm -rf .deps 97 98if HAVE_DICT_WORDS 99if HAVE_SLOW_TESTS 100EXTRA_DIST += make-log-test.sh 101CLEANFILES += auto_write_logs.c 102MAINTAINERCLEANFILES += auto_write_logs.c 103 104nodist_bench_log_SOURCES = auto_write_logs.c 105 106bench_log: auto_write_logs.c 107$(builddir)/auto_write_logs.c: make-log-test.sh 108 @$(srcdir)/make-log-test.sh > $(builddir)/write_logs-tmp.c 109 $(AM_V_GEN)mv $(builddir)/write_logs-tmp.c $(builddir)/auto_write_logs.c 110endif 111endif 112 113bench_log_SOURCES = bench-log.c 114bench_log_LDADD = $(top_builddir)/lib/libqb.la 115 116if HAVE_CHECK 117EXTRA_DIST += start.test resources.test 118EXTRA_DIST += blackbox-segfault.sh 119 120TESTS = start.test array.test map.test rb.test list.test log.test blackbox-segfault.sh loop.test ipc.test resources.test 121TESTS_ENVIRONMENT = export PATH=.:../tools:$$PATH; 122 123resources.log: rb.log log.log ipc.log 124 125check_LTLIBRARIES = 126check_PROGRAMS = array.test ipc.test list.test log.test loop.test \ 127 map.test rb.test util.test \ 128 crash_test_dummy file_change_bytes 129dist_check_SCRIPTS = start.test resources.test blackbox-segfault.sh 130 131if HAVE_SLOW_TESTS 132TESTS += util.test 133check_PROGRAMS += util.test 134endif 135 136if INSTALL_TESTS 137testsuitedir = $(TESTDIR) 138testsuite_PROGRAMS = $(check_PROGRAMS) 139testsuite_SCRIPTS = $(dist_check_SCRIPTS) test.conf 140endif 141 142file_change_bytes_SOURCES = file_change_bytes.c 143 144crash_test_dummy_SOURCES = crash_test_dummy.c 145crash_test_dummy_CFLAGS = @CHECK_CFLAGS@ 146crash_test_dummy_LDADD = $(top_builddir)/lib/libqb.la @CHECK_LIBS@ 147 148array_test_SOURCES = check_array.c 149array_test_CFLAGS = @CHECK_CFLAGS@ 150array_test_LDADD = $(top_builddir)/lib/libqb.la @CHECK_LIBS@ 151 152map_test_SOURCES = check_map.c 153map_test_CFLAGS = @CHECK_CFLAGS@ 154map_test_LDADD = $(top_builddir)/lib/libqb.la @CHECK_LIBS@ 155 156rb_test_SOURCES = check_rb.c 157rb_test_CFLAGS = @CHECK_CFLAGS@ 158rb_test_LDADD = $(top_builddir)/lib/libqb.la @CHECK_LIBS@ 159 160loop_test_SOURCES = check_loop.c 161loop_test_CFLAGS = @CHECK_CFLAGS@ 162loop_test_LDADD = $(top_builddir)/lib/libqb.la @CHECK_LIBS@ 163 164ipc_test_SOURCES = check_ipc.c 165ipc_test_CFLAGS = @CHECK_CFLAGS@ 166ipc_test_LDADD = $(top_builddir)/lib/libqb.la @CHECK_LIBS@ 167if HAVE_FAILURE_INJECTION 168ipc_test_LDADD += _failure_injection.la 169 170if HAVE_GLIB 171ipc_test_CFLAGS += $(GLIB_CFLAGS) 172ipc_test_LDADD += $(GLIB_LIBS) 173endif 174 175check_LTLIBRARIES += _failure_injection.la 176_failure_injection_la_SOURCES = _failure_injection.c _failure_injection.h 177_failure_injection_la_LDFLAGS = -module 178_failure_injection_la_LIBADD = $(dlopen_LIBS) 179endif 180 181check_LTLIBRARIES += _syslog_override.la 182_syslog_override_la_SOURCES = _syslog_override.c _syslog_override.h 183_syslog_override_la_LDFLAGS = -module 184 185log_test_SOURCES = check_log.c 186log_test_CFLAGS = @CHECK_CFLAGS@ 187log_test_LDADD = $(top_builddir)/lib/libqb.la @CHECK_LIBS@ 188log_test_LDADD += _syslog_override.la 189 190util_test_SOURCES = check_util.c 191util_test_CFLAGS = @CHECK_CFLAGS@ 192util_test_LDADD = $(top_builddir)/lib/libqb.la @CHECK_LIBS@ 193 194list_test_SOURCES = check_list.c 195list_test_CFLAGS = @CHECK_CFLAGS@ 196list_test_LDADD = $(top_builddir)/lib/libqb.la @CHECK_LIBS@ 197 198endif 199 200clean-local: 201 rm -f *.log 202 rm -f *.fdata 203