Makefile 5.98 KB
Newer Older
1 2 3
# See LICENSE file for license and copyright information

include config.mk
4
include common.mk
5

6 7 8 9
PROJECT    = zathura
OSOURCE    = $(wildcard *.c)
HEADER     = $(wildcard *.h)
HEADERINST = version.h zathura.h document.h macros.h
10

11
ifneq (${WITH_SQLITE},0)
12 13
INCS   += $(SQLITE_INC)
LIBS   += $(SQLITE_LIB)
14 15
SOURCE = $(OSOURCE)
CPPFLAGS += -DWITH_SQLITE
16
else
17
SOURCE = $(filter-out database-sqlite.c,$(OSOURCE))
18
endif
19 20 21

ifneq ($(wildcard ${VALGRIND_SUPPRESSION_FILE}),)
VALGRIND_ARGUMENTS += --suppressions=${VALGRIND_SUPPRESSION_FILE}
22
endif
23

24 25 26
OBJECTS  = $(patsubst %.c, %.o,  $(SOURCE))
DOBJECTS = $(patsubst %.c, %.do, $(SOURCE))

27 28 29 30 31 32 33
all: options ${PROJECT} po build-manpages

girara-version-check:
ifneq ($(GIRARA_VERSION_CHECK), 0)
	$(error "The minimum required version of girara is ${GIRARA_MIN_VERSION}")
endif
	$(QUIET)touch girara-version-check
34 35 36 37 38 39 40 41

options:
	@echo ${PROJECT} build options:
	@echo "CFLAGS  = ${CFLAGS}"
	@echo "LIBS    = ${LIBS}"
	@echo "DFLAGS  = ${DFLAGS}"
	@echo "CC      = ${CC}"

42 43 44 45
version.h: version.h.in config.mk
	$(QUIET)sed 's/ZVMAJOR/${ZATHURA_VERSION_MAJOR}/' < version.h.in | \
		sed 's/ZVMINOR/${ZATHURA_VERSION_MINOR}/' | \
		sed 's/ZVREV/${ZATHURA_VERSION_REV}/' | \
46 47
		sed 's/ZVAPI/${ZATHURA_API_VERSION}/' | \
		sed 's/ZVABI/${ZATHURA_ABI_VERSION}/' > version.h
48

49
%.o: %.c
50
	$(ECHO) CC $<
51 52
	@mkdir -p .depend
	$(QUIET)${CC} -c ${CPPFLAGS} ${CFLAGS} -o $@ $< -MMD -MF .depend/$@.dep
53 54

%.do: %.c
55
	$(ECHO) CC $<
56 57
	@mkdir -p .depend
	$(QUIET)${CC} -c ${CPPFLAGS} ${CFLAGS} ${DFLAGS} -o $@ $< -MMD -MF .depend/$@.dep
58

59 60
${OBJECTS}:  config.mk version.h girara-version-check
${DOBJECTS}: config.mk version.h girara-version-check
61 62

${PROJECT}: ${OBJECTS}
63 64
	$(ECHO) CC -o $@
	$(QUIET)${CC} ${SFLAGS} ${LDFLAGS} -o $@ ${OBJECTS} ${LIBS}
65 66

clean:
67
	$(QUIET)rm -rf ${PROJECT} ${OBJECTS} ${PROJECT}-${VERSION}.tar.gz \
68
		${DOBJECTS} ${PROJECT}-debug .depend ${PROJECT}.pc doc version.h \
69 70
		*gcda *gcno $(PROJECT).info gcov *.tmp \
		girara-version-check
71
	$(QUIET)make -C tests clean
72
	$(QUIET)make -C po clean
73

74
${PROJECT}-debug: ${DOBJECTS}
75 76
	$(ECHO) CC -o $@
	$(QUIET)${CC} ${LDFLAGS} -o $@ ${DOBJECTS} ${LIBS}
77 78 79

debug: ${PROJECT}-debug

80 81 82
${PROJECT}.pc: ${PROJECT}.pc.in config.mk
	$(QUIET)echo project=${PROJECT} > ${PROJECT}.pc
	$(QUIET)echo version=${VERSION} >> ${PROJECT}.pc
83 84
	$(QUIET)echo apiversion=${ZATHURA_API_VERSION} >> ${PROJECT}.pc
	$(QUIET)echo abiversion=${ZATHURA_ABI_VERSION} >> ${PROJECT}.pc
85
	$(QUIET)echo includedir=${INCLUDEDIR} >> ${PROJECT}.pc
86 87 88 89
	$(QUIET)echo plugindir=${PLUGINDIR} >> ${PROJECT}.pc
	$(QUIET)echo GTK_VERSION=${ZATHURA_GTK_VERSION} >> ${PROJECT}.pc
	$(QUIET)cat ${PROJECT}.pc.in >> ${PROJECT}.pc

90
valgrind: debug
91 92
	 $(QUIET)G_SLICE=always-malloc G_DEBUG=gc-friendly ${VALGRIND} ${VALGRIND_ARGUMENTS} \
		 ./${PROJECT}-debug
93 94

gdb: debug
95
	$(QUIET)cgdb ${PROJECT}-debug
96

97 98 99
test: ${OBJECTS}
	$(QUIET)make -C tests run

100
dist: clean build-manpages
101
	$(QUIET)mkdir -p ${PROJECT}-${VERSION}
102
	$(QUIET)mkdir -p ${PROJECT}-${VERSION}/tests
