#
# This script creates a makefile for A++ to be executed
# with SMake and the SAS/C++ Development System.
#

# open the output file
echo "Creating SAS 'smakefile'.."
rm smakefile
open smakefile w 1

echo "#"^j\
"# SAS Makefile for the A++ Library"^j\
"# Copyright (C) by Armin Vogt"^j\
"#"^j\
"# This makefile has been created automatically with 'makesas'"^j\
"# "$Id: makesas,v 1.3 1994/07/15 21:49:50 Armin_Vogt Exp Armin_Vogt $^j\
"#"^j^j\
"LIBRARYFILE     =       aplusplus.lib"^j\
"LIBSOURCE       =       apphome:libsource/"^j\
"APPHEADERS      =       appinclude:APlusPlus/"^j\
"APPINCLUDE      =       appinclude:"^j\
"INCLUDERCS      =       apphome:RCS/include/APlusPlus/"^j\
"LIBRCS          =       apphome:RCS/libsource/"^j\
""^j\
""^j\
"CI       =     @ ci -l"^j\
"CIOPTS   =     -l"^j\
"TOUCH    =     @ touch"^j\
""^j >.1


alias ALL        "*p%c exec set p $p; foreach s ( $p ) $c"

echo "Making object lists.."
#
# create object list: all files present in the libsource directory
# are included.
#
echo "OBJS =  \\" >.1
cd apphome:libsource
unset file
ALL *.cxx "strhead file .cxx $s;echo \" \"$file.o\\\\" >.1
dswap

echo ^j^j"$(LIBRARYFILE): $(OBJS)"^j"   oml $(LIBRARYFILE) R $?"^j^j >.1
echo ".cxx.o:"^j"   sc $*.cxx includedirectory=$(APPINCLUDE) objectname=/APPLibrary/" >.1

#
# create object's source and header dependencies: for each files
# present in the header directories a dependency is created.
# Even if the header does not correspond to a source file,
# that doesnt matter since only source files are included into
# the objects list.
#

echo "Making A++ source RCS dependencies.."

echo ^j^j"#"^j"# A++ source RCS dependencies"^j"#"^j >.1
cd appinclude:APlusPlus
unset file
unset name
ALL */*.h "strhead file .h $s;strtail name / $file;echo "$name.o: "\"$\""(LIBSOURCE)$name.cxx "\"$\""(APPHEADERS)$file.h"^j;unset name" >.1
dswap

# close created output file
close 1
echo "done."
