Makefile 6.93 KB
Newer Older
1
# See LICENSE file for license and copyright information
Moritz Lipp's avatar
Moritz Lipp committed
2

3
include config.mk
4
include common.mk
Moritz Lipp's avatar
Moritz Lipp committed
5

Sebastian Ramacher's avatar
Sebastian Ramacher committed
6 7 8
PROJECT    = zathura
OSOURCE    = $(wildcard *.c)
HEADER     = $(wildcard *.h)
Moritz Lipp's avatar
Moritz Lipp committed
9
HEADERINST = version.h document.h macros.h page.h types.h plugin-api.h links.h
10

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

20 21 22 23 24 25
ifneq ($(WITH_MAGIC),0)
INCS += $(MAGIC_INC)
LIBS += $(MAGIC_LIB)
CPPFLAGS += -DWITH_MAGIC
endif

26 27 28 29
ifneq ($(wildcard ${VALGRIND_SUPPRESSION_FILE}),)
VALGRIND_ARGUMENTS += --suppressions=${VALGRIND_SUPPRESSION_FILE}
endif

30 31 32 33 34 35 36 37 38 39
ifeq (,$(findstring -DZATHURA_PLUGINDIR,${CPPFLAGS}))
CPPFLAGS += -DZATHURA_PLUGINDIR=\"${PLUGINDIR}\"
endif
ifeq (,$(findstring -DGETTEXT_PACKAGE,${CPPFLAGS}))
CPPFLAGS += -DGETTEXT_PACKAGE=\"${PROJECT}\"
endif
ifeq (,$(findstring -DLOCALEDIR,${CPPFLAGS}))
CPPFLAGS += -DLOCALEDIR=\"${LOCALEDIR}\"
endif

40 41 42
OBJECTS  = $(patsubst %.c, %.o,  $(SOURCE))
DOBJECTS = $(patsubst %.c, %.do, $(SOURCE))

43
all: options ${PROJECT} po build-manpages
44

45 46 47 48 49 50 51 52 53
# pkg-config based version checks
.version-checks/%:
	$(QUIET)test $($(*)_VERSION_CHECK) -eq 0 || \
		pkg-config --atleast-version $($(*)_MIN_VERSION) $($(*)_PKG_CONFIG_NAME) || ( \
		echo "The minium required version of $(*) is $($(*)_MIN_VERSION)" && \
		false \
	)
	@mkdir -p .version-checks
	$(QUIET)touch $@
54

55
options:
Moritz Lipp's avatar
Moritz Lipp committed
56
	@echo ${PROJECT} build options:
57
	@echo "CFLAGS  = ${CFLAGS}"
Moritz Lipp's avatar
Moritz Lipp committed
58
	@echo "LIBS    = ${LIBS}"
59 60 61
	@echo "DFLAGS  = ${DFLAGS}"
	@echo "CC      = ${CC}"

62
version.h: version.h.in config.mk
Sebastian Ramacher's avatar
Sebastian Ramacher committed
63 64 65 66 67
	$(QUIET)sed -e 's/ZVMAJOR/${ZATHURA_VERSION_MAJOR}/' \
		-e 's/ZVMINOR/${ZATHURA_VERSION_MINOR}/' \
		-e 's/ZVREV/${ZATHURA_VERSION_REV}/' \
		-e 's/ZVAPI/${ZATHURA_API_VERSION}/' \
		-e 's/ZVABI/${ZATHURA_ABI_VERSION}/' version.h.in > version.h
68

69
%.o: %.c
70
	$(ECHO) CC $<
Sebastian Ramacher's avatar
Sebastian Ramacher committed
71
	@mkdir -p .depend
Sebastian Ramacher's avatar
Sebastian Ramacher committed
72
	$(QUIET)${CC} -c ${CPPFLAGS} ${CFLAGS} -o $@ $< -MMD -MF .depend/$@.dep
73 74

%.do: %.c
75
	$(ECHO) CC $<
Sebastian Ramacher's avatar
Sebastian Ramacher committed
76
	@mkdir -p .depend
Sebastian Ramacher's avatar
Sebastian Ramacher committed
77
	$(QUIET)${CC} -c ${CPPFLAGS} ${CFLAGS} ${DFLAGS} -o $@ $< -MMD -MF .depend/$@.dep
78

79 80
${OBJECTS} ${DOBJECTS}: config.mk version.h \
	.version-checks/GIRARA .version-checks/GLIB .version-checks/GTK
81 82

${PROJECT}: ${OBJECTS}
83 84
	$(ECHO) CC -o $@
	$(QUIET)${CC} ${SFLAGS} ${LDFLAGS} -o $@ ${OBJECTS} ${LIBS}
