grug

A static website generator written for Guile Scheme
Log | Files | Refs | README | LICENSE

commit dabb4ff9068c0d9ebc56567c3f347eb0b9ea71ea
parent 1fac5b160d7985ac16ced11b00068617edbedd27
Author: Luke Willis <lukejw@loquat.dev>
Date:   Tue, 17 Jun 2025 11:50:24 -0400

Setup program skeleton

Diffstat:
AMakefile.am | 33+++++++++++++++++++++++++++++++++
MREADME.md | 4+++-
Abootstrap | 3+++
Aconfigure.ac | 23+++++++++++++++++++++++
Agrug/hello.scm | 6++++++
Aguix.scm | 25+++++++++++++++++++++++++
Apre-inst-env.in | 16++++++++++++++++
Ascripts/grug.in | 15+++++++++++++++
8 files changed, 124 insertions(+), 1 deletion(-)

diff --git a/Makefile.am b/Makefile.am @@ -0,0 +1,33 @@ +GOBJECTS = $(SOURCES:%.scm=%.go) + +nobase_mod_DATA = $(SOURCES) $(NOCOMP_SOURCES) +nobase_go_DATA = $(GOBJECTS) + +# Make sure source files are installed first, so that the mtime of +# installed compiled files is greater than that of installed source +# files. See +# <http://lists.gnu.org/archive/html/guile-devel/2010-07/msg00125.html> +# for details. +guile_install_go_files = install-nobase_goDATA +$(guile_install_go_files): install-nobase_modDATA + +EXTRA_DIST = $(SOURCES) $(NOCOMP_SOURCES) +GUILE_WARNINGS = -Wunbound-variable -Warity-mismatch -Wformat +SUFFIXES = .scm .go +.scm.go: + $(AM_V_GEN)$(top_builddir)/pre-inst-env $(GUILE_TOOLS) compile $(GUILE_WARNINGS) -o "$@" "$<" + +moddir=$(prefix)/share/guile/site/$(GUILE_EFFECTIVE_VERSION) +godir=$(libdir)/guile/$(GUILE_EFFECTIVE_VERSION)/site-ccache + +bin_SCRIPTS = \ + scripts/grug + +SOURCES = \ + grug/hello.scm + +EXTRA_DIST += \ + README.md \ + guix.scm \ + pre-inst-env.in + diff --git a/README.md b/README.md @@ -1,3 +1,5 @@ -# grug +# Grug A simple static site generator, written with [Guile](https://www.gnu.org/software/guile/), inspired by [haunt](https://dthompson.us/projects/haunt.html) +## Why? +I am learning to work with Guile. I originally had a simple shell script that used cmark to generate static pages for my website, but I quickly reached limitations. I started to use haunt as my generator of choice, and I greatly enjoyed using it, but I struggled to understand how it actually worked on the inside. I figured that making a Guile program of my own would be a good step for me to take as a programmer. diff --git a/bootstrap b/bootstrap @@ -0,0 +1,3 @@ +#!/bin/sh + +autoreconf -vif diff --git a/configure.ac b/configure.ac @@ -0,0 +1,23 @@ +AC_INIT([grug], [0.1]) +AC_CONFIG_SRCDIR([grug]) +AC_CONFIG_AUX_DIR([build-aux]) +AM_INIT_AUTOMAKE([-Wall -Werror foreign]) + +GUILE_PKG([3.0]) +GUILE_PROGS + +AC_CONFIG_FILES([Makefile]) +AC_CONFIG_FILES([pre-inst-env], [chmod +x pre-inst-env]) +AC_CONFIG_FILES([scripts/grug], [chmod +x scripts/grug]) + +dnl Compute complete installation directories for .scm and .go files +dnl so that the Grug executable can automagically add them to Guile's +dnl load path. +grug_prefix="`eval echo $prefix | sed -e"s|NONE|/usr/local|g"`" +grug_libdir="`eval echo $libdir | sed -e"s|NONE|$grug_prefix|g"`" +guilemoduledir="`eval echo ${datarootdir}/guile/site/$GUILE_EFFECTIVE_VERSION | sed -e"s|NONE|$grug_prefix|g"`" +guileobjectdir="`eval echo ${libdir}/guile/$GUILE_EFFECTIVE_VERSION/site-ccache | sed -e"s|NONE|$grug_prefix|g"`" +AC_SUBST([guilemoduledir]) +AC_SUBST([guileobjectdir]) + +AC_OUTPUT diff --git a/grug/hello.scm b/grug/hello.scm @@ -0,0 +1,6 @@ +(define-module (grug hello) + #:export (hello-world)) + +(define (hello-world) + (display "Hello, World!") + (newline)) diff --git a/guix.scm b/guix.scm @@ -0,0 +1,25 @@ +(use-modules (guix packages) + (guix licenses) + (guix git) + (guix build-system gnu) + (gnu packages) + (gnu packages autotools) + (gnu packages base) + (gnu packages guile) + (gnu packages guile-xyz) + (gnu packages pkg-config) + (gnu packages rsync) + (gnu packages texinfo) + (gnu packages version-control)) + +(package + (name "grug") + (version "0.1.0") + (source (git-checkout (url (dirname (current-filename))))) + (build-system gnu-build-system) + (native-inputs (list autoconf automake pkg-config)) + (inputs (list guile-3.0)) + (synopsis "Functional static site generator") + (description #f) + (home-page #f) + (license gpl3+)) diff --git a/pre-inst-env.in b/pre-inst-env.in @@ -0,0 +1,16 @@ +#!/bin/sh + +abs_top_srcdir="`cd "@abs_top_srcdir@" > /dev/null; pwd`" +abs_top_builddir="`cd "@abs_top_builddir@" > /dev/null; pwd`" + +GUILE_LOAD_COMPILED_PATH="$abs_top_builddir${GUILE_LOAD_COMPILED_PATH:+:}$GUILE_LOAD_COMPILED_PATH" +GUILE_LOAD_PATH="$abs_top_builddir:$abs_top_srcdir${GUILE_LOAD_PATH:+:}:$GUILE_LOAD_PATH" +export GUILE_LOAD_COMPILED_PATH GUILE_LOAD_PATH + +PATH="$abs_top_builddir/scripts:$PATH" +export PATH + +GRUG_UNINSTALLED=true +export GRUG_UNINSTALLED + +exec "$@" diff --git a/scripts/grug.in b/scripts/grug.in @@ -0,0 +1,15 @@ +#!@GUILE@ --no-auto-compile +!# + +(define-syntax-rule (push! elt v) (set! v (cons elt v))) + +;; Automatically add Grug modules to Guile's load path so that users +;; aren't wondering why Grug isn't working when the modules aren't +;; installed to Guile's default module locations. +(unless (getenv "GRUG_UNINSTALLED") + (push! "@guilemoduledir@" %load-path) + (push! "@guileobjectdir@" %load-compiled-path)) + +(use-modules (grug hello)) + +(hello-world)