[PATCH] Move program configuration to config.def.h

From: sin <sin_AT_2f30.org>
Date: Fri, 5 Dec 2014 12:13:49 +0000

---
 Makefile     | 8 ++++++--
 config.def.h | 2 ++
 config.mk    | 2 +-
 slock.c      | 2 ++
 4 files changed, 11 insertions(+), 3 deletions(-)
 create mode 100644 config.def.h
diff --git a/Makefile b/Makefile
index 2bea555..1017ac2 100644
--- a/Makefile
+++ b/Makefile
_AT_@ -18,7 +18,11 @@ options:
 	_AT_echo CC $<
 	_AT_${CC} -c ${CFLAGS} $<
 
-${OBJ}: config.mk
+${OBJ}: config.h config.mk
+
+config.h:
+	_AT_echo creating $@ from config.def.h
+	_AT_cp config.def.h $@
 
 slock: ${OBJ}
 	_AT_echo CC -o $@
_AT_@ -31,7 +35,7 @@ clean:
 dist: clean
 	_AT_echo creating dist tarball
 	_AT_mkdir -p slock-${VERSION}
-	_AT_cp -R LICENSE Makefile README config.mk ${SRC} slock-${VERSION}
+	_AT_cp -R LICENSE Makefile README config.def.h config.mk ${SRC} slock-${VERSION}
 	_AT_tar -cf slock-${VERSION}.tar slock-${VERSION}
 	_AT_gzip slock-${VERSION}.tar
 	_AT_rm -rf slock-${VERSION}
diff --git a/config.def.h b/config.def.h
new file mode 100644
index 0000000..89e5977
--- /dev/null
+++ b/config.def.h
_AT_@ -0,0 +1,2 @@
+#define COLOR1 "black"
+#define COLOR2 "#005577"
diff --git a/config.mk b/config.mk
index 8cc3f68..067cfc7 100644
--- a/config.mk
+++ b/config.mk
_AT_@ -14,7 +14,7 @@ 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\"
+CPPFLAGS = -DVERSION=\"${VERSION}\" -DHAVE_SHADOW_H
 CFLAGS = -std=c99 -pedantic -Wall -Os ${INCS} ${CPPFLAGS}
 LDFLAGS = -s ${LIBS}
 
diff --git a/slock.c b/slock.c
index d281965..5051f04 100644
--- a/slock.c
+++ b/slock.c
_AT_@ -23,6 +23,8 @@
 #include <bsd_auth.h>
 #endif
 
+#include "config.h"
+
 typedef struct {
 	int screen;
 	Window root, win;
-- 
1.8.4
--envbJBWh7q8WU6mo--
Received on Mon Sep 17 2001 - 00:00:00 CEST

This archive was generated by hypermail 2.3.0 : Fri Dec 05 2014 - 18:36:04 CET