Subject: Re: [PATCH 3/5] gnu: Add libgeramun.

From: Liliana Marie Prikler <[email-masked]>
Date: Tue, 14 Mar 2023 20:41:32 +0100

Am Dienstag, dem 14.03.2023 um 15:09 +0800 schrieb Adam Faiz:
>  From 03a5262a846175be5ce4c8e1b9ea6d199a46b4fa Mon Sep 17 00:00:00
> 2001
> Message-Id:
> <03a5262a846175be5ce4c8e1b9ea6d199a46b4fa.1678775193.git.adam.faiz@di
> sroot.org>
> In-Reply-To: <[email-masked]>
> References: <[email-masked]>
> From: AwesomeAdam54321 <[email-masked]>
> Date: Tue, 14 Mar 2023 14:02:58 +0800
> Subject: [PATCH 3/5] gnu: Add libgeramun.
> 
> * gnu/packages/game-development.scm (libgeramun): New variable.
> * gnu/packages/patches/libgeramun-Add-Makefile.patch: New file.
> * gnu/local.mk (dist_patch_DATA): Register it.
> ---
>   gnu/local.mk                                  |  1 +
>   gnu/packages/game-development.scm             | 41 ++++++++++
>   .../patches/libgeramun-Add-Makefile.patch     | 79
> +++++++++++++++++++
>   3 files changed, 121 insertions(+)
>   create mode 100644 gnu/packages/patches/libgeramun-Add-
> Makefile.patch
> 
> diff --git a/gnu/local.mk b/gnu/local.mk
> index 1bdbddce5e..228ec92bb1 100644
> --- a/gnu/local.mk
> +++ b/gnu/local.mk
> @@ -1382,6 +1382,7 @@ dist_patch_DATA
> =                                         \
>     %D%/packages/patches/libffi-3.3-powerpc-fixes.patch         \
>     %D%/packages/patches/libffi-float128-powerpc64le.patch      \
>     %D%/packages/patches/libgeotiff-fix-tests-with-proj-
> 9.1.1.patch     \
> +  %D%/packages/patches/libgeramun-Add-Makefile.patch   \
>     %D%/packages/patches/libobjc2-unbundle-robin-map.patch      \
>     %D%/packages/patches/librime-fix-build-with-gcc10.patch     \
>     %D%/packages/patches/libvirt-add-install-prefix.patch       \
> diff --git a/gnu/packages/game-development.scm b/gnu/packages/game-
> development.scm
> index f86793fda0..57bffa9b88 100644
> --- a/gnu/packages/game-development.scm
> +++ b/gnu/packages/game-development.scm
> @@ -2494,6 +2494,47 @@ (define-public libccd
>   a.k.a. XenoCollide) as described in Game Programming Gems 7.")
>       (license license:expat)))
>   
> +(define-public libgeramun
> +  (let ((commit "29668d33266a00fa730d8ee5a16893a86ee2d04d")
> +             (revision "0"))
> +  (package
> +    (name "libgeramun")
> +    (version (git-version "0.14" revision commit))
> +    (source (origin
> +              (method git-fetch)
> +              (uri (git-reference
> +                    (url "https://gitlab.com/hydren/libgeramun")
> +                    (commit commit)))
> +              (file-name (git-file-name name version))
> +              (sha256
> +               (base32
> +               
> "1nfsdyp3nnz33wxy54vnbbm50kr2y5h6q40kz6g1whz12lqmi79n"))
> +              (patches
> +               (search-patches "libgeramun-Add-Makefile.patch"))
We prefer not to add too many capital letters.
> +              (modules '((guix build utils)))
> +              (snippet
> +               #~(begin
> +                   (for-each
> +                    (lambda (file)
> +                      (install-file file "include/libgeramun"))
> +                    (find-files "." "\\.h"))))))
This only matches the .hpp files by accident.  Use "\\.h(pp)?$"
instead.
> +    (build-system gnu-build-system)
> +    (arguments
> +     (list #:tests? #f ; no tests
> +           #:phases
> +           #~(modify-phases %standard-phases
> +               (delete 'configure))
> +           #:make-flags
> +           #~(list (string-append "DESTDIR=" #$output)
> +                   "PREFIX=")))
> +    (synopsis "Procedural platformer-game map generation library")
> +    (description
> +     "libgeramun is a set of
> +stochastic, procedural platformer-game map generation routines.
> +  The routines are meant to produce maps with a Terraria-like look
> and feel.")
Don't break lines abruptly.  Also, you don't need to indent the
beginning of sentences.
> +    (home-page "https://gitlab.com/hydren/libgeramun")
> +    (license license:gpl2+))))
> +
>   (define-public ode
>     (package
>       (name "ode")
> diff --git a/gnu/packages/patches/libgeramun-Add-Makefile.patch
> b/gnu/packages/patches/libgeramun-Add-Makefile.patch
> new file mode 100644
> index 0000000000..01a94d6422
> --- /dev/null
> +++ b/gnu/packages/patches/libgeramun-Add-Makefile.patch
> @@ -0,0 +1,79 @@
> +From ac239d7be2755dc28fa831ba15a0fb318848a5a6 Mon Sep 17 00:00:00
> 2001
> +From: AwesomeAdam54321 <[email-masked]>
> +Date: Sun, 12 Mar 2023 01:30:46 +0800
> +Subject: [PATCH] libgeramun: Add Makefile.
> +
> +Adapted from
> https://gitlab.com/hydren/terrarium/-/raw/master/build/linux-gcc-sdl2-release/src_libs/libgeramun/subdir.mk
> +---
> + Makefile | 59
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> + 1 file changed, 59 insertions(+)
> + create mode 100644 Makefile
> +
> +diff --git a/Makefile b/Makefile
> +new file mode 100644
> +index 0000000..8d37ce4
> +--- /dev/null
> ++++ b/Makefile
> +@@ -0,0 +1,59 @@
> ++###################################################################
> #############
> ++# Automatically-generated file. Do not edit!
> ++###################################################################
> #############
> ++
> ++# Add inputs and outputs from these tool invocations to the build
> variables
> ++CPP_SRCS += \
> ++brush.cpp \
> ++cave.cpp \
> ++debug.cpp \
> ++generators.cpp \
> ++midpoint_displacement.cpp \
> ++miners.cpp \
> ++preview_callback.cpp \
> ++random_walk.cpp \
> ++spring.cpp \
> ++surf_replacer.cpp
> ++
> ++OBJS += \
> ++brush.so \
> ++cave.so \
> ++debug.so \
> ++generators.so \
> ++midpoint_displacement.so \
> ++miners.so \
> ++preview_callback.so \
> ++random_walk.so \
> ++spring.so \
> ++surf_replacer.so
Is it really necessary to make all of the objects shared?

> ++SRCDIR ?= .
> ++INCLUDE_PATH ?= ${SRCDIR}/include
> ++PREFIX ?= /usr/local
> ++
> ++all: libgeramun.so
> ++
> ++libgeramun.so: $(OBJS) $(USER_OBJS)
> ++      @echo 'Building target: $@'
> ++      @echo 'Invoking: GCC C++ Linker'
> ++      g++ -shared -o "libgeramun.so" $(OBJS) $(USER_OBJS) $(LIBS)
> ++      @echo 'Finished building target: $@'
> ++      @echo ' '
> ++
> ++install: all
> ++      install -d $(DESTDIR)$(PREFIX)
> ++      cp -r include $(DESTDIR)$(PREFIX)
> ++      install -d $(DESTDIR)$(PREFIX)/lib
> ++      install -m 644 libgeramun.so $(DESTDIR)$(PREFIX)/lib
> ++
> ++%.so: %.cpp
> ++      @echo 'Building file: $<'
> ++      @echo 'Invoking: GCC C++ Compiler'
> ++      g++ -I${INCLUDE_PATH} -O3 -Wall -shared -fPIC -c -fmessage-
> length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@)" -o "$@" "$<"
I think some of this ought to be abstracted into CFLAGS and similar
variables.

Also note that a Makefile isn't strictly needed.
You could just as well
  (apply invoke #$(cc-for-target) "-shared" "-o" "libgeramun.so"
         ;; some more CFLAGS
         (find-files "." "\\.cpp"))          

Cheers