Summary Files Commits Branches @commit @diff @stats
path: root / configure
diff options
context:
space:
mode:
Commitc5fca92a08a8a63ad4d746b4d3a44a9cf724ea61 (patch)
Author
 Haelwenn (lanodan) Monnier <contact@hacktivis.me>
2021-09-07 02:46:07 +0200
Committer
 Haelwenn (lanodan) Monnier <contact@hacktivis.me>
2021-09-07 04:32:57 +0200
Filesa29f8f326af9dd3d0a89ff8e9e2c9af6f4dd0c2a /configure
goodwolf-c5fca92a08a8a63ad4d746b4d3a44a9cf724ea61.tar
goodwolf-c5fca92a08a8a63ad4d746b4d3a44a9cf724ea61.tar.gz
goodwolf-c5fca92a08a8a63ad4d746b4d3a44a9cf724ea61.zip
Parent714dea37efa4ef1be1b0bb12ef56c8128fcfd24f (diff)
Change buildsystem to use a ./configure script
This is done to support webkit2gtk-4.1 (libsoup3) vs. webkit2gtk-4.0 (libsoup2). It will also be useful once WebKitGTK with support for GTK4 lands in badwolf.
1 files changed, 110 insertions, 0 deletions
-rwxr-xr-xconfigure110
diff --git a/configure b/configure
new file mode 100755
index 0000000..17510a0
--- /dev/null
+++ b/configure
@@ -0,0 +1,110 @@
+#!/bin/sh
+VERSION=1.1.0
+VERSION_FULL=${VERSION}$(./version.sh)
+PREFIX="${PREFIX:-/usr/local}"
+BINDIR="${BINDIR:-${PREFIX}/bin}"
+MANDIR="${MANDIR:-${PREFIX}/share/man}"
+DOCDIR="${DOCDIR:-${PREFIX}/share/doc/badwolf-${VERSION}}"
+DATADIR="${DATADIR:-${PREFIX}/share/badwolf}"
+APPSDIR="${APPSDIR:-${PREFIX}/share/applications}"
+
+PKGCONFIG="${PKGCONFIG:-pkg-config}"
+MSGFMT="${MSGFMT:-msgfmt}"
+INKSCAPE="${INKSCAPE:-inkscape}"
+CC="${CC:-cc}"
+CFLAGS="${CFLAGS:--g -O2 -pie -fPIE} -fstack-protector-strong -D_FORTIFY_SOURCE=2 -Wall -Wextra -Wconversion -Wsign-conversion -Werror=implicit-function-declaration -Werror=implicit-int -Werror=vla ${EXTRA_CFLAGS}"
+
+DEPS="gtk+-3.0 libxml-2.0"
+
+is_ok() {
+ status="$?"
+
+ if test "$status" == 0; then
+ printf " OK\n"
+ else
+ printf " FAIL\n"
+ fi
+
+ return $status
+}
+
+required() {
+ is_ok || exit 1
+}
+
+pkg_config_check() {
+ printf 'Checking: %s %s ...' "${PKGCONFIG}" "$*"
+ "${PKGCONFIG}" "$@"
+ is_ok
+}
+
+printf 'Checking %s command existance ...' "${PKGCONFIG}"
+command -v "${PKGCONFIG}" >/dev/null ; required
+
+printf 'Checking %s command existance ...' "${CC}"
+command -v "${CC}" >/dev/null ; required
+
+for dep in ${DEPS}
+do
+ pkg_config_check --exists "$dep" || exit 1
+done
+
+case "${WITH_WEBKITGTK}n" in
+ 4.1n)
+ pkg_config_check --atleast-version=2.32.0 webkit2gtk-4.1 || exit 1
+ DEPS="${DEPS} webkit2gtk-4.1 libsoup-3.0"
+ ;;
+ 4.0n)
+ pkg_config_check --atleast-version=2.32.0 webkit2gtk-4.0 || exit 1
+ DEPS="${DEPS} webkit2gtk-4.0 libsoup-2.4"
+ ;;
+ n)
+ echo "warning: Packagers should specify the ABI version (4.0 or 4.1) in WITH_WEBKITGTK" >&2
+ if pkg_config_check --atleast-version=2.32.0 webkit2gtk-4.1
+ then
+ DEPS="${DEPS} webkit2gtk-4.1 libsoup-3.0"
+ else
+ pkg_config_check --atleast-version=2.32.0 webkit2gtk-4.0 || exit 1
+ DEPS="${DEPS} webkit2gtk-4.0 libsoup-2.4"
+ fi
+ ;;
+ *)
+ echo "error: invalid webkit2gtk version in WITH_WEBKITGTK environment variable, must be 4.0 or 4.1" >&2
+ exit 1
+ ;;
+esac
+
+get_cflags() { "${PKGCONFIG}" --cflags "${DEPS}"; }
+DEPS_cflags="$(get_cflags)"
+get_libs() { "${PKGCONFIG}" --libs "${DEPS}"; }
+DEPS_libs="$(get_libs)"
+
+ICON_SIZES="$(for i in 24 32 48 64 128 256; do printf 'icons/hicolor/%sx%s/apps/badwolf.png ' $i $i ; done)"
+
+printf 'Writing to config.mk ...'
+cat >config.mk <<EOF
+# Autogenerated by ./configure
+PACKAGE = Badwolf
+VERSION = ${VERSION}
+VERSION_FULL = ${VERSION_FULL}
+
+PREFIX = ${PREFIX}
+BINDIR = ${BINDIR}
+MANDIR = ${MANDIR}
+DOCDIR = ${DOCDIR}
+DATADIR = ${DATADIR}
+APPSDIR = ${APPSDIR}
+
+PKGCONFIG = ${PKGCONFIG}
+CC = ${CC}
+INKSCAPE = ${INKSCAPE}
+MSGFMT = ${MSGFMT}
+DBG = ${DBG}
+
+CFLAGS = ${CFLAGS} -DDATADIR=\"\${DATADIR}\" -DPACKAGE=\"\${PACKAGE}\" -D_XOPEN_SOURCE=700 -D_POSIX_C_SOURCE=200809L -DVERSION=\"\${VERSION_FULL}\" ${DEPS_cflags}
+LIBS = ${DEPS_libs}
+ICON_SIZES = ${ICON_SIZES}
+EOF
+is_ok
+
+echo 'Done, you can now run make'