zathura/tests/Makefile
Sebastian Ramacher 66805ec2eb Query pkg-config only once for libs and cflags
Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
2017-07-02 19:09:34 +02:00

132 lines
3.8 KiB
Makefile

# See LICENSE file for license and copyright information
include ../config.mk
include ../colors.mk
include ../common.mk
include config.mk
PROJECT = tests
SOURCE = tests.c $(wildcard test_*.c)
OBJECTS = $(addprefix ${BUILDDIR_RELEASE}/,${SOURCE:.c=.o})
OBJECTS_DEBUG = $(addprefix ${BUILDDIR_DEBUG}/,${SOURCE:.c=.o})
OBJECTS_GCOV = $(addprefix ${BUILDDIR_GCOV}/,${SOURCE:.c=.o})
FILTER = %/main.o
ifneq (${WITH_SQLITE},0)
CPPFLAGS += -DWITH_SQLITE
else
FILTER += %/database-sqlite.o
endif
ifneq ($(WITH_MAGIC),0)
CPPFLAGS += -DWITH_MAGIC
endif
ifneq ($(WITH_SYNCTEX),0)
CPPFLAGS += -DWITH_SYNCTEX
endif
ZATHURA_OBJECTS = \
$(filter-out $(FILTER), $(wildcard ../${BUILDDIR_RELEASE}/zathura/*.o))
ZATHURA_OBJECTS_DEBUG = \
$(filter-out $(FILTER), $(wildcard ../${BUILDDIR_DEBUG}/zathura/*.o))
ZATHURA_OBJECTS_GCOV= \
$(filter-out $(FILTER), $(wildcard ../${BUILDDIR_GCOV}/zathura/*.o))
ifneq ($(wildcard ${VALGRIND_SUPPRESSION_FILE}),)
VALGRIND_ARGUMENTS += --suppressions=${VALGRIND_SUPPRESSION_FILE}
endif
all: release
# release
${OBJECTS}: config.mk ../config.mk ../zathura/version.h
${BUILDDIR_RELEASE}/%.o: %.c
$(call colorecho,CC,$<)
@mkdir -p ${DEPENDDIR}/$(dir $(abspath $@))
@mkdir -p $(dir $(abspath $@))
$(QUIET)${CC} -c ${CPPFLAGS} ${CFLAGS} \
-o $@ $< -MMD -MF ${DEPENDDIR}/$(abspath $@).dep
${BUILDDIR_RELEASE}/${BINDIR}/${PROJECT}: ${OBJECTS}
$(QUIET)${MAKE} WITH_LIBFIU=1 -C .. ${BUILDDIR_RELEASE}/${BINDIR}/zathura
$(call colorecho,CC,$@)
@mkdir -p ${BUILDDIR_RELEASE}/${BINDIR}
$(QUIET)${CC} ${SFLAGS} ${LDFLAGS} \
-o ${BUILDDIR_RELEASE}/${BINDIR}/${PROJECT} \
${OBJECTS} ${ZATHURA_OBJECTS} ${LIBS}
release: ${BUILDDIR_RELEASE}/${BINDIR}/${PROJECT}
run: ${BUILDDIR_RELEASE}/${BINDIR}/${PROJECT}
$(QUIET)${FIU_EXEC} ./${BUILDDIR_RELEASE}/${BINDIR}/${PROJECT}
# debug
${OBJECTS_DEBUG}: config.mk ../config.mk ../zathura/version.h
${BUILDDIR_DEBUG}/%.o: %.c
@mkdir -p ${DEPENDDIR}/$(dir $(abspath $@))
@mkdir -p $(dir $(abspath $@))
$(call colorecho,CC,$<)
$(QUIET)${CC} -c ${CPPFLAGS} ${CFLAGS} ${DFLAGS} \
-o $@ $< -MMD -MF ${DEPENDDIR}/$(abspath $@).dep
${BUILDDIR_DEBUG}/${BINDIR}/${PROJECT}: ${OBJECTS_DEBUG}
$(QUIET)${MAKE} WITH_LIBFIU=1 -C .. ${BUILDDIR_DEBUG}/${BINDIR}/zathura
$(call colorecho,CC,$@)
@mkdir -p ${BUILDDIR_DEBUG}/${BINDIR}
$(QUIET)${CC} ${SFLAGS} ${LDFLAGS} \
-o ${BUILDDIR_DEBUG}/${BINDIR}/${PROJECT} \
${OBJECTS} ${ZATHURA_OBJECTS_DEBUG} ${LIBS}
debug: ${BUILDDIR_DEBUG}/${BINDIR}/${PROJECT}
run-debug: ${BUILDDIR_DEBUG}/${BINDIR}/${PROJECT}
$(QUIET)${FIU_EXEC} ./${BUILDDIR_DEBUG}/${BINDIR}/${PROJECT}
# gcov
${OBJECTS_GCOV}: config.mk ../config.mk ../zathura/version.h
${BUILDDIR_GCOV}/%.o: %.c
@mkdir -p ${DEPENDDIR}/$(dir $(abspath $@))
@mkdir -p $(dir $(abspath $@))
$(call colorecho,CC,$<)
$(QUIET)${CC} -c ${CPPFLAGS} ${CFLAGS} ${GCOV_CFLAGS} ${DFLAGS} ${GCOV_DFLAGS} \
-o $@ $< -MMD -MF ${DEPENDDIR}/$(abspath $@).dep
${BUILDDIR_GCOV}/${BINDIR}/${PROJECT}: ${OBJECTS_GCOV}
$(QUIET)${MAKE} WITH_LIBFIU=1 -C .. ${BUILDDIR_GCOV}/${BINDIR}/zathura
$(call colorecho,CC,$@)
@mkdir -p ${BUILDDIR_GCOV}/${BINDIR}
$(QUIET)${CC} ${SFLAGS} ${LDFLAGS} ${GCOV_CFLAGS} ${GCOV_LDFLAGS} \
-o ${BUILDDIR_GCOV}/${BINDIR}/${PROJECT} \
${OBJECTS} ${ZATHURA_OBJECTS_GCOV} ${LIBS}
gcov: ${BUILDDIR_GCOV}/${BINDIR}/${PROJECT}
run-gcov: gcov
$(QUIET)${FIU_EXEC} ./${BUILDDIR_GCOV}/${BINDIR}/${PROJECT}
../zathura/version.h:
$(MAKE) -C .. zathura/version.h
valgrind: ${PROJECT}-debug
$(QUIET)G_SLICE=always-malloc G_DEBUG=gc-friendly ${FIU_EXEC} ${VALGRIND} ${VALGRIND_ARGUMENTS} ./${PROJECT}-debug
clean:
$(call colorecho,RM, "Clean test files")
$(QUIET)rm -rf ${PROJECT}
$(QUIET)rm -rf ${PROJECT}-debug
$(QUIET)rm -rf ${PROJECT}-gcov
$(QUIET)rm -rf ${BUILDDIR}
$(QUIET)rm -rf ${DEPENDDIR}
.PHONY: all clean debug run
-include $(wildcard ${DEPENDDIR}/*.dep)