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

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

Moritz Lipp's avatar
Moritz Lipp committed
6
PROJECT  = zathura-pdf-mupdf
7
PLUGIN   = pdf
Sebastian Ramacher's avatar
Sebastian Ramacher committed
8 9
SOURCE   = $(sort $(wildcard *.c))
HEADER   = $(sort $(wildcard *.h))
10 11 12
OBJECTS  = ${SOURCE:.c=.o}
DOBJECTS = ${SOURCE:.c=.do}

13
ifneq "$(WITH_CAIRO)" "0"
Sebastian Ramacher's avatar
Sebastian Ramacher committed
14
CPPFLAGS += -DHAVE_CAIRO
15 16
endif

17 18 19 20
CPPFLAGS += "-DVERSION_MAJOR=${VERSION_MAJOR}"
CPPFLAGS += "-DVERSION_MINOR=${VERSION_MINOR}"
CPPFLAGS += "-DVERSION_REV=${VERSION_REV}"

Moritz Lipp's avatar
Moritz Lipp committed
21
all: options ${PLUGIN}.so
22

23 24 25 26
zathura-version-check:
ifneq ($(ZATHURA_VERSION_CHECK), 0)
	$(error "The minimum required version of zathura is ${ZATHURA_MIN_VERSION}")
endif
27
	$(QUIET)touch zathura-version-check
28

29
options:
Moritz Lipp's avatar
Moritz Lipp committed
30 31 32 33 34
	$(ECHO) ${PLUGIN} build options:
	$(ECHO) "CFLAGS  = ${CFLAGS}"
	$(ECHO) "LDFLAGS = ${LDFLAGS}"
	$(ECHO) "DFLAGS  = ${DFLAGS}"
	$(ECHO) "CC      = ${CC}"
35 36

%.o: %.c
Moritz Lipp's avatar
Moritz Lipp committed
37
	$(ECHO) CC $<
Sebastian Ramacher's avatar
Sebastian Ramacher committed
38
	@mkdir -p .depend
Moritz Lipp's avatar
Moritz Lipp committed
39
	$(QUIET)${CC} -c ${CPPFLAGS} ${CFLAGS} -o $@ $< -MMD -MF .depend/$@.dep
40 41

%.do: %.c
Moritz Lipp's avatar
Moritz Lipp committed
42
	$(ECHO) CC $<
Sebastian Ramacher's avatar
Sebastian Ramacher committed
43
	@mkdir -p .depend
Moritz Lipp's avatar
Moritz Lipp committed
44
	$(QUIET)${CC} -c ${CPPFLAGS} ${CFLAGS} ${DFLAGS} -o $@ $< -MMD -MF .depend/$@.dep
45

46 47
${OBJECTS}:  config.mk zathura-version-check
${DOBJECTS}: config.mk zathura-version-check
48

49
${PLUGIN}.so: ${OBJECTS}
Moritz Lipp's avatar
Moritz Lipp committed
50
	$(ECHO) LD $@
Moritz Lipp's avatar
Moritz Lipp committed
51
	$(QUIET)${CC} -shared ${LDFLAGS} -o $@ $(OBJECTS) ${LIBS}
52

53
${PLUGIN}-debug.so: ${DOBJECTS}
Moritz Lipp's avatar
Moritz Lipp committed
54
	$(ECHO) LD $@
Moritz Lipp's avatar
Moritz Lipp committed
55
	$(QUIET)${CC} -shared ${LDFLAGS} -o $@ $(DOBJECTS) ${LIBS}
56 57

clean:
Moritz Lipp's avatar
Moritz Lipp committed
58
	$(QUIET)rm -rf ${OBJECTS} ${DOBJECTS} $(PLUGIN).so $(PLUGIN)-debug.so \
59
		doc .depend ${PROJECT}-${VERSION}.tar.gz zathura-version-check
60

Moritz Lipp's avatar
Moritz Lipp committed
61
debug: options ${PLUGIN}-debug.so
62

Moritz Lipp's avatar
Moritz Lipp committed
63 64 65
dist: clean
	$(QUIET)mkdir -p ${PROJECT}-${VERSION}
	$(QUIET)cp -R LICENSE Makefile config.mk common.mk Doxyfile \
66 67
		${HEADER} ${SOURCE} AUTHORS ${PROJECT}.desktop \
		${PROJECT}-${VERSION}
Moritz Lipp's avatar
Moritz Lipp committed
68 69 70 71
	$(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
72 73 74
doc: clean
	$(QUIET)doxygen Doxyfile

75
install: all
Moritz Lipp's avatar
Moritz Lipp committed
76
	$(ECHO) installing ${PLUGIN} plugin
77 78
	$(QUIET)mkdir -p ${DESTDIR}${PLUGINDIR}
	$(QUIET)cp -f ${PLUGIN}.so ${DESTDIR}${PLUGINDIR}
79 80 81
	$(QUIET)mkdir -m 755 -p ${DESTDIR}${DESKTOPPREFIX}
	$(ECHO) installing desktop file
	$(QUIET)install -m 644 ${PROJECT}.desktop ${DESTDIR}${DESKTOPPREFIX}
82 83

uninstall:
Moritz Lipp's avatar
Moritz Lipp committed
84
	$(ECHO) uninstalling ${PLUGIN} plugin
85
	$(QUIET)rm -f ${DESTDIR}${PLUGINDIR}/${PLUGIN}.so
86 87 88 89
	$(QUIET)rmdir --ignore-fail-on-non-empty ${DESTDIR}${PLUGINDIR} 2> /dev/null
	$(ECHO) removing desktop file
	$(QUIET)rm -f ${DESTDIR}${DESKTOPPREFIX}/${PROJECT}.desktop
	$(QUIET)rmdir --ignore-fail-on-non-empty ${DESTDIR}${DESKTOPPREFIX} 2> /dev/null
Sebastian Ramacher's avatar
Sebastian Ramacher committed
90

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

Moritz Lipp's avatar
Moritz Lipp committed
93
.PHONY: all options clean debug doc dist install uninstall