Commit 2ea7394c authored by Sebastian Ramacher's avatar Sebastian Ramacher

Switch to meson based build system

parent e136e0fc
# See LICENSE file for license and copyright information
ifeq ($(COLOR),1)
# GCC diagnostics colors
DIAGNOSTICS_COLOR_AVAILABLE ?= $(shell ($(CC) -fdiagnostics-color=always -E - </dev/null >/dev/null 2>/dev/null && echo 1) || echo 0)
ifeq ($(DIAGNOSTICS_COLOR_AVAILABLE),1)
CPPFLAGS += -fdiagnostics-color=always
endif
# colorful output
TPUT ?= /usr/bin/tput
TPUT_AVAILABLE ?= $(shell ${TPUT} -V 2>/dev/null)
ifdef TPUT_AVAILABLE
COLOR_NORMAL = `$(TPUT) sgr0`
COLOR_ACTION = `$(TPUT) bold``$(TPUT) setaf 3`
COLOR_COMMENT = `$(TPUT) bold``$(TPUT) setaf 2`
COLOR_BRACKET = `$(TPUT) setaf 4`
define colorecho
@echo $(COLOR_BRACKET)" ["$(COLOR_ACTION)$1$(COLOR_BRACKET)"] "$(COLOR_COMMENT)$2$(COLOR_BRACKET) $(COLOR_NORMAL)
endef
else
define colorecho
@echo " [$1]" $2
endef
endif
else
define colorecho
@echo " [$1]" $2
endef
endif
# See LICENSE file for license and copyright information
ifeq "$(VERBOSE)" "0"
ECHO=@echo
QUIET=@
else
ECHO=@\#
QUIET=
endif
gnome = import('gnome')
girara_css = gnome.compile_resources(
'girara-css',
'girara-css.gresource.xml',
c_name: 'girara_css',
dependencies: files('girara.css_t')
)
project=@PROJECT@
version=@VERSION@
includedir=@INCLUDEDIR@
libdir=@LIBDIR@
GTK_VERSION=3
Name: ${project}
Description: User interface libray
Version: ${version}
URL: http://pwmt.org/projects/girara
Cflags: -I${includedir}
Libs: -L${libdir} -l${project}
Requires.private: gtk+-3.0 @LIBNOTIFY_PC_NAME@ @JSON_PC_NAME@
project('girara', 'c',
meson_version: '>=0.43',
default_options: 'c_std=c11'
)
version_major = '0'
version_minor = '2'
version_rev = '8'
version = '@0@.@1@.@2@'.format(version_major, version_minor, version_rev)
so_major = '3'
so_minor = '0'
so_version = '@0@.@1@'.format(so_major, so_minor)
conf_data = configuration_data()
conf_data.set('GVMAJOR', version_major)
conf_data.set('GVMINOR', version_minor)
conf_data.set('GVREV', version_rev)
conf_data.set('version', version)
cc = meson.get_compiler('c', required: false)
prefix = get_option('prefix')
localedir = get_option('localedir')
libm = cc.find_library('libm')
glib = dependency('glib-2.0', version: '>=2.50')
gtk3 = dependency('gtk+-3.0', version: '>=3.20')
build_dependencies = [libm, glib, gtk3]
pc_requires = ['glib-2.0', 'gtk+-3.0']
defines = [
'-DGETTEXT_PACKAGE="libgirara-gtk3-@0@"'.format(so_major),
'-DLOCALEDIR="@0@"'.format(join_paths(prefix, localedir))
]
flags = [
'-Wall',
'-Wextra',
'-pedantic',
'-Wmissing-declarations',
'-Werror=implicit-function-declaration'
]
flags = cc.get_supported_arguments(flags)
if get_option('enable-notify')
libnotify = dependency('libnotify', version: '>=0.7.0', required: false)
if libnotify.found()
build_dependencies += libnotify
defines += '-DWITH_LIBNOTIFY'
pc_requires += 'libnotify'
endif
endif
if get_option('enable-json')
jsonc = dependency('json-c', required: false)
if jsonc.found()
build_dependencies += jsonc
defines += '-DWITH_JSONC'
pc_requires += 'json-c'
endif
endif
version_header = configure_file(
input: 'girara/version.h.in',
output: 'version.h',
configuration: conf_data
)
include_directories = [
include_directories('.')
]
subdir('data')
subdir('po')
sources = files(
'girara/callbacks.c',
'girara/completion.c',
'girara/entry.c',
'girara/input-history-io.c',
'girara/session.c',
'girara/shortcuts.c',
'girara/template.c',
'girara/commands.c',
'girara/config.c',
'girara/datastructures.c',
'girara/input-history.c',
'girara/log.c',
'girara/settings.c',
'girara/statusbar.c',
'girara/utils.c'
)
sources += girara_css
headers = files(
'girara/callbacks.h',
'girara/commands.h',
'girara/completion.h',
'girara/config.h',
'girara/css-definitions.h',
'girara/datastructures.h',
'girara/entry.h',
'girara/girara.h',
'girara/input-history.h',
'girara/log.h',
'girara/macros.h',
'girara/session.h',
'girara/settings.h',
'girara/shortcuts.h',
'girara/statusbar.h',
'girara/template.h',
'girara/types.h',
'girara/utils.h'
)
headers += version_header
girara = library(
'girara-gtk3',
sources,
dependencies: build_dependencies,
soversion: so_version,
install: true,
include_directories: include_directories,
c_args: defines + flags
)
install_headers(headers, subdir: 'girara')
pkg = import('pkgconfig')
pkg.generate(
name: 'girara-gtk3',
description: 'User interface library',
url: 'https://pwmt.org/projects/girara',
version: version,
libraries: girara,
requires_private: pc_requires,
)
subdir('tests')
option('enable-notify',
type: 'boolean',
value: true,
description: 'Enable libnotify support if available.'
)
option('enable-json',
type: 'boolean',
value: true)
de
el
eo
es
fr
he
it
pl
pt_BR
ru
tr
# See LICENSE file for license and copyright information
include ../config.mk
include ../common.mk
include ../colors.mk
PROJECTNV = girara
PROJECT = girara-gtk3
CATALOGS = $(sort $(wildcard *.po))
LINGUAS ?= $(patsubst %.po, %, $(CATALOGS))
ifeq ($(LINGUAS),)
ALINGUAS =
else
ALINGUAS = $(shell find $(patsubst %, %.po, $(LINGUAS)) 2>/dev/null)
endif
MOS = $(patsubst %, %/LC_MESSAGES/${GETTEXT_PACKAGE}.mo, $(patsubst %.po, %, $(ALINGUAS)))
all: ${MOS}
clean:
$(QUIET)rm -rf POTFILES.in POTFILES.in.tmp $(patsubst %.po, %, $(CATALOGS)) ${PROJECT}.pot
POTFILES.in: $(sort $(wildcard ../girara/*.c))
$(QUIET) set -e && rm -f $@.tmp && touch $@.tmp && \
for f in $(^F) ; do \
echo girara/$$f >> $@.tmp ; \
done && \
mv $@.tmp $@
${GETTEXT_PACKAGE}.pot: POTFILES.in
$(ECHO) regenerate $@
$(QUIET)intltool-update --pot --gettext-package=${GETTEXT_PACKAGE}
update-po: ${GETTEXT_PACKAGE}.pot
$(call colorecho,PO,"Updating po files ${CATALOGS}")
$(QUIET)set -e && for f in ${CATALOGS} ; do \
intltool-update --dist --gettext-package=${GETTEXT_PACKAGE} `echo $$f | sed 's/\.po//'` ; \
sed -i 's/Report-Msgid-Bugs-To: \\n/Report-Msgid-Bugs-To: http:\/\/bugs.pwmt.org\\n/' "$$f" ; \
done
%/LC_MESSAGES/${GETTEXT_PACKAGE}.mo: %.po
@mkdir -p $(@D)
$(call colorecho,MSGFMT,$(shell echo $< | sed 's/\.po//'))
$(QUIET)${MSGFMT} ${MSGFMTFLAGS} -c $< -o $@
install: ${MOS}
$(call colorecho,INSTALL,"Install translations")
$(QUIET)set -e && for f in $^ ; do \
mkdir -p -m 755 $(DESTDIR)$(LOCALEDIR)/`dirname $$f`; \
install -m 644 $$f $(DESTDIR)$(LOCALEDIR)/`dirname $$f` ; \
done
uninstall: ${MOS}
$(call colorecho,UNINSTALL,"Uninstall translations")
$(QUIET)set -e && for f in $^ ; do \
rm -f $(LOCALEDIR)/$$f; \
done
.PHONY: all clean install uninstall update-po
girara/callbacks.c
girara/commands.c
girara/completion.c
girara/config.c
girara/css-definitions.c
girara/datastructures.c
girara/entry.c
girara/input-history-io.c
girara/input-history.c
girara/log.c
girara/session.c
girara/settings.c
girara/shortcuts.c
girara/statusbar.c
girara/template.c
girara/utils.c
i18n = import('i18n')
i18n.gettext('libgirara-gtk3-@0@'.format(so_major),
preset: 'glib'
)
# See LICENSE file for license and copyright information
include ../config.mk
include ../common.mk
include ../colors.mk
include config.mk
PROJECT = test
SOURCE = tests.c $(wildcard test_*.c)
OBJECTS = $(addprefix ${BUILDDIR_RELEASE}/,${SOURCE:.c=.o})
OBJECTS_DEBUG = $(addprefix ${BUILDDIR_DEBUG}/,${SOURCE:.c=.o})
OBJECTS_GCOV = $(addprefix ${BUILDDIR_GCOV}/,${SOURCE:.c=.o})
GIRARA_OBJECTS = $(wildcard ${GIRARA_RELEASE}/*.o)
GIRARA_OBJECTS_DEBUG = $(wildcard ${GIRARA_DEBUG}/*.o)
GIRARA_OBJECTS_GCOV = $(wildcard ${GIRARA_GCOV}/*.o)
XDG_HELPER_SOURCE = xdg_test_helper.c
XDG_HELPER = $(addprefix ${BUILDDIR_RELEASE}/,${XDG_HELPER_SOURCE:.c=})
CPPFLAGS += -I../girara -DXDG_TEST_HELPER=\"${XDG_HELPER}\"
all: release ${XDG_HELPER}
../girara/version.h:
$(MAKE) -C .. girara/version.h
# release
${OBJECTS}: config.mk ../config.mk ../girara/version.h
${BUILDDIR_RELEASE}/%.o: %.c
$(call colorecho,CC,$<)
@mkdir -p ${DEPENDDIR}/$(dir $(abspath $@))
@mkdir -p $(dir $(abspath $@))
$(QUIET)${CC} -c ${CPPFLAGS} ${CFLAGS} \
-o $@ $< -MMD -MF ${DEPENDDIR}/$(abspath $@).dep
${BUILDDIR_RELEASE}/${BINDIR}/${PROJECT}: ${OBJECTS}
$(QUIET)$(MAKE) -C .. release
$(call colorecho,CC,$@)
@mkdir -p ${BUILDDIR_RELEASE}/${BINDIR}
$(QUIET)${CC} ${SFLAGS} ${LDFLAGS} \
-o ${BUILDDIR_RELEASE}/${BINDIR}/${PROJECT} \
${OBJECTS} ${GIRARA_OBJECTS} ${LIBS}
release: ${BUILDDIR_RELEASE}/${BINDIR}/${PROJECT}
run: release ${XDG_HELPER}
$(QUIET)env -u HOME ./${BUILDDIR_RELEASE}/${BINDIR}/${PROJECT}
$(QUIET)env HOME=/home/test ./${BUILDDIR_RELEASE}/${BINDIR}/${PROJECT}
# debug
${OBJECTS_DEBUG}: config.mk ../config.mk ../girara/version.h
${BUILDDIR_DEBUG}/%.o: %.c
@mkdir -p ${DEPENDDIR}/$(dir $(abspath $@))
@mkdir -p $(dir $(abspath $@))
$(call colorecho,CC,$<)
$(QUIET)${CC} -c ${CPPFLAGS} ${CFLAGS} ${DFLAGS} \
-o $@ $< -MMD -MF ${DEPENDDIR}/$(abspath $@).dep
${BUILDDIR_DEBUG}/${BINDIR}/${PROJECT}: ${OBJECTS_DEBUG}
$(QUIET)$(MAKE) -C .. debug
$(call colorecho,CC,$@)
@mkdir -p ${BUILDDIR_DEBUG}/${BINDIR}
$(QUIET)${CC} ${SFLAGS} ${LDFLAGS} \
-o ${BUILDDIR_DEBUG}/${BINDIR}/${PROJECT} \
${OBJECTS} ${GIRARA_OBJECTS_DEBUG} ${LIBS}
debug: ${BUILDDIR_DEBUG}/${BINDIR}/${PROJECT}
run-debug: debug ${XDG_HELPER}
$(QUIET)./${BUILDDIR_DEBUG}/${BINDIR}/${PROJECT}
# gcov
${OBJECTS_GCOV}: config.mk ../config.mk ../girara/version.h
${BUILDDIR_GCOV}/%.o: %.c
@mkdir -p ${DEPENDDIR}/$(dir $(abspath $@))
@mkdir -p $(dir $(abspath $@))
$(call colorecho,CC,$<)
$(QUIET)${CC} -c ${CPPFLAGS} ${CFLAGS} ${GCOV_CFLAGS} ${DFLAGS} ${GCOV_DFLAGS} \
-o $@ $< -MMD -MF ${DEPENDDIR}/$(abspath $@).dep
${BUILDDIR_GCOV}/${BINDIR}/${PROJECT}: ${OBJECTS_GCOV}
$(QUIET)$(MAKE) -C .. gcov
$(call colorecho,CC,$@)
@mkdir -p ${BUILDDIR_GCOV}/${BINDIR}
$(QUIET)${CC} ${SFLAGS} ${LDFLAGS} ${GCOV_CFLAGS} ${GCOV_LDFLAGS} \
-o ${BUILDDIR_GCOV}/${BINDIR}/${PROJECT} \
${OBJECTS} ${GIRARA_OBJECTS_GCOV} ${LIBS}
gcov: ${BUILDDIR_GCOV}/${BINDIR}/${PROJECT}
run-gcov: gcov
$(QUIET)./${BUILDDIR_GCOV}/${BINDIR}/${PROJECT}
# XDG test helper
${XDG_HELPER}: ${XDG_HELPER_SOURCE}
$(MAKE) -C .. release
@mkdir -p ${DEPENDDIR}/$(dir $(abspath $@))
@mkdir -p $(dir $(abspath $@))
$(call colorecho,CC,$@)
$(QUIET)${CC} ${CPPFLAGS} ${CFLAGS} -o $@ $< ${GIRARA_OBJECTS} \
${LDFLAGS} ${LIBS} -MMD -MF ${DEPENDDIR}/$(abspath $@).dep
clean:
$(call colorecho,RM, "Clean test files")
$(QUIET)rm -rf ${PROJECT}
$(QUIET)rm -rf ${PROJECT}-debug
$(QUIET)rm -rf ${PROJECT}-gcov
$(QUIET)rm -rf ${BUILDDIR}
$(QUIET)rm -rf ${DEPENDDIR}
.PHONY: all clean debug gciv run run-debug run-gcov
-include $(wildcard ${DEPENDDIR}/*.dep)
# See LICENSE file for license and copyright information
CHECK_INC ?= $(shell pkg-config --cflags check)
CHECK_LIB ?= $(shell pkg-config --libs check)
LIBS += ${CHECK_LIB}
GIRARA_RELEASE=../${BUILDDIR_RELEASE}/girara
GIRARA_DEBUG=../${BUILDDIR_DEBUG}/girara
GIRARA_GCOV=../${BUILDDIR_GCOV}/girara
check = dependency('check', required: false)
if check.found()
test_dependencies = [
declare_dependency(link_with: girara),
check
]
include_directories += [ include_directories('../girara') ]
test_sources = [
'tests.c',
'test_config.c',
'test_datastructures.c',
'test_session.c',
'test_setting.c',
'test_template.c',
'test_utils.c'
]
xdg_test_helper = executable('xdg_test_helper', 'xdg_test_helper.c',
dependencies: [ glib, declare_dependency(link_with: girara) ],
include_directories: include_directories
)
tests = executable('tests', test_sources,
dependencies: build_dependencies + test_dependencies,
include_directories: include_directories,
)
env = environment()
env.set('XDG_TEST_HELPER_PATH', meson.current_build_dir())
env.set('HOME', '/home/test')
test('tests-with-home', tests, env: env)
# Cannot unset environment variables.
# env.unset('HOME')
# test('tests-without-home', tests, env: env)
endif
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