103
	$(QUIET)mkdir -p ${PROJECT}-${VERSION}/po
104
	$(QUIET)cp LICENSE Makefile config.mk common.mk README AUTHORS Doxyfile \
105 106
			${PROJECT}.1.rst ${PROJECT}rc.5.rst ${OSOURCE} ${HEADER} ${PROJECT}.pc.in \
			${PROJECT}.desktop version.h.in \
107
			${PROJECT}.1 ${PROJECT}rc.5 \
108 109 110
			${PROJECT}-${VERSION}
	$(QUIET)cp tests/Makefile tests/config.mk tests/*.c \
			${PROJECT}-${VERSION}/tests
111
	$(QUIET)cp po/Makefile po/*.po ${PROJECT}-${VERSION}/po
112 113 114
	$(QUIET)tar -cf ${PROJECT}-${VERSION}.tar ${PROJECT}-${VERSION}
	$(QUIET)gzip ${PROJECT}-${VERSION}.tar
	$(QUIET)rm -rf ${PROJECT}-${VERSION}
115

116 117 118 119
doc:
	$(QUIET)doxygen Doxyfile

gcov: clean
120 121
	$(QUIET)CFLAGS="${CFLAGS} -fprofile-arcs -ftest-coverage" LDFLAGS="${LDFLAGS} -fprofile-arcs" ${MAKE} $(PROJECT)
	$(QUIET)CFLAGS="${CFLAGS} -fprofile-arcs -ftest-coverage" LDFLAGS="${LDFLAGS} -fprofile-arcs" ${MAKE} -C tests run
122 123 124
	$(QUIET)lcov --directory . --capture --output-file $(PROJECT).info
	$(QUIET)genhtml --output-directory gcov $(PROJECT).info

125 126 127 128 129 130
po:
	$(QUIET)${MAKE} -C po

update-po:
	$(QUIET)${MAKE} -C po update-po

131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154
ifneq "$(wildcard ${RSTTOMAN})" ""
%.1 %.5: config.mk
	$(QUIET)sed "s/VERSION/${VERSION}/g" < $@.rst > $@.tmp
	$(QUIET)${RSTTOMAN} $@.tmp > $@
	$(QUIET)rm $@.tmp

${PROJECT}.1: ${PROJECT}.1.rst
${PROJECT}rc.5: ${PROJECT}rc.5.rst

build-manpages: ${PROJECT}.1 ${PROJECT}rc.5
else
build-manpages:
endif

install-manpages: build-manpages
	$(ECHO) installing manual pages
	$(QUIET)mkdir -p ${DESTDIR}${MANPREFIX}/man1 ${DESTDIR}${MANPREFIX}/man5
ifneq "$(wildcard ${PROJECT}.1)" ""
	$(QUIET)install -m 644 ${PROJECT}.1 ${DESTDIR}${MANPREFIX}/man1
endif
ifneq "$(wildcard ${PROJECT}rc.5)" ""
	$(QUIET)install -m 644 ${PROJECT}rc.5 ${DESTDIR}${MANPREFIX}/man5
endif

155 156 157
install-headers: ${PROJECT}.pc
	$(ECHO) installing header files
	$(QUIET)mkdir -p ${DESTDIR}${INCLUDEDIR}/${PROJECT}
158
	$(QUIET)install -m 644 ${HEADERINST} ${DESTDIR}${INCLUDEDIR}/${PROJECT}
159 160 161 162
	$(ECHO) installing pkgconfig file
	$(QUIET)mkdir -p ${DESTDIR}${LIBDIR}/pkgconfig
	$(QUIET)install -m 644 ${PROJECT}.pc ${DESTDIR}${LIBDIR}/pkgconfig

163
install: all install-headers install-manpages
164 165 166 167 168 169
	$(ECHO) installing executable file
	$(QUIET)mkdir -p ${DESTDIR}${PREFIX}/bin
	$(QUIET)install -m 755 ${PROJECT} ${DESTDIR}${PREFIX}/bin
	$(QUIET)mkdir -p ${DESTDIR}${DESKTOPPREFIX}
	$(ECHO) installing desktop file
	$(QUIET)install -m 644 ${PROJECT}.desktop ${DESTDIR}${DESKTOPPREFIX}
170 171 172 173 174 175 176
	$(MAKE) -C po install

uninstall-headers:
	$(ECHO) removing header files
	$(QUIET)rm -rf ${DESTDIR}${INCLUDEDIR}/${PROJECT}
	$(ECHO) removing pkgconfig file
	$(QUIET)rm -f ${DESTDIR}${LIBDIR}/pkgconfig/${PROJECT}.pc
177 178

uninstall:
179 180
	$(ECHO) removing executable file
	$(QUIET)rm -f ${DESTDIR}${PREFIX}/bin/${PROJECT}
181
	$(ECHO) removing manual pages
182 183 184 185
	$(QUIET)rm -f ${DESTDIR}${MANPREFIX}/man1/${PROJECT}.1
	$(QUIET)rm -f ${DESTDIR}${MANPREFIX}/man5/${PROJECT}rc.5
	$(ECHO) removing desktop file
	$(QUIET)rm -f ${DESTDIR}${DESKTOPPREFIX}/${PROJECT}.desktop
186
	$(MAKE) -C po uninstall
187 188 189

-include $(wildcard .depend/*.dep)

190
.PHONY: all options clean doc debug valgrind gdb dist doc install uninstall test \
191
	po install-headers uninstall-headers update-po install-manpages build-manpages