On Thu, Nov 14, 2013 at 02:24:53PM +0200, sin wrote: > Hi all, > > This is similar to what we do with http://git.suckless.org/utmp. > Take this with a grain of salt at the moment. There are some smaller > fixes embedded in this commit and it might be wise to split those > out. > > Second step is to split the ifdef'ed code out into bsd.c and linux.c > or similar (and update the OBJ entries from the corresponding config.* > files.) > > Let me know what you think.
Would be ideal to have attached the patch.
>From 75f8d2b6bc09e0125f07f2dacc226ab7242e0a8f Mon Sep 17 00:00:00 2001 From: sin <s...@2f30.org> Date: Thu, 14 Nov 2013 11:42:43 +0000 Subject: [PATCH 2/2] Add a tiny configure script for BSD and Linux systems --- Makefile | 7 +++++-- config.bsd | 23 +++++++++++++++++++++++ config.linux | 23 +++++++++++++++++++++++ config.mk | 30 ------------------------------ configure | 10 ++++++++++ 5 files changed, 61 insertions(+), 32 deletions(-) create mode 100644 config.bsd create mode 100644 config.linux delete mode 100644 config.mk create mode 100755 configure diff --git a/Makefile b/Makefile index 2bea555..2bf78e5 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,9 @@ # slock - simple screen locker # See LICENSE file for copyright and license details. +# slock version +VERSION=1.2 + include config.mk SRC = slock.c @@ -40,8 +43,8 @@ install: all @echo installing executable file to ${DESTDIR}${PREFIX}/bin @mkdir -p ${DESTDIR}${PREFIX}/bin @cp -f slock ${DESTDIR}${PREFIX}/bin - @chmod 755 ${DESTDIR}${PREFIX}/bin/slock - @chmod u+s ${DESTDIR}${PREFIX}/bin/slock + @chgrp ${GROUP} ${DESTDIR}${PREFIX}/bin/slock + @chmod ${MODE} ${DESTDIR}${PREFIX}/bin/slock uninstall: @echo removing executable file from ${DESTDIR}${PREFIX}/bin diff --git a/config.bsd b/config.bsd new file mode 100644 index 0000000..afbc825 --- /dev/null +++ b/config.bsd @@ -0,0 +1,23 @@ +# Customize below to fit your system + +# paths +PREFIX = /usr/local + +X11INC = /usr/X11R6/include +X11LIB = /usr/X11R6/lib + +# includes and libs +INCS = -I${X11INC} +LIBS = -L${X11LIB} -lX11 -lXext + +# flags +CPPFLAGS = -DVERSION=\"${VERSION}\" -DHAVE_BSD_AUTH -DCOLOR1=\"black\" -DCOLOR2=\"\#005577\" +CFLAGS += ${INCS} ${CPPFLAGS} +LDFLAGS += ${LIBS} + +# compiler and linker +CC = cc + +# install mode +MODE=2755 +GROUP=auth diff --git a/config.linux b/config.linux new file mode 100644 index 0000000..41bfe4f --- /dev/null +++ b/config.linux @@ -0,0 +1,23 @@ +# Customize below to fit your system + +# paths +PREFIX = /usr/local + +X11INC = /usr/X11R6/include +X11LIB = /usr/X11R6/lib + +# includes and libs +INCS = -I. -I/usr/include -I${X11INC} +LIBS = -L/usr/lib -lc -lcrypt -L${X11LIB} -lX11 -lXext + +# flags +CPPFLAGS = -DVERSION=\"${VERSION}\" -DHAVE_SHADOW_H -DCOLOR1=\"black\" -DCOLOR2=\"\#005577\" +CFLAGS = -std=c99 -pedantic -Wall -Os ${INCS} ${CPPFLAGS} +LDFLAGS = -s ${LIBS} + +# compiler and linker +CC = cc + +# install mode +MODE=4755 +GROUP=root diff --git a/config.mk b/config.mk deleted file mode 100644 index 8cc3f68..0000000 --- a/config.mk +++ /dev/null @@ -1,30 +0,0 @@ -# slock version -VERSION = 1.2 - -# Customize below to fit your system - -# paths -PREFIX = /usr/local - -X11INC = /usr/X11R6/include -X11LIB = /usr/X11R6/lib - -# includes and libs -INCS = -I. -I/usr/include -I${X11INC} -LIBS = -L/usr/lib -lc -lcrypt -L${X11LIB} -lX11 -lXext - -# flags -CPPFLAGS = -DVERSION=\"${VERSION}\" -DHAVE_SHADOW_H -DCOLOR1=\"black\" -DCOLOR2=\"\#005577\" -CFLAGS = -std=c99 -pedantic -Wall -Os ${INCS} ${CPPFLAGS} -LDFLAGS = -s ${LIBS} - -# On *BSD remove -DHAVE_SHADOW_H from CPPFLAGS and add -DHAVE_BSD_AUTH -# On OpenBSD and Darwin remove -lcrypt from LIBS - -# compiler and linker -CC = cc - -# Install mode. On BSD systems MODE=2755 and GROUP=auth -# On others MODE=4755 and GROUP=root -#MODE=2755 -#GROUP=auth diff --git a/configure b/configure new file mode 100755 index 0000000..82db20d --- /dev/null +++ b/configure @@ -0,0 +1,10 @@ +#!/bin/sh + +case $(uname) in +*BSD) + ln config.bsd config.mk + ;; +*) + ln config.linux config.mk + ;; +esac \ No newline at end of file -- 1.8.4.2