libgrapheme

unicode string library
git clone git://git.suckless.org/libgrapheme
Log | Files | Refs | README | LICENSE

commit 30766915c37d88fc423a4d750227a769e7a307ae
parent 858c34a1e19bd790510bb918c583cea73487e64e
Author: Laslo Hunhold <dev@frign.de>
Date:   Tue, 11 Oct 2022 22:21:47 +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@frign.de>

Diffstat:
Mconfig.mk | 14+-------------
Aconfigure | 39+++++++++++++++++++++++++++++++++++++++
2 files changed, 40 insertions(+), 13 deletions(-)

diff --git a/config.mk b/config.mk @@ -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 @@ -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 @@ -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