🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.misc.discuss
Article #72144

Re: About the GNU's project's path

#72144
From: Gray Watson
Date: Thu, 19 Mar 1992 15:53
213 lines
5225 bytes
e> Something I hate doing is editing a bunch of Makefiles and header
e> files and browsing through the man pages in order to manually con-
e> figure the program to work.

One of things that we do at Antaire is use a parent shell script to call make.
Our build script uses the i386/sparc/vax/etc machine commands (the ones that
are linked to /bin/true or /bin/false) and a Buildfile to set environmental
variables and then run make.  It can set variables like INCLUDES for which
include files to use, LIBRARIES for what libraries to link with, DEFINES for
what -D options to add, etc.

Basically, build coupled with standard Makefiles means that our source trees
compile with no (none, 0, nada) changes on 3 cpu-types types.  In my last job,
this was 8 cpu-types.  Okay, this isn't 90 but I don't see any large reasons
why it can't handle most if not all Unix boxes.

This solution assumes that each machine and system type:

	a) has sh or some sort of equivalent shell language
	b) has a make which can get variables from the environment (GNU)
	c) has the appropriate machine type commands: (sparc, vax, i386)
	d) has the appropriate operating system commands: (sunos4.1, ultrix)

So, in theory, GNU could decide on a set of machine-type commands and os-type
commands, and then deliver a Buildfile and build script which would
auto-configure the Makefile with env variables based on the machine/os
commands.  The rest would be done with #ifdefs.  This may not solve all the
configuration problems but it may improve the situation.

I've included a sample Buildfile and my build.sh.  Yes its hacky :-), but hey,
it works.  My build.sh also included a feature where a building directory is
"locked" so multiple programs can work on the same directory without going
nuts.

enjoy,
gray

p.s. This is not an original concept.  I got the general idea from
	rjy@med.pitt.edu (Russell J. Yount).

-------------------------------------------------------------------------------

#
# $Id: Buildfile,v 1.5 1992/02/06 22:24:16 gray Exp $
#

if i386; then
	if esix; then
		LIBRARIES="-lbsd -lnet"
	fi
	if isc; then
		LIBRARIES="-linet"
	fi
fi

if sparc; then
	DEFINES="-DDEBUG"
fi

-------------------------------------------------------------------------------

#!/bin/sh
#
# Build program for resolving system differences
#
# $Id: build.sh,v 2.14 1992/02/10 18:27:50 gray Exp $
#

MAKEFLAGS=
DEFINES=
CCFLAGS=
LOCKFILE=Build.lock
UNLOCK="/bin/rm -f $LOCKFILE"

if [ -r $LOCKFILE ]; then
	echo "File '$LOCKFILE' already exists: "
	echo -n "  "
	cat $LOCKFILE
	echo "Remove the lock by typing rm -f $LOCKFILE"
	exit 1
else
	echo "by '$USER' on '"`date '+%h %d  %T`"' args = '$*'" > $LOCKFILE
	chmod 660 $LOCKFILE
	trap '$UNLOCK' 1 2
fi

if [ "$BUILDING" = "" ]; then
	BUILDING=1
else
	BUILDING=`expr $BUILDING + 1`
fi

#
# run the local buildfile
#
if [ -r ./Buildfile ]; then
	. ./Buildfile
else
	if [ -r RCS/Buildfile,v ]; then
		co Buildfile

		. ./Buildfile
	fi
fi

#
# machine defines
#
if i386
then
	DEFINES="-Di386 "$DEFINES
fi

if mips
then
	DEFINES="-Dmips "$DEFINES
fi

if sparc
then
	DEFINES="-Dsparc "$DEFINES
fi

if vax
then
	DEFINES="-Dvax "$DEFINES
fi

#
# process arguments
#

OPT=0
DONE=0
while [ $# -gt 0 -a $DONE -eq 0 ]
do
	case $1 in
		-d | -D)
			# debug flag
			DEFINES="-DDEBUG "$DEFINES
			shift
			;;
		-o | -O)
			# optimize flag
			CCFLAGS="-O "$CCFLAGS
			OPT=1
			shift
			;;
		-w | -W)
			# warning flag for gcc compiler
			CCFLAGS="-Wall -Wshadow "$CCFLAGS
			shift
			;;
		--*)
			# pass special arguments onto make (--O -> -O)
			MAKEFLAGS=$MAKEFLAGS" "`echo $1 | cut -c2-100`
			shift
			;;
		-*)
			# pass argument onto make
			MAKEFLAGS=$MAKEFLAGS" "$1
			shift
			;;
		*)
			DONE=1
			;;
	esac
done

#
# debug flag is the default
#
CCFLAGS="-g "$CCFLAGS

export BUILDING CCFLAGS DEFINES INCLUDES LIBRARIES

#
# do we have any more arguments to process?
#
if [ $# -eq 0 ]; then
	MAKEFLAGS=$MAKEFLAGS
else
	MAKEFLAGS=$MAKEFLAGS" "$*
fi

#
# find a makefile to make
#
if [ ! -r ./Makefile ]; then
	if [ -r ./RCS/Makefile,v ]; then
		co ./RCS/Makefile,v
	else
		echo 'Warning: no Makefile.'
		echo 'include /usr/antaire/Default.make' > /usr/tmp/build.$$
		MAKEFLAGS=$MAKEFLAGS" -f /usr/tmp/build.$$"
	fi
fi

if [ "$MAKE" = "" ]; then
	MAKE=make
fi

if [ "$SHOWBUILD" != "" ]; then
	echo "Executing: $MAKE $MAKEFLAGS"
fi

$MAKE $MAKEFLAGS

# remove possible temporary file
rm -f /usr/tmp/build.$$

$UNLOCK
Technical Details
Message-ID: <9203191553.AA22324@antaire.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!antaire.COM!gray

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 1025b4,f83a59fcb4a9e8bb,start
X-Google-Attributes: gid1025b4,public
X-Google-ArrivalTime: 1992-03-19 08:14:12 PST
Newsgroups: gnu.misc.discuss
Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!antaire.COM!gray
From: gray@antaire.COM (Gray Watson)
Subject: Re: About the GNU's project's path
Message-ID: <9203191553.AA22324@antaire.com>
Sender: daemon@cis.ohio-state.edu
Reply-To: Gray.Watson@antaire.com
Organization: Antaire Corporation, Pittsburgh, PA, USA
Distribution: gnu
Date: Thu, 19 Mar 1992 15:53:23 GMT
Lines: 214