changeset 25:2a19b44c272e

convert to new ThemWi configure and build system
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 21 May 2024 01:59:17 +0000
parents f0139d74d3aa
children c8cb05b69118
files .hgignore Makefile configure enc-text/Makefile gen-pdu/Makefile libcoding/Makefile scripts/Makefile
diffstat 7 files changed, 88 insertions(+), 29 deletions(-) [+]
line wrap: on
line diff
--- a/.hgignore	Sat Sep 02 19:45:47 2023 +0000
+++ b/.hgignore	Tue May 21 01:59:17 2024 +0000
@@ -1,6 +1,7 @@
 syntax: regexp
 
 \.[oa]$
+^config\.defs$
 
 ^enc-text/sms-encode-text$
 ^gen-pdu/sms-gen-tpdu$
--- a/Makefile	Sat Sep 02 19:45:47 2023 +0000
+++ b/Makefile	Tue May 21 01:59:17 2024 +0000
@@ -1,26 +1,26 @@
-CC=	gcc
-CFLAGS=	-O2
 PROGDIR=enc-text gen-pdu scripts
 LIBDIR=	libcoding
 SUBDIR=	${PROGDIR} ${LIBDIR}
-
-INSTALL_PREFIX=	/opt/freecalypso
+DESTDIR=
 
 all:	${SUBDIR}
 
 enc-text:	libcoding
 gen-pdu:	libcoding
 
-${SUBDIR}: FRC
-	cd $@; ${MAKE} ${MFLAGS} CC=${CC} CFLAGS="${CFLAGS}"
+${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
-	mkdir -p ${INSTALL_PREFIX}
 	for i in ${PROGDIR}; do (cd $$i; ${MAKE} ${MFLAGS} \
-		INSTALL_PREFIX=${INSTALL_PREFIX} install); done
+		DESTDIR=${DESTDIR} install); done
 
 FRC:
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/configure	Tue May 21 01:59:17 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/enc-text/Makefile	Sat Sep 02 19:45:47 2023 +0000
+++ b/enc-text/Makefile	Tue May 21 01:59:17 2024 +0000
@@ -1,12 +1,8 @@
-CC=	gcc
-CFLAGS=	-O2
 PROG=	sms-encode-text
 OBJS=	concat_refno.o gsm7.o main.o ucs2.o
 LIBS=	../libcoding/libcoding.a
 
-INSTALL_PREFIX=	/opt/freecalypso
-
-INSTBIN=${INSTALL_PREFIX}/bin
+include ../config.defs
 
 all:	${PROG}
 
@@ -14,8 +10,8 @@
 	${CC} ${CFLAGS} -o $@ ${OBJS} ${LIBS}
 
 install:	${PROG}
-	mkdir -p ${INSTBIN}
-	install -c ${PROG} ${INSTBIN}
+	mkdir -p ${DESTDIR}${bindir}
+	install -c ${PROG} ${DESTDIR}${bindir}
 
 clean:
 	rm -f *.o *.out *errs ${PROG}
--- a/gen-pdu/Makefile	Sat Sep 02 19:45:47 2023 +0000
+++ b/gen-pdu/Makefile	Tue May 21 01:59:17 2024 +0000
@@ -1,12 +1,8 @@
-CC=	gcc
-CFLAGS=	-O2
 PROG=	sms-gen-tpdu
 OBJS=	auto_scts.o input.o main.o message.o settings.o
 LIBS=	../libcoding/libcoding.a
 
-INSTALL_PREFIX=	/opt/freecalypso
-
-INSTBIN=${INSTALL_PREFIX}/bin
+include ../config.defs
 
 all:	${PROG}
 
@@ -14,8 +10,8 @@
 	${CC} ${CFLAGS} -o $@ ${OBJS} ${LIBS}
 
 install:	${PROG}
-	mkdir -p ${INSTBIN}
-	install -c ${PROG} ${INSTBIN}
+	mkdir -p ${DESTDIR}${bindir}
+	install -c ${PROG} ${DESTDIR}${bindir}
 
 clean:
 	rm -f *.o *.out *errs ${PROG}
--- a/libcoding/Makefile	Sat Sep 02 19:45:47 2023 +0000
+++ b/libcoding/Makefile	Tue May 21 01:59:17 2024 +0000
@@ -1,10 +1,10 @@
-CC=	gcc
-CFLAGS=	-O2
 OBJS=	alpha_addr.o check_high_bit.o gsm7_encode.o gsm7_encode2.o \
 	gsm7_encode_table.o gsm7_pack.o hexdigits.o hexout.o number_encode.o \
 	timestamp.o ucs2_bigend.o utf8_decode.o utf8_decode2.o
 LIB=	libcoding.a
 
+include ../config.defs
+
 all:	${LIB}
 
 ${LIB}:	${OBJS}
--- a/scripts/Makefile	Sat Sep 02 19:45:47 2023 +0000
+++ b/scripts/Makefile	Tue May 21 01:59:17 2024 +0000
@@ -1,13 +1,11 @@
 SCRIPTS=gen-sms-deliver-pdu sms-deliver-pdu-hdr
 
-INSTALL_PREFIX=	/opt/freecalypso
-
-INSTBIN=${INSTALL_PREFIX}/bin
+include ../config.defs
 
 all:
 
 install:
-	mkdir -p ${INSTBIN}
-	install -c ${SCRIPTS} ${INSTBIN}
+	mkdir -p ${DESTDIR}${bindir}
+	install -c ${SCRIPTS} ${DESTDIR}${bindir}
 
 clean: