[hackers] [libgrapheme] Add ./configure-script with presets for common systems || Laslo Hunhold

From: <git_AT_suckless.org>
Date: Tue, 11 Oct 2022 22:28:13 +0200 (CEST)

commit 30766915c37d88fc423a4d750227a769e7a307ae
Author: Laslo Hunhold <dev_AT_frign.de>
AuthorDate: Tue Oct 11 22:21:47 2022 +0200
Commit: Laslo Hunhold <dev_AT_frign.de>
CommitDate: Tue Oct 11 22:21:47 2022 +0200

    Add ./configure-script with presets for common systems
    
    After quite a few requests and a bit of reflection on my behalf I've
    decided to add a very simple ./configure-script that automatically
    modifies config.mk to make it fit for common systems.
    
    Even though it's reasonable to simply have out-commentable options
    in the config.mk, it is admittedly more convenient to have such a
    script available, especially to accomodate more systems along the way.
    
    uname(1) is Posix compliant and this ./configure-script is in no way
    comparable to the horrible autoconf-insanity and won't take an eternity
    to run. It's also completely optional and merely a
    quality-of-life-addition for those working with libgrapheme manually.
    
    Signed-off-by: Laslo Hunhold <dev_AT_frign.de>

diff --git a/config.mk b/config.mk
index 32829c3..f1ba0c6 100644
--- a/config.mk
+++ b/config.mk
_AT_@ -1,4 +1,4 @@
-# Customize below to fit your system
+# Customize below to fit your system (run ./configure for automatic presets)
 
 # paths
 PREFIX = /usr/local
_AT_@ -21,18 +21,6 @@ SOFLAGS = -shared -nostdlib -Wl,--soname=libgrapheme.so.$(VERSION_MAJOR).$(VER
 SONAME = libgrapheme.so.$(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_PATCH)
 SOSYMLINK = true
 
-# -- OpenBSD -- (also unset LDCONFIG)
-# SOFLAGS = -shared -nostdlib
-# SONAME = libgrapheme.so.$(VERSION_MAJOR).$(VERSION_MINOR)
-# SOSYMLINK = false
-
-# -- macOS -- (also unset LDCONFIG)
-# SOFLAGS = -dynamiclib -install_name "libgrapheme.$(VERSION_MAJOR).dylib" \
-# -current_version "$(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_PATCH)" \
-# -compatibility_version "$(VERSION_MAJOR).$(VERSION_MINOR).0"
-# SONAME = libgrapheme.$(VERSION_MAJOR).dylib
-# SOSYMLINK = false
-
 # tools
 CC = cc
 BUILD_CC = $(CC)
diff --git a/configure b/configure
new file mode 100755
index 0000000..69df018
--- /dev/null
+++ b/configure
_AT_@ -0,0 +1,39 @@
+#!/bin/sh
+# See LICENSE file for copyright and license details.
+
+replace_line()
+{
+ VAR=$1
+ ALIGNMENT=$2
+ VALUE=$3
+ awk "/^${VAR}[ ]*=/ { print \"${VAR}${ALIGNMENT} = ${VALUE}\"; next }; { print; }" config.mk > config.mk.tmp
+ mv config.mk.tmp config.mk
+}
+
+case $(uname) in
+ DragonFly|FreeBSD|Linux|NetBSD)
+ # the default
+ replace_line 'SOFLAGS' ' ' '-shared -nostdlib -Wl,--soname=libgrapheme.so.$(VERSION_MAJOR).$(VERSION_MINOR)'
+ replace_line 'SONAME' ' ' 'libgrapheme.so.$(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_PATCH)'
+ replace_line 'SOSYMLINK' '' 'true'
+ replace_line 'LDCONFIG' '' 'ldconfig \# unset to not call ldconfig(1) after install/uninstall'
+ ;;
+ OpenBSD)
+ replace_line 'SOFLAGS' ' ' '-shared -nostdlib'
+ replace_line 'SONAME' ' ' 'libgrapheme.so.$(VERSION_MAJOR).$(VERSION_MINOR)'
+ replace_line 'SOSYMLINK' '' 'false'
+ replace_line 'LDCONFIG' '' ''
+ ;;
+ Darwin)
+ replace_line 'SOFLAGS' ' ' '-dynamiclib -install_name libgrapheme.$(VERSION_MAJOR).dylib -current_version $(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_PATCH) -compatibility_version $(VERSION_MAJOR).$(VERSION_MINOR).0'
+ replace_line 'SONAME' ' ' 'libgrapheme.$(VERSION_MAJOR).dylib'
+ replace_line 'SOSYMLINK' '' 'false'
+ replace_line 'LDCONFIG' '' ''
+ ;;
+ *)
+ echo "Your system does not have a preset. Edit config.mk and send a patch please! :)"
+ exit 1
+ ;;
+esac
+
+exit 0
Received on Tue Oct 11 2022 - 22:28:13 CEST

This archive was generated by hypermail 2.3.0 : Tue Oct 11 2022 - 22:36:36 CEST