changeset 18:f7321b25195e default tip

new build system for ThemWi sw components
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 14 May 2024 18:08:35 -0800
parents 830af7de3403
children
files .hgignore Makefile configure librtpalloc/Makefile libsip/Makefile libutil/Makefile test-fsk/Makefile test-v22/Makefile test-voice/Makefile tone-detect/Makefile
diffstat 10 files changed, 99 insertions(+), 28 deletions(-) [+]
line wrap: on
line diff
--- a/.hgignore	Mon May 13 22:31:24 2024 -0800
+++ b/.hgignore	Tue May 14 18:08:35 2024 -0800
@@ -1,6 +1,7 @@
 syntax: regexp
 
 \.[oa]$
+^config\.defs$
 
 ^test-fsk/sipout-test-fsk$
 ^test-v22/sipout-test-v22$
--- a/Makefile	Mon May 13 22:31:24 2024 -0800
+++ b/Makefile	Tue May 14 18:08:35 2024 -0800
@@ -1,6 +1,3 @@
-CC=	gcc
-CFLAGS=	-O2
-
 PROGDIR=test-fsk test-v22 test-voice tone-detect
 LIBDIR=	librtpalloc libsip libutil
 SUBDIR=	${PROGDIR} ${LIBDIR}
@@ -11,14 +8,19 @@
 test-v22:	librtpalloc libsip libutil
 test-voice:	librtpalloc libsip libutil
 
-${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
-	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 14 18:08:35 2024 -0800
@@ -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/librtpalloc/Makefile	Mon May 13 22:31:24 2024 -0800
+++ b/librtpalloc/Makefile	Tue May 14 18:08:35 2024 -0800
@@ -1,8 +1,8 @@
-CC=	gcc
-CFLAGS=	-O2
 OBJS=	rtp_alloc_simple.o rtpmgr_resp.o
 LIB=	librtpalloc.a
 
+include ../config.defs
+
 all:	${LIB}
 
 ${LIB}:	${OBJS}
--- a/libsip/Makefile	Mon May 13 22:31:24 2024 -0800
+++ b/libsip/Makefile	Tue May 14 18:08:35 2024 -0800
@@ -1,9 +1,9 @@
-CC=	gcc
-CFLAGS=	-O2
 OBJS=	get_header.o grok_from.o out_msg.o primary_parse.o req_supp.o \
 	resp_ident.o sdp_gen.o sdp_parse.o to_tag.o uas_basic.o uri_utils.o
 LIB=	libsip.a
 
+include ../config.defs
+
 all:	${LIB}
 
 ${LIB}:	${OBJS}
--- a/libutil/Makefile	Mon May 13 22:31:24 2024 -0800
+++ b/libutil/Makefile	Tue May 14 18:08:35 2024 -0800
@@ -1,8 +1,8 @@
-CC=	gcc
-CFLAGS=	-O2
 OBJS=	bitfunc.o crc8gen.o g711_decode.o sockinit.o tfo_msg_enc.o
 LIB=	libutil.a
 
+include ../config.defs
+
 all:	${LIB}
 
 ${LIB}:	${OBJS}
--- a/test-fsk/Makefile	Mon May 13 22:31:24 2024 -0800
+++ b/test-fsk/Makefile	Tue May 14 18:08:35 2024 -0800
@@ -1,10 +1,9 @@
-CC=	gcc
-CFLAGS=	-O2
 PROG=	sipout-test-fsk
 OBJS=	bye_in.o disc_cmd.o main.o modem_rx.o readconf.o reinvite.o rtp_rx.o \
 	rtp_tx.o sdp_in.o sip_log.o sip_udp.o uac.o uas.o user_cmd.o
 LIBS=	../libsip/libsip.a ../librtpalloc/librtpalloc.a ../libutil/libutil.a
-INSTBIN=/opt/themwi/bin
+
+include ../config.defs
 
 all:	${PROG}
 
@@ -12,7 +11,8 @@
 	${CC} ${CFLAGS} -o $@ ${OBJS} ${LIBS} -lspandsp -lm
 
 install:
-	install -c -m 755 ${PROG} ${INSTBIN}
+	mkdir -p ${DESTDIR}${bindir}
+	install -c -m 755 ${PROG} ${DESTDIR}${bindir}
 
 clean:
 	rm -f *.o ${PROG} errs
--- a/test-v22/Makefile	Mon May 13 22:31:24 2024 -0800
+++ b/test-v22/Makefile	Tue May 14 18:08:35 2024 -0800
@@ -1,10 +1,9 @@
-CC=	gcc
-CFLAGS=	-O2
 PROG=	sipout-test-v22
 OBJS=	bye_in.o disc_cmd.o main.o modem_func.o readconf.o reinvite.o rtp_rx.o \
 	rtp_tx.o sdp_in.o sip_log.o sip_udp.o uac.o uas.o user_cmd.o
 LIBS=	../libsip/libsip.a ../librtpalloc/librtpalloc.a ../libutil/libutil.a
-INSTBIN=/opt/themwi/bin
+
+include ../config.defs
 
 all:	${PROG}
 
@@ -12,7 +11,8 @@
 	${CC} ${CFLAGS} -o $@ ${OBJS} ${LIBS} -lspandsp -lm
 
 install:
-	install -c -m 755 ${PROG} ${INSTBIN}
+	mkdir -p ${DESTDIR}${bindir}
+	install -c -m 755 ${PROG} ${DESTDIR}${bindir}
 
 clean:
 	rm -f *.o ${PROG} errs
--- a/test-voice/Makefile	Mon May 13 22:31:24 2024 -0800
+++ b/test-voice/Makefile	Tue May 14 18:08:35 2024 -0800
@@ -1,10 +1,9 @@
-CC=	gcc
-CFLAGS=	-O2
 PROG=	sipout-test-voice
 OBJS=	bye_in.o disc_cmd.o main.o pcmu_catcher.o readconf.o reinvite.o \
 	rtp_rx.o rtp_tx.o sdp_in.o sip_log.o sip_udp.o uac.o uas.o user_cmd.o
 LIBS=	../libsip/libsip.a ../librtpalloc/librtpalloc.a ../libutil/libutil.a
-INSTBIN=/opt/themwi/bin
+
+include ../config.defs
 
 all:	${PROG}
 
@@ -12,7 +11,8 @@
 	${CC} ${CFLAGS} -o $@ ${OBJS} ${LIBS}
 
 install:
-	install -c -m 755 ${PROG} ${INSTBIN}
+	mkdir -p ${DESTDIR}${bindir}
+	install -c -m 755 ${PROG} ${DESTDIR}${bindir}
 
 clean:
 	rm -f *.o ${PROG} errs
--- a/tone-detect/Makefile	Mon May 13 22:31:24 2024 -0800
+++ b/tone-detect/Makefile	Tue May 14 18:08:35 2024 -0800
@@ -1,7 +1,6 @@
-CC=	gcc
-CFLAGS=	-O2
 PROG=	g711-tone-detect
-INSTBIN=/opt/themwi/bin
+
+include ../config.defs
 
 all:	${PROG}
 
@@ -9,7 +8,8 @@
 	${CC} ${CFLAGS} -o $@ $@.c -lspandsp -lm
 
 install:
-	install -c -m 755 ${PROG} ${INSTBIN}
+	mkdir -p ${DESTDIR}${bindir}
+	install -c -m 755 ${PROG} ${DESTDIR}${bindir}
 
 clean:
 	rm -f *.o ${PROG} errs