[1828] in Kerberos_V5_Development

home help back first fref pref prev next nref lref last post

Re: make vs. gmake and the Athena source tree

daemon@ATHENA.MIT.EDU (Greg Hudson)
Mon Sep 30 14:46:47 1996

To: Marc Horowitz <marc@MIT.EDU>
Cc: Greg Hudson <ghudson@MIT.EDU>, krbdev@MIT.EDU
In-Reply-To: Your message of "Mon, 30 Sep 1996 13:24:01 EDT."
             <199609301724.NAA25771@beeblebrox.MIT.EDU> 
Date: Mon, 30 Sep 1996 14:46:39 EDT
From: Greg Hudson <ghudson@MIT.EDU>

> If someone can propose a maintainable solution which uses none of
> these, I'll shut up.  I just haven't seen one yet.

Okay, sure.  As I mentioned in my initial message, I maintain that
suffix substitutions are okay for the purpose of rel-eng but a bad
strategic move for Kerberos, so you get a little bit of choice in the
Makefile (see the comments).  As I mentioned before, the potential for
maintainer error in updating three identical lists of object files is
pretty low, so I don't think using suffix substitutions is much of a
win.

I borrowed a little bit from the tcl configure.in.  This
implementation may not be immediately applicable to platforms with
especially bogus ways of generating shared libraries; you can either
choose not to support shared libraries on those systems, or write
scripts to generated shared libraries for those systems.

Obviously, you'll need to add a bit more hair to support the sources
being in multiple directories.

configure.in is:

AC_INIT(obj1.c)

AC_ARG_ENABLE(profiled, [help string], [profiled="$enableval"], [profiled=no])
AC_ARG_ENABLE(shared, [help string], [shared="$enableval"], [shared=no])

AC_PROG_CC
AC_CANONICAL_SYSTEM

dnl Determine parameters for making shared libraries.
PROF_CFLAGS="-pg"
SHLIB_CFLAGS=""
SHLIB_LD=":"
case "$target" in
	*-*-linux*)
		SHLIB_CFLAGS="-fPIC"
		SHLIB_LD="${CC} -shared"
		;;
	*-*-irix*)
		SHLIB_LD="ld -shared -rdata_shared"
		;;
	*-*-netbsd*)
		SHLIB_CFLAGS="-fPIC"
		SHLIB_LD="ld -Bshareable"
		;;
	*-*-solaris2*)
		SHLIB_CFLAGS="-K PIC"
		SHLIB_LD="/usr/ccs/bin/ld -G -z text"
		;;
esac
AC_SUBST(PROF_CFLAGS)
AC_SUBST(SHLIB_CFLAGS)
AC_SUBST(SHLIB_LD)

MAKELIBS='lib${LIB_NAME}.a'
if test "$profiled" != "no"; then
	MAKELIBS="$MAKELIBS "'lib${LIB_NAME}_p.a'
fi
if test "$shared" != "no"; then
	MAKELIBS="$MAKELIBS "'lib${LIB_NAME}.so.${SHLIB_VERSION}'
fi
AC_SUBST(MAKELIBS)

AC_OUTPUT(Makefile)

Makefile.in is:

# Boilerplate stuff.

CC=@CC@
CFLAGS=@CFLAGS@
PROF_CFLAGS=@PROF_CFLAGS@
SHLIB_CFLAGS=@SHLIB_CFLAGS@
SHLIB_LD=@SHLIB_LD@
MAKELIBS=@MAKELIBS@

.SUFFIXES: .so .po

# The actual Makefile.

LIB_NAME=test
SHLIB_VERSION=1.3

OBJS=obj1.o obj2.o obj3.o
SHOBJS=obj1.so obj2.so obj3.so
POBJS=obj1.po obj2.po obj3.po
# Or:
# SHOBS=${OBJS:.o=.so}
# POBJS=${OBJS:.o=.po}

all: ${MAKELIBS}

clean:
	rm -f ${OBJS} ${SHOBJS} ${POBJS} ${MAKELIBS}

# More boilerplate stuff.

lib${LIB_NAME}.a: ${OBJS}
	ar cru $@ ${OBJS}

lib${LIB_NAME}_p.a: ${POBJS}
	ar cru $@ ${POBJS}

lib${LIB_NAME}.so.${SHLIB_VERSION}: ${SHOBJS}
	${SHLIB_LD} -o $@ ${SHOBJS}

.c.po:
	${CC} ${CFLAGS} ${PROF_CFLAGS} -c $< -o $@

.c.so:
	${CC} ${CFLAGS} ${SHLIB_CFLAGS} -c $< -o $@

home help back first fref pref prev next nref lref last post