Makefile 2.56 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 14 15 16
CPPFLAGS += "-DVERSION_MAJOR=${VERSION_MAJOR}"
CPPFLAGS += "-DVERSION_MINOR=${VERSION_MINOR}"
CPPFLAGS += "-DVERSION_REV=${VERSION_REV}"

Moritz Lipp's avatar
Moritz Lipp committed
17
all: options ${PLUGIN}.so
18

19 20 21 22
zathura-version-check:
ifneq ($(ZATHURA_VERSION_CHECK), 0)
	$(error "The minimum required version of zathura is ${ZATHURA_MIN_VERSION}")
endif
23
	$(QUIET)touch zathura-version-check
24

25
options:
Moritz Lipp's avatar
Moritz Lipp committed
26 27 28 29 30
	$(ECHO) ${PLUGIN} build options:
	$(ECHO) "CFLAGS  = ${CFLAGS}"
	$(ECHO) "LDFLAGS = ${LDFLAGS}"
	$(ECHO) "DFLAGS  = ${DFLAGS}"
	$(ECHO) "CC      = ${CC}"
31 32

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

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

42 43
${OBJECTS}:  config.mk zathura-version-check
${DOBJECTS}: config.mk zathura-version-check
44

45
${PLUGIN}.so: ${OBJECTS}
Moritz Lipp's avatar
Moritz Lipp committed
46
	$(ECHO) LD $@
Moritz Lipp's avatar
Moritz Lipp committed
47
	$(QUIET)${CC} -shared ${LDFLAGS} -o $@ $(OBJECTS) ${LIBS}
48

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

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

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

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

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

uninstall:
Moritz Lipp's avatar
Moritz Lipp committed
80
	$(ECHO) uninstalling ${PLUGIN} plugin
81
	$(QUIET)rm -f ${DESTDIR}${PLUGINDIR}/${PLUGIN}.so
82 83 84 85
	$(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
86

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

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