Commit 427c05c2 authored by Sebastian Ramacher's avatar Sebastian Ramacher

Add meson build system

parent 4fe283c1
# See LICENSE file for license and copyright information
include config.mk
include common.mk
PROJECT = zathura-pdf-poppler
PLUGIN = pdf
SOURCE = $(sort $(wildcard *.c))
HEADER = $(wildcard *.h)
OBJECTS = ${SOURCE:.c=.o}
DOBJECTS = ${SOURCE:.c=.do}
ifeq ($(UNAME), Darwin)
SOFILE = ${PLUGIN}.dylib
SODEBUGFILE = ${PLUGIN}-debug.dylib
ZATHURAFILE = ${PREFIX}/bin/zathura
PLATFORMFLAGS = -Wl,-dylib_install_name,${DESTDIR}${PLUGINDIR}/pdf.dylib -Wl,-bundle_loader,${ZATHURAFILE} -bundle
else
SOFILE = ${PLUGIN}.so
SODEBUGFILE = ${PLUGIN}-debug.so
PLATFORMFLAGS = -shared
endif
CPPFLAGS += "-DVERSION_MAJOR=${VERSION_MAJOR}"
CPPFLAGS += "-DVERSION_MINOR=${VERSION_MINOR}"
CPPFLAGS += "-DVERSION_REV=${VERSION_REV}"
all: options ${SOFILE}
# pkg-config based version checks
.version-checks/%: config.mk
$(QUIET)test $($(*)_VERSION_CHECK) -eq 0 || \
${PKG_CONFIG} --atleast-version $($(*)_MIN_VERSION) $($(*)_PKG_CONFIG_NAME) || ( \
echo "The minimum required version of $(*) is $($(*)_MIN_VERSION)" && \
false \
)
@mkdir -p .version-checks
$(QUIET)touch $@
options:
$(ECHO) ${PLUGIN} build options:
$(ECHO) "CFLAGS = ${CFLAGS}"
$(ECHO) "LDFLAGS = ${LDFLAGS}"
$(ECHO) "DFLAGS = ${DFLAGS}"
$(ECHO) "CC = ${CC}"
$(ECHO) "PKG_CONFIG = ${PKG_CONFIG}"
%.o: %.c
$(ECHO) CC $<
@mkdir -p .depend
$(QUIET)${CC} -c ${CPPFLAGS} ${CFLAGS} -o $@ $< -MMD -MF .depend/$@.dep
%.do: %.c
$(ECHO) CC $<
@mkdir -p .depend
$(QUIET)${CC} -c ${CPPFLAGS} ${CFLAGS} ${DFLAGS} -o $@ $< -MMD -MF .depend/$@.dep
${OBJECTS}: config.mk \
.version-checks/ZATHURA \
.version-checks/POPPLER
${DOBJECTS}: config.mk \
.version-checks/ZATHURA \
.version-checks/POPPLER
${SOFILE}: ${OBJECTS}
$(ECHO) LD $@
$(QUIET)${CC} ${PLATFORMFLAGS} ${LDFLAGS} -o $@ ${OBJECTS} ${LIBS}
${SODEBUGFILE}: ${DOBJECTS}
$(ECHO) LD $@
$(QUIET)${CC} ${PLATFORMFLAGS} ${LDFLAGS} -o $@ ${OBJECTS} ${LIBS}
clean:
$(QUIET)rm -rf ${OBJECTS} ${DOBJECTS} ${SOFILE} ${SODEBUGFILE} \
doc .depend ${PROJECT}-${VERSION}.tar.gz zathura-version-check
debug: options ${SODEBUGFILE}
dist: clean
$(QUIET)mkdir -p ${PROJECT}-${VERSION}
$(QUIET)cp -R LICENSE Makefile config.mk common.mk Doxyfile \
${HEADER} ${SOURCE} AUTHORS ${PROJECT}.desktop \
${PROJECT}.metainfo.xml \
${PROJECT}-${VERSION}
$(QUIET)tar -cf ${PROJECT}-${VERSION}.tar ${PROJECT}-${VERSION}
$(QUIET)gzip ${PROJECT}-${VERSION}.tar
$(QUIET)rm -rf ${PROJECT}-${VERSION}
doc: clean
$(QUIET)doxygen Doxyfile
install: all
$(ECHO) installing ${PLUGIN} plugin
$(QUIET)mkdir -p ${DESTDIR}${PLUGINDIR}
$(QUIET)cp -f ${SOFILE} ${DESTDIR}${PLUGINDIR}
$(QUIET)mkdir -m 755 -p ${DESTDIR}${DESKTOPPREFIX}
$(ECHO) installing desktop file
$(QUIET)install -m 644 ${PROJECT}.desktop ${DESTDIR}${DESKTOPPREFIX}
$(ECHO) installing AppData file
$(QUIET)mkdir -m 755 -p $(DESTDIR)$(APPDATAPREFIX)
$(QUIET)install -m 644 $(PROJECT).metainfo.xml $(DESTDIR)$(APPDATAPREFIX)
uninstall:
$(ECHO) uninstalling ${PLUGIN} plugin
$(QUIET)rm -f ${DESTDIR}${PLUGINDIR}/${SOFILE}
$(QUIET)find ${DESTDIR}${PLUGINDIR} -type d -empty -delete 2> /dev/null
$(ECHO) removing desktop file
$(QUIET)rm -f ${DESTDIR}${DESKTOPPREFIX}/${PROJECT}.desktop
$(QUIET)find ${DESTDIR}${DESKTOPPREFIX} -type d -empty -delete 2> /dev/null
$(ECHO) removing AppData file
$(QUIET)rm -f $(DESTDIR)$(APPDATAPREFIX)/$(PROJECT).metainfo.xml
-include $(wildcard .depend/*.dep)
.PHONY: all options clean debug doc dist install uninstall
# See LICENSE file for license and copyright information
ifeq "$(VERBOSE)" "0"
ECHO=@echo
QUIET=@
else
ECHO=@\#
QUIET=
endif
# See LICENSE file for license and copyright information
VERSION_MAJOR = 0
VERSION_MINOR = 2
VERSION_REV = 8
VERSION = ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_REV}
PKG_CONFIG ?= pkg-config
# version checks
# If you want to disable any of the checks, set *_VERSION_CHECK to 0.
# zathura
ZATHURA_VERSION_CHECK ?= 1
ZATHURA_MIN_VERSION = 0.3.8
ZATHURA_PKG_CONFIG_NAME = zathura
# poppler
POPPLER_VERSION_CHECK ?= 1
POPPLER_MIN_VERSION = 0.18
POPPLER_PKG_CONFIG_NAME = poppler-glib
# paths
PREFIX ?= /usr
LIBDIR ?= ${PREFIX}/lib
DESKTOPPREFIX ?= ${PREFIX}/share/applications
APPDATAPREFIX ?= ${PREFIX}/share/metainfo
# libs
CAIRO_INC ?= $(shell $(PKG_CONFIG) --cflags cairo)
CAIRO_LIB ?= $(shell $(PKG_CONFIG) --libs cairo)
PDF_INC ?= $(shell $(PKG_CONFIG) --cflags poppler-glib)
PDF_LIB ?= $(shell $(PKG_CONFIG) --libs poppler-glib)
GIRARA_INC ?= $(shell $(PKG_CONFIG) --cflags girara-gtk3)
GIRARA_LIB ?= $(shell $(PKG_CONFIG) --libs girara-gtk3)
ZATHURA_INC ?= $(shell $(PKG_CONFIG) --cflags zathura)
PLUGINDIR ?= $(shell $(PKG_CONFIG) --variable=plugindir zathura)
ifeq (,${PLUGINDIR})
PLUGINDIR = ${LIBDIR}/zathura
endif
INCS = ${CAIRO_INC} ${PDF_INC} ${ZATHURA_INC} ${GIRARA_INC}
LIBS = ${GIRARA_LIB} ${CAIRO_LIB} ${PDF_LIB}
# uname
UNAME := $(shell uname -s)
# compiler flags
CFLAGS += -std=c11 -fPIC -pedantic -Wall -Wno-format-zero-length $(INCS)
# linker flags
LDFLAGS += -fPIC
ifeq ($(UNAME), Darwin)
LDFLAGS += -fno-common
endif
# debug
DFLAGS ?= -g
# compiler
CC ?= gcc
LD ?= ld
# set to something != 0 if you want verbose build output
VERBOSE ?= 0
project('zathura-pdf-poppler', 'c',
version: '0.2.8',
meson_version: '>=0.43',
default_options: 'c_std=c11'
)
version = meson.project_version()
version_array = version.split('.')
cc = meson.get_compiler('c')
prefix = get_option('prefix')
datadir = get_option('datadir')
metainfodir = join_paths(datadir, 'metainfo')
desktopdir = join_paths(datadir, 'applications')
# required dependencies
zathura = dependency('zathura', version: '>=0.3.8')
poppler = dependency('poppler-glib', version: '>=0.18')
build_dependencies = [zathura, poppler]
# defines
defines = [
'-DVERSION_MAJOR=@0@'.format(version_array[0]),
'-DVERSION_MINOR=@0@'.format(version_array[1]),
'-DVERSION_REV=@0@'.format(version_array[2]),
'-D_DEFAULT_SOURCE',
]
# compile flags
flags = [
'-Wall',
'-Wextra',
'-pedantic',
'-Werror=implicit-function-declaration'
]
flags = cc.get_supported_arguments(flags)
sources = files(
'attachments.c',
'document.c',
'forms.c',
'image.c',
'index.c',
'links.c',
'meta.c',
'page.c',
'plugin.c',
'render.c',
'search.c',
'select.c',
'utils.c'
)
pdf = shared_module('pdf',
sources,
dependencies: build_dependencies,
c_args: defines + flags,
install: true,
install_dir: zathura.get_pkgconfig_variable('plugindir')
)
install_data('zathura-pdf-poppler.metainfo.xml', install_dir: metainfodir)
install_data('zathura-pdf-poppler.desktop', install_dir: desktopdir)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment