. ../../config/system
. ../../config/site

if [ _$ranlib = _yes ]; then
    ranlib_cmd=ranlib
else
    ranlib_cmd=touch
fi

if [ _$load_obj = _shl ]; then
    library=libutil.sl
    make_lib="../../scripts/linkext.shl \$@ \$(O)"
else
    library=libutil.a
    make_lib="ar clr \$@ \$(O)"
fi

echo Building Makefile.local...
cat <<EOT >Makefile.local
# This Makefile was produced by running ./build in this directory.

SHELL=/bin/sh

CC= ${cc-cc}
CFLAGS= $cflags $obj_cflags
LINTFLAGS= $lintflags

INC=	../../include

H=	\$(INC)/config.h\\
	\$(INC)/param.h\\
	\$(INC)/object.h\\
	\$(INC)/extern.h\\
	\$(INC)/misc.h\\
	\$(INC)/stkmem.h\\
	\$(INC)/cstring.h

C=	objects.c\\
	symbol.c

O=	objects.o\\
	symbol.o

.c.o:
	\$(CC) \$(CFLAGS) -I\$(INC) -c \$<

$library: \$(O)
	$make_lib
	$ranlib_cmd \$@

objects.o:	\$(H) objects.h objects.c
symbol.o:	\$(H) symbol.h symbol.c

install: $library
	-@if [ ! -d $lib_dir ]; then \\
	    echo mkdir $lib_dir; \\
	    mkdir $lib_dir; \\
	fi
	cp $library $lib_dir
	$ranlib_cmd $lib_dir/$library

lint:
	lint \$(LINTFLAGS) -I\$(INC) \$(C)

clean:
	rm -f *.o libutil.a libutil.sl core

distclean:
	rm -f *.o libutil.a libutil.sl core lint.out Makefile.local
EOT
