Commit 5249f02c authored by Vivien Kraus's avatar Vivien Kraus
Browse files

Guile configuration

parent ab0bef1d
......@@ -110,6 +110,7 @@
/src/libtarot/gobject/tarot-enums-stamp
/src/libtarot/gobject/tarot-gobject.c
/src/libtarot/gobject/tarot-gobject.h
/src/libtarot/guile/tarot/config.scm
/src/libtarot/hand/check_hand
/src/libtarot/layout/check-layout
/src/libtarot/pkgconfig/libtarot-gobject.pc
......
......@@ -23,14 +23,17 @@ AC_CONFIG_HEADERS([config.h])
AC_ARG_ENABLE([runtime-prefix], AS_HELP_STRING([--enable-runtime-prefix=ENV],
[At runtime, prepend the value of the environment variable ENV to the installation prefix. This is useful to make the package relocatable. If ENV is empty or 'no', this is disabled.]))
AC_DEFINE_UNQUOTED([RUNTIME_PREFIX_ENV], "$enable_runtime_prefix", [Environment variable to look up the installation prefix])
AC_SUBST([RUNTIME_PREFIX_ENV], "$enable_runtime_prefix")
AC_ARG_VAR([USER_DATA_DIR_VARIABLE], [Which environment variable points to the user-local read-write directory. With freedesktop.org, it is XDG_DATA_HOME (default). With Windows it should be set to LOCALAPPDATA.])
AS_IF([test "x$USER_DATA_DIR_VARIABLE" == "x"], [
USER_DATA_DIR_VARIABLE="XDG_DATA_HOME"
])
AC_DEFINE_UNQUOTED([USER_DATA_DIR], "$USER_DATA_DIR_VARIABLE", [The environment variable pointing to user-local read-write storage (XDG_DATA_HOME).])
AC_SUBST([USER_DATA_DIR], "$USER_DATA_DIR_VARIABLE")
AC_ARG_ENABLE([textdomain-codeset], AS_HELP_STRING([--enable-textdomain-codeset=CODESET],
[Do not use the current locale for translation message; use the CODESET encoding. On Windows, set it to utf-8.]))
AC_DEFINE_UNQUOTED([TEXTDOMAIN_CODESET], "$enable_textdomain_codeset", [Force gettext encoding, if not set to no.])
AC_SUBST([TEXTDOMAIN_CODESET], "$enable_textdomain_codeset")
AC_CONFIG_MACRO_DIRS([m4])
AC_SUBST([VERSION_MAJOR], m4_esyscmd([./get-version.sh package | cut -d '.' -f 1]))
AC_SUBST([VERSION_MINOR], m4_esyscmd([./get-version.sh package | cut -d '.' -f 2]))
......
......@@ -52,7 +52,7 @@ case "$1" in
EXPECTED_FIRSTLINE="# $EXPECTED_FIRSTLINE"
EXPECTED_COPYRIGHT=$(echo "$EXPECTED_COPYRIGHT" | sed 's/^/# /g' | sed 's/^# $/#/g')
;;
*.el|*.el.in)
*.el|*.el.in|*.scm|*.scm.in)
EXPECTED_FIRSTLINE=";; $EXPECTED_FIRSTLINE"
EXPECTED_COPYRIGHT=$(echo "$EXPECTED_COPYRIGHT" | sed 's/^/;; /g' | sed 's/^;; $/;;/g')
;;
......
......@@ -15,7 +15,22 @@
AM_CPPFLAGS += -I $(srcdir)/%reldir% -I %reldir%
EXTRA_DIST += %reldir%/test_guile.c
EXTRA_DIST += %reldir%/test_guile.c %reldir%/tarot/config.scm.in
%reldir%/tarot/config.scm: $(srcdir)/%reldir%/tarot/config.scm.in
@$(MKDIR_P) %reldir%/tarot
$(AM_V_GEN) sed 's|"RUNTIME_PREFIX_ENV"|"$(RUNTIME_PREFIX_ENV)"|g' < $(srcdir)/%reldir%/tarot/config.scm.in \
| sed 's|"SYSCONFDIR"|"$(sysconfdir)"|g' \
| sed 's|"LOCALEDIR"|"$(localedir)"|g' \
| sed 's|"DATADIR"|"$(datadir)"|g' \
| sed 's|"PACKAGE"|"$(PACKAGE)"|g' \
| sed 's|"PACKAGE_STRING"|"$(PACKAGE_STRING)"|g' \
| sed 's|"USER_DATA_DIR"|"$(USER_DATA_DIR)"|g' \
| sed 's|"TEXTDOMAIN_CODESET"|"$(TEXTDOMAIN_CODESET)"|g' \
> %reldir%/tarot/config.scm-t
@mv %reldir%/tarot/config.scm-t %reldir%/tarot/config.scm
CLEANFILES += %reldir%/tarot/config.scm
if HAVE_GUILE
AM_CFLAGS += $(GUILE_CFLAGS)
......
;; tarot implements the rules of the tarot game
;; Copyright (C) 2019 Vivien Kraus
;; This program is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, version 3 of the License.
;;
;; This program is distributed in the hope that it will be useful, but
;; WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
(define-module (tarot config)
#:export (runtime-prefix-env
sysconfdir
localedir
datadir
package
package-string
user-data-dir
textdomain-codeset
absolute-datadir
absolute-sysconfdir
absolute-localedir
absolute-localdatadir))
(define runtime-prefix-env "RUNTIME_PREFIX_ENV")
(define sysconfdir "SYSCONFDIR")
(define localedir "LOCALEDIR")
(define datadir "DATADIR")
(define package "PACKAGE")
(define package-string "PACKAGE_STRING")
(define user-data-dir "USER_DATA_DIR")
(define textdomain-codeset "TEXTDOMAIN_CODESET")
(define runtime-prefix
(if (or (string=? runtime-prefix-env "no")
(string=? runtime-prefix-env ""))
""
(or (getenv runtime-prefix-env) "")))
(define absolute-sysconfdir (string-append runtime-prefix sysconfdir))
(define absolute-localedir (string-append runtime-prefix localedir))
(define absolute-datadir (string-append runtime-prefix datadir))
(define absolute-localdatadir
(let ((env (getenv user-data-dir))
(home (getenv "HOME"))
(is-xdg-data-home (string=? user-data-dir "XDG_DATA_HOME")))
(or env
(and is-xdg-data-home
(or (string-append home "/.local/share")
(error "The 'HOME' environment variable is not set")))
(error (string-append "The environment variable '" user-data-dir "' is not set.")))))
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