changeset 10:2c022e0334c4

convert to new ThemWi configure and build system
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 21 May 2024 01:03:40 +0000
parents b6331ae4eea9
children b4b4a822286c
files .hgignore Makefile configure gen/Makefile libutil/Makefile smswrap/Makefile test/Makefile
diffstat 7 files changed, 91 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/.hgignore	Mon Feb 22 02:19:43 2021 +0000
+++ b/.hgignore	Tue May 21 01:03:40 2024 +0000
@@ -1,6 +1,7 @@
 syntax: regexp
 
 \.[oa]$
+^config\.defs$
 
 ^gen/ota-set-msisdn$
 
--- a/Makefile	Mon Feb 22 02:19:43 2021 +0000
+++ b/Makefile	Tue May 21 01:03:40 2024 +0000
@@ -1,6 +1,7 @@
 PROGDIR=gen smswrap test
 LIBDIR=	libutil
 SUBDIR=	${PROGDIR} ${LIBDIR}
+DESTDIR=
 
 all:	${SUBDIR}
 
@@ -8,14 +9,19 @@
 smswrap:	libutil
 test:		libutil
 
-${SUBDIR}: FRC
+${SUBDIR}: FRC config.defs
 	cd $@; ${MAKE} ${MFLAGS}
 
+config.defs:
+	@echo 'You must run ./configure before make'
+	@false
+
 clean: FRC
 	rm -f a.out core errs
 	for i in ${SUBDIR}; do (cd $$i; ${MAKE} ${MFLAGS} clean); done
 
 install: FRC
-	for i in ${PROGDIR}; do (cd $$i; ${MAKE} ${MFLAGS} install); done
+	for i in ${PROGDIR}; do (cd $$i; ${MAKE} ${MFLAGS} \
+		DESTDIR=${DESTDIR} install); done
 
 FRC:
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/configure	Tue May 21 01:03:40 2024 +0000
@@ -0,0 +1,68 @@
+#!/bin/sh
+# This configure script is custom and hand-coded;
+# it is NOT a product of GNU Autoconf or any other such tools!
+
+set -e
+
+if [ ! -f configure ]
+then
+	echo "This script needs to be run from the top of the source tree" 1>&2
+	exit 1
+fi
+
+# defaults that can be overridden
+CC=gcc
+CFLAGS=-O2
+prefix=/usr/local
+exec_prefix=
+bindir=
+
+while [ $# != 0 ]
+do
+	case "$1" in
+		--prefix=*)
+			prefix=`echo $1 | cut -c 10-`
+			;;
+		--exec-prefix=*)
+			exec_prefix=`echo $1 | cut -c 15-`
+			;;
+		--bindir=*)
+			bindir=`echo $1 | cut -c 10-`
+			;;
+		CC=*)
+			CC=`echo $1 | cut -c 4-`
+			;;
+		CFLAGS=*)
+			CFLAGS=`echo $1 | cut -c 8-`
+			;;
+		*)
+			echo "error: non-understood option $1" 1>&2
+			exit 1;
+			;;
+	esac
+	shift
+done
+
+# inheritance rules for install directories
+
+if [ -z "$exec_prefix" ]
+then
+	exec_prefix="$prefix"
+fi
+if [ -z "$bindir" ]
+then
+	bindir="$exec_prefix/bin"
+fi
+
+# report the final configuration
+
+echo "C code will be compiled with:"
+echo "  CC=$CC"
+echo "  CFLAGS=$CFLAGS"
+echo "Installation directory:"
+echo "  bindir=$bindir"
+
+# emit the Makefile include fragment
+echo "CC=$CC" > config.defs
+echo "CFLAGS=$CFLAGS" >> config.defs
+echo "bindir=$bindir" >> config.defs
--- a/gen/Makefile	Mon Feb 22 02:19:43 2021 +0000
+++ b/gen/Makefile	Tue May 21 01:03:40 2024 +0000
@@ -1,8 +1,7 @@
-CC=	gcc
-CFLAGS=	-O2
 PROGS=	ota-set-msisdn
 LIBS=	../libutil/libutil.a
-INSTBIN=/opt/freecalypso/bin
+
+include ../config.defs
 
 all:	${PROGS}
 
@@ -10,8 +9,8 @@
 	${CC} ${CFLAGS} -o $@ $@.o ${LIBS}
 
 install:
-	mkdir -p ${INSTBIN}
-	install -c ${PROGS} ${INSTBIN}
+	mkdir -p ${DESTDIR}${bindir}
+	install -c ${PROGS} ${DESTDIR}${bindir}
 
 clean:
 	rm -f ${PROGS} *.o
--- a/libutil/Makefile	Mon Feb 22 02:19:43 2021 +0000
+++ b/libutil/Makefile	Tue May 21 01:03:40 2024 +0000
@@ -1,8 +1,8 @@
-CC=	gcc
-CFLAGS=	-O2
 OBJS=	gsm7_encode.o gsm7_encode_table.o hexstdin.o hexstr.o number_encode.o
 LIB=	libutil.a
 
+include ../config.defs
+
 all:	${LIB}
 
 ${LIB}:	${OBJS}
--- a/smswrap/Makefile	Mon Feb 22 02:19:43 2021 +0000
+++ b/smswrap/Makefile	Tue May 21 01:03:40 2024 +0000
@@ -1,8 +1,7 @@
-CC=	gcc
-CFLAGS=	-O2
 PROGS=	ota-smswrap-sjs1
 LIBS=	../libutil/libutil.a
-INSTBIN=/opt/freecalypso/bin
+
+include ../config.defs
 
 all:	${PROGS}
 
@@ -10,8 +9,8 @@
 	${CC} ${CFLAGS} -o $@ $@.o ${LIBS} -lcrypto
 
 install:
-	mkdir -p ${INSTBIN}
-	install -c ${PROGS} ${INSTBIN}
+	mkdir -p ${DESTDIR}${bindir}
+	install -c ${PROGS} ${DESTDIR}${bindir}
 
 clean:
 	rm -f ${PROGS} *.o
--- a/test/Makefile	Mon Feb 22 02:19:43 2021 +0000
+++ b/test/Makefile	Tue May 21 01:03:40 2024 +0000
@@ -1,8 +1,7 @@
-CC=	gcc
-CFLAGS=	-O2
 PROGS=	ota-smspp-envelope
 LIBS=	../libutil/libutil.a
-INSTBIN=/opt/freecalypso/bin
+
+include ../config.defs
 
 all:	${PROGS}
 
@@ -10,8 +9,8 @@
 	${CC} ${CFLAGS} -o $@ $@.o ${LIBS}
 
 install:
-	mkdir -p ${INSTBIN}
-	install -c ${PROGS} ${INSTBIN}
+	mkdir -p ${DESTDIR}${bindir}
+	install -c ${PROGS} ${DESTDIR}${bindir}
 
 clean:
 	rm -f ${PROGS} *.o