Moritz Lipp's avatar
Moritz Lipp committed
85 86

clean:
87
	$(QUIET)rm -rf ${PROJECT} ${OBJECTS} ${PROJECT}-${VERSION}.tar.gz \
88
		${DOBJECTS} ${PROJECT}-debug .depend ${PROJECT}.pc doc version.h \
89
		*gcda *gcno $(PROJECT).info gcov *.tmp \
90
		.version-checks
91 92 93
ifneq "$(wildcard ${RSTTOMAN})" ""
	$(QUIET)rm -f zathura.1 zathurarc.5
endif
94 95
	$(QUIET)$(MAKE) -C tests clean
	$(QUIET)$(MAKE) -C po clean
96 97

${PROJECT}-debug: ${DOBJECTS}
98 99
	$(ECHO) CC -o $@
	$(QUIET)${CC} ${LDFLAGS} -o $@ ${DOBJECTS} ${LIBS}
Moritz Lipp's avatar
Moritz Lipp committed
100

101
debug: ${PROJECT}-debug
Moritz Lipp's avatar
Moritz Lipp committed
102

103
${PROJECT}.pc: ${PROJECT}.pc.in config.mk
104 105
	$(QUIET)echo project=${PROJECT} > ${PROJECT}.pc
	$(QUIET)echo version=${VERSION} >> ${PROJECT}.pc
Sebastian Ramacher's avatar
Sebastian Ramacher committed
106
	$(QUIET)echo apiversion=${ZATHURA_API_VERSION} >> ${PROJECT}.pc
Sebastian Ramacher's avatar
Sebastian Ramacher committed
107
	$(QUIET)echo abiversion=${ZATHURA_ABI_VERSION} >> ${PROJECT}.pc
108
	$(QUIET)echo includedir=${INCLUDEDIR} >> ${PROJECT}.pc
109
	$(QUIET)echo plugindir=${PLUGINDIR} >> ${PROJECT}.pc
110
	$(QUIET)echo GTK_VERSION=${ZATHURA_GTK_VERSION} >> ${PROJECT}.pc
111
	$(QUIET)cat ${PROJECT}.pc.in >> ${PROJECT}.pc
112

113
valgrind: debug
114 115
	 $(QUIET)G_SLICE=always-malloc G_DEBUG=gc-friendly ${VALGRIND} ${VALGRIND_ARGUMENTS} \
		 ./${PROJECT}-debug
116 117

gdb: debug
Moritz Lipp's avatar
Moritz Lipp committed
118
	$(QUIET)cgdb ${PROJECT}-debug
119

120
test: ${OBJECTS}
121
	$(QUIET)make -C tests run
122

123
dist: clean build-manpages
Sebastian Ramacher's avatar
Sebastian Ramacher committed
124
	$(QUIET)mkdir -p ${PROJECT}-${VERSION}
Sebastian Ramacher's avatar
Sebastian Ramacher committed
125
	$(QUIET)mkdir -p ${PROJECT}-${VERSION}/tests
126
	$(QUIET)mkdir -p ${PROJECT}-${VERSION}/po
Sebastian Ramacher's avatar
Sebastian Ramacher committed
127
	$(QUIET)cp LICENSE Makefile config.mk common.mk README AUTHORS Doxyfile \
128
			${PROJECT}.1.rst ${PROJECT}rc.5.rst ${OSOURCE} ${HEADER} ${PROJECT}.pc.in \
129
			${PROJECT}.desktop version.h.in \
130
			${PROJECT}.1 ${PROJECT}rc.5 \
131
			org.pwmt.zathura.synxtex.xml \
Sebastian Ramacher's avatar
Sebastian Ramacher committed
132
			${PROJECT}-${VERSION}
