1. Abstract
-----------

This package is an automatic makefile maker
which can be used for simple programming projects.

Unlike GNU Autoconf/Automake it's very simple to
use. It does however not do extensive checks on
operating systems.

But, although it's very small, it's powerfull.
It fits most purposes of c/c++, lex/yacc programming.

I made this package when I was a very busy system/CAD
administrator and was tired of making new makefiles 
for every small programming project.

1.1 License
-----------

This product is distributed under GPL license.
You can freely distribute and alter the source.
If you are using this package please mail this
to me. I'd like to know if it's used. If you
want to contribute to this package, please send
requested changes or alterations done to the maintainer. 
Include version number of the package altered.

1.2 Maintainer
--------------

This package is maintained bij Hans Dijkema
Send contributions and comments to hnmdijkema@softhome.net.

1.3 USE
-------

Use it as follows:

The makefile structure consists of three parts:

	Makefile.def
	Makefile
	Makefile.lsm

In Makefile.lsm you can describe the package you're
making. This file has some generic entries that you
should not touch. These entries are automatically
filled in when a 'make srcdist' is done.

In Makefile.def the programs, sources, libraries etc.
are specifiec. Makefile is then generated from this 
Makefile.def by using the command 

	make makefile

This package assumes the following directory structure!

	.../package/version1
	           /version2
		   ...
	           /version3

When a srcdist is made, the tar file will be:

	$TAR-versionx.tar.gz

And the contents will be extracted in 

	$TAR/versionx


Makefile.def has the following structure:

   #######################################################

   CPP=Y

   SHL=sl

   SRC1=sample.cxx sample.hxx
   SRC2=sample1.c sample1.yacc sample1.lex
   SRC3=samplelib.cxx
   SRC4=sample1lib.c
   TARGETS=sample:SRC1 sample1:SRC2 libsample.$(SHL):SRC3 libsample1.a:SRC4

   INSTALLDIR=$(HOME)/bin
   INSTALLLIB=$(HOME)/lib
   INSTALLEXTRA=runsamples
   INSTALLEXE=install.sh

   TAR=Sample

   SHL_LIB=-lsomeshared
   LIB=-lm
   CFLAG=-O
   #CFLAG=-O3 -D_THREADS_ -D_REENTRANT
   #CFLAG=-g
   INCL=-I/opt/include
   NETFLAG=
   LEXFLAG=
   YACCFLAG=

   #######################################################

Basically you specify targets to be made with sources you specify.
From this variables the makefile is made by generating the dependencies and
calling the right tools to proces the sources.

The tools are contained in variables that are given by files in 
the Makefile.os directory.

2. Explanation of the Makefile.def variables
--------------------------------------------

CPP=Y		- Variable that says to use C++ as 
		  default for processing .y/.yacc and
		  .l/.lex files. If however 1 of the
		  sources for the target is .c, C will
		  be used by default. If CPP=N, C will
		  always be used.

SRC1		- Variable that determines sources for a target 
		  (can be any name)
TARGETS		- The targets + sources.
INSTALLDIR	- Where to install binaries.
INSTALLLIB	- Where to install libraries.
INSTALLEXTRA	- Extra scripts (binaries) to install in INSTALLDIR
		  (Can also be libraries or directories).
INSTALLEXE	- a script or executable to execute when
		  installing binaries or libraries. The
		  script is executed after the binaries/libraries
		  have been copied to the right location.
		  The script has as arguments all binaries/libraries
		  and the environment variable INSTALLDIR is set
		  (to $(INSTALLDIR) or $(INSTALLLIB). This script
		  is executed in the source directory.
TAR		- Name of tar file to be made from sources.
SHL_LIB		- Name of shared libraries to be linked.
LIB		- Name of static libraries to be linked.
CFLAG		- CFLAGS to add to C/C++.
INCL		- Include extra's 
NETFLAG		- Extra flags to GenNet (package to generate neural
		  networks).
LEXFLAG		- Extra flags for lex.
YACCFLAG	- Extra flags for yacc.



3. OS dependend generation variables
------------------------------------

3.1 Sample OS file:
-------------------

In OS files the following variables are specified:

OS.lex/OS.flex

   LEXFLAGS=$(LEXFLAG)
   LEX=lex $(LEXFLAGS)
   LEXLIB=-ll

OS/OS.gcc

   OS=HPUX
   OSTEXT="Using OS=$(OS)"
   NETFLAGS=$(NETFLAG)
   GENNET=GenNet $(NETFLAGS)
   YACCFLAGS=$(YACCFLAG) -v -d
   YACC=yacc $(YACCFLAGS)
   CFLAGS=-Aa -D$(OS) +z $(CFLAG)
   SHL_LIBS=$(LEXLIB) $(SHL_LIB)
   LIBS=$(LEXLIB) $(LIB)
   INCLUDE=-I. $(INCL)
   CC=cc
   CXX=c++
   AR=ar -r
   SL=ld -b -o

The OS files are automatically put in the makefile when doing
a 'make makefile'.

NOTE:

   When gcc is in your path, OS.gcc will be used instead of OS.
   The use of gcc can be overridden by using 

	make makefile OPTIONS="--use-cc"

   When flex is in your path, OS.flex will be used instead of OS.lex.
   The use of flex can be overridden by using
	
	make makefile OPTIONS="--use-lex"

   So

	make makefile OPTIONS="--use-cc --use-lex" 

   will build a makefile for the default OS tools.


These variables won't be explained only the extensions with wich
they are used are given:


3.2 Dependencies generation process
-----------------------------------

SX, X=

.h .hxx .hpp	- header files, only dependencies generated.
		  and used for installation of headerfiles.
		  NOTE: header file dependency information
		  is also automatically generated for each
		  C/C++ file.
.lex .l		- generate S.lex.c or S.lex.cxx and make
		  S.lex.o from these.
.yac .yacc .y	- generate S.yacc.c or S.yacc.cxx and make
		  S.yacc.o and S.yacc.h from these.
		  (when generating yacc/lex programms, first
		   use S.yacc and then S.lex (example:
			SRC=sample.y sample.l
			TARGETS=sample:SRC
                  ))
		  Sometimes also S.yacc.out is generated.
.net		- GenNet S.net
.c		- Generate $(CC) -c $(INCLUDE) $(CFLAGS) S.c
.cxx .cpp .cc	- Generate $(CXX) -c $(INCLUDE) $(CFLAGS) S.cxx (S.cpp, S.cc)

After the source dependencies are generated, the object
files and libraries are assembled and the target
commands are generated:


3.3 Targets generation process
------------------------------

if no extension to the target, Linking is done as follows:

  For .net files	-> GenNet $OBJ $TARGET
  otherwise		-> 
	if one of the sources .cxx/.cpp/.cc:
		$(CXX) -o $TARGET $(LDFLAGS) $OBJ $(LIBS)
	otherwise:
		$(CC) -o $TARGET $(LDFLAGS) $OBJ $(LIBS)

otherwise
  if .a files
	$(AR) $TARGET $OBJ
  if .sl or .so
	$(SL) $TARGET $OBJ $(SHL_LIBS)
  otherwise
	Generate an error.



