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

if [ _$gdbm = _yes ]; then
    gdbm_c="gdbm.c"
    gdbm_o="gdbm.o"
    gdbm_rule="gdbm.o:		\$(H) gdbm.c"
fi

if [ _$load_obj != _ ]; then
    linkext="../../scripts/linkext-$load_obj \$@ \$@"
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=	chdir.c\\
	debug.c\\
	hack.c\\
	hunk.c\\
	monitor.c\\
	newhandler.c\\
	struct.c\\
	unix.c $gdbm_c

O=	chdir.o\\
	debug.o\\
	hack.o\\
	hunk.o\\
	monitor.o\\
	newhandler.o\\
	struct.o\\
	unix.o $gdbm_o

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

all: \$(O)

chdir.o:	\$(H) chdir.c
debug.o:	\$(H) debug.c
hack.o:		\$(H) hack.c
hunk.o:		\$(H) hunk.c
monitor.o:	\$(H) monitor.c
newhandler.o:	\$(H) newhandler.c
struct.o:	\$(H) struct.c
unix.o:		\$(H) unix.c
$gdbm_rule

install: \$(O)
	-@if [ ! -d $lib_dir ]; then \\
	    echo mkdir $lib_dir; \\
	    mkdir $lib_dir; \\
	fi
	@for i in \$(O) ;\\
	do \\
	    echo cp \$\$i $lib_dir; \\
	    cp \$\$i $lib_dir; \\
	done

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

clean:
	rm -f *.o core

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