Sebastian Ramacher's avatar
Sebastian Ramacher committed
133
	$(QUIET)cp tests/Makefile tests/config.mk tests/*.c \
Sebastian Ramacher's avatar
Sebastian Ramacher committed
134
			${PROJECT}-${VERSION}/tests
135
	$(QUIET)cp po/Makefile po/*.po ${PROJECT}-${VERSION}/po
136 137 138
	$(QUIET)tar -cf ${PROJECT}-${VERSION}.tar ${PROJECT}-${VERSION}
	$(QUIET)gzip ${PROJECT}-${VERSION}.tar
	$(QUIET)rm -rf ${PROJECT}-${VERSION}
Moritz Lipp's avatar
Moritz Lipp committed
139

Sebastian Ramacher's avatar
Sebastian Ramacher committed
140
doc:
141 142
	$(QUIET)doxygen Doxyfile

143
gcov: clean
144 145
	$(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
146 147 148
	$(QUIET)lcov --directory . --capture --output-file $(PROJECT).info
	$(QUIET)genhtml --output-directory gcov $(PROJECT).info

149 150 151
po:
	$(QUIET)${MAKE} -C po

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

155 156 157
ifneq "$(wildcard ${RSTTOMAN})" ""
%.1 %.5: config.mk
	$(QUIET)sed "s/VERSION/${VERSION}/g" < $@.rst > $@.tmp
158 159
	$(QUIET)${RSTTOMAN} $@.tmp > $@.out.tmp
	$(QUIET)mv $@.out.tmp $@
160 161 162 163 164 165
	$(QUIET)rm $@.tmp

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

build-manpages: ${PROJECT}.1 ${PROJECT}rc.5
166 167 168
else
build-manpages:
endif
169 170 171

install-manpages: build-manpages
	$(ECHO) installing manual pages
Sebastian Ramacher's avatar
Sebastian Ramacher committed
172
	$(QUIET)mkdir -m 755 -p ${DESTDIR}${MANPREFIX}/man1 ${DESTDIR}${MANPREFIX}/man5
173
ifneq "$(wildcard ${PROJECT}.1)" ""
174
	$(QUIET)install -m 644 ${PROJECT}.1 ${DESTDIR}${MANPREFIX}/man1
175 176
endif
ifneq "$(wildcard ${PROJECT}rc.5)" ""
177
	$(QUIET)install -m 644 ${PROJECT}rc.5 ${DESTDIR}${MANPREFIX}/man5
178
endif
179

180 181
install-headers: ${PROJECT}.pc
	$(ECHO) installing header files
Sebastian Ramacher's avatar
Sebastian Ramacher committed
182
	$(QUIET)mkdir -m 755 -p ${DESTDIR}${INCLUDEDIR}/${PROJECT}
Sebastian Ramacher's avatar
Sebastian Ramacher committed
183
	$(QUIET)install -m 644 ${HEADERINST} ${DESTDIR}${INCLUDEDIR}/${PROJECT}
184
	$(ECHO) installing pkgconfig file
Sebastian Ramacher's avatar
Sebastian Ramacher committed
185
	$(QUIET)mkdir -m 755 -p ${DESTDIR}${LIBDIR}/pkgconfig
186 187
	$(QUIET)install -m 644 ${PROJECT}.pc ${DESTDIR}${LIBDIR}/pkgconfig

188 189 190 191 192 193
install-dbus:
	$(ECHO) installing D-Bus interface definitions
	$(QUIET)mkdir -m 755 -p $(DESTDIR)$(DBUSINTERFACEDIR)
	$(QUIET)install -m 644 org.pwmt.zathura.synxtex.xml $(DESTDIR)$(DBUSINTERFACEDIR)

install: all install-headers install-manpages install-dbus
194
	$(ECHO) installing executable file
Sebastian Ramacher's avatar
Sebastian Ramacher committed
195
	$(QUIET)mkdir -m 755 -p ${DESTDIR}${PREFIX}/bin
196
	$(QUIET)install -m 755 ${PROJECT} ${DESTDIR}${PREFIX}/bin
Sebastian Ramacher's avatar
Sebastian Ramacher committed
197
	$(QUIET)mkdir -m 755 -p ${DESTDIR}${DESKTOPPREFIX}
198 199
	$(ECHO) installing desktop file
	$(QUIET)install -m 644 ${PROJECT}.desktop ${DESTDIR}${DESKTOPPREFIX}
200
	$(MAKE) -C po install
Moritz Lipp's avatar
Moritz Lipp committed
201

202 203 204 205 206 207
uninstall-headers:
	$(ECHO) removing header files
	$(QUIET)rm -rf ${DESTDIR}${INCLUDEDIR}/${PROJECT}
	$(ECHO) removing pkgconfig file
	$(QUIET)rm -f ${DESTDIR}${LIBDIR}/pkgconfig/${PROJECT}.pc

208
uninstall: uninstall-headers
209 210
	$(ECHO) removing executable file
	$(QUIET)rm -f ${DESTDIR}${PREFIX}/bin/${PROJECT}
211
	$(ECHO) removing manual pages
212
	$(QUIET)rm -f ${DESTDIR}${MANPREFIX}/man1/${PROJECT}.1
213 214 215
	$(QUIET)rm -f ${DESTDIR}${MANPREFIX}/man5/${PROJECT}rc.5
	$(ECHO) removing desktop file
	$(QUIET)rm -f ${DESTDIR}${DESKTOPPREFIX}/${PROJECT}.desktop
216
	$(MAKE) -C po uninstall
Sebastian Ramacher's avatar
Sebastian Ramacher committed
217

Sebastian Ramacher's avatar
Sebastian Ramacher committed
218
-include $(wildcard .depend/*.dep)
219

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