# $Id: Smakefile,v 1.16 1993/11/21 13:25:44 jraja Exp $
# 
# Smakefile for AmiTCP/IP network support library 
#
# Copyright  1993 AmiTCP/IP Group, <amitcp-group@hut.fi>
#		   Helsinki University of Technology, Finland.
#		   All rights reserved. 
#
# Created      : Sat Mar 20 02:44:57 1993 ppessi
# Last modified: Sun Nov 21 15:25:26 1993 jraja
#
# $Log: Smakefile,v $
# Revision 1.16  1993/11/21  13:25:44  jraja
# Commented autodoc installation, since the docs are incomplete.
#
# Revision 1.15  1993/10/20  05:42:26  ppessi
# Added autodoc extraction.
#
# Revision 1.14  1993/10/18  06:13:15  jraja
# Added timerinit.c and gettimeofday.c.
#
# Revision 1.13  1993/10/15  01:14:47  ppessi
# Changed compilation mechanism, added debugging libraries.
#
# Revision 1.12  1993/10/14  00:05:35  ppessi
# SCOPTIONS is now created automatically from Smakefile
# Added user database handling functions.
# Added a new `install' target.
#
# Revision 1.11  1993/07/16  18:58:20  too
# Fixed lineread.c to lineread.o in object file names
#
# Revision 1.10  1993/06/16  16:43:34  too
# Added lineread.c to libraries
#
# Revision 1.9  1993/06/03  23:27:19  ppessi
# Cosmetic changes for version 1.0
#
# Revision 1.8  1993/05/17  00:05:42  ppessi
# Added printfault.c module (defines Perror()).
#
# Revision 1.7  1993/05/15  00:51:36  ppessi
# Added sana2.lib
#
# Revision 1.6  93/05/04  13:24:11  13:24:11  jraja (Jarno Tapio Rajahalme)
# Added getthostname().
# 
# Revision 1.5  93/04/20  18:45:44  18:45:44  puhuri (Markus Peuhkuri)
# Removed sana2perror, sana2errlist and sana2printfault modules.
# 
# Revision 1.4  93/04/19  01:38:22  01:38:22  ppessi (Pekka Pessi)
# Supports multiple bases
# 
# Revision 1.2  93/04/13  21:48:15  21:48:15  jraja (Jarno Tapio Rajahalme)
# Disabled perror & strerror.
# 
# Revision 1.1  93/03/22  03:23:54  03:23:54  ppessi (Pekka Pessi)
# Initial revision
#

DEST = AmiTCP:

MAKE = smake

RM= delete
RM_RECURSIVE= delete all
MKDIR= makedir
CP= copy dates

CC= sc
LD= slink
AUTODOC= autodoc

OFLAGS= Optimize NoDebug
GFLAGS= NoOptimize Debug=fullflush

CFLAGS=    DATA=NEAR
CFLAGS_NB= DATA=FAR
CFLAGS_S=  DATA=NEAR SHORTINTS 

DEFS= "DEF=RCS_ID_C=//" DEF=AMITCP=1 DEF=NETLIB=1
IDIRS= IDIR=netinclude: 
SCOPTIONS= parm=BOTH Nostackcheck \
	Stringmerge Noerrorsource Nomultipleincludes Structureequivalence \
	Smallcode Smalldata Addsymbols noicons batch \
	STARTUP=catch LINKEROPTIONS=plain \
	maphunk Mapsymbols maplib mapxreference \
	noversion noerrorhighlight IGNORE=224 IGNORE=92 \
	optinl optinlocal opttime optcomp=5 optdep=5 optrdep=5 \
	 $(IDIRS) $(DEFS)

NETLIBSRC= errlst.c autoinit.c dummy.c lineread.c \
	getopt.c gethostname.c printfault.c \
	getpasswdent.c getgroupent.c userparsing.c \
	timerinit.c gettimeofday.c

SANA2LIBSRC= sana2perror.c sana2errlist.c sana2printfault.c

DOCS= netlib.doc sana2lib.doc

LIBS= net.lib netnb.lib nets.lib \
      sana2.lib sana2nb.lib sana2s.lib \
      autoinitd.o serveraccept.o

DEBUGLIBS= gnet.lib gnetnb.lib gnets.lib \
      gsana2.lib gsana2nb.lib gsana2s.lib \
      autoinitd.go serveraccept.go

NETOBJ= errlst.o autoinit.o dummy.o lineread.o \
	getopt.o gethostname.o printfault.o \
	getpasswdent.o getgroupent.o userparsing.o \
	timerinit.o gettimeofday.o

NETNBOBJ= errlst.nbo autoinit.nbo dummy.nbo lineread.nbo \
	getopt.nbo gethostname.nbo printfault.nbo \
	getpasswdent.nbo getgroupent.nbo userparsing.nbo \
	timerinit.nbo gettimeofday.nbo

NETSOBJ= errlst.so autoinit.so dummy.so lineread.so \
	getopt.so gethostname.so printfault.so \
	getpasswdent.so getgroupent.so userparsing.so \
	timerinit.so gettimeofday.so

SANA2OBJ=   sana2perror.o   sana2errlist.o   sana2printfault.o
SANA2NBOBJ= sana2perror.nbo sana2errlist.nbo sana2printfault.nbo
SANA2SOBJ=  sana2perror.so  sana2errlist.so  sana2printfault.so

GNETOBJ= errlst.go autoinit.go dummy.go lineread.go \
	getopt.go gethostname.go printfault.go  \
	getpasswdent.go getgroupent.go userparsing.go \
	timerinit.go gettimeofday.go

GNETNBOBJ= errlst.gnbo autoinit.gnbo dummy.gnbo lineread.gnbo \
	getopt.gnbo gethostname.gnbo printfault.gnbo \
	getpasswdent.gnbo getgroupent.gnbo userparsing.gnbo \
	timerinit.gnbo gettimeofday.gnbo

GNETSOBJ= errlst.gso autoinit.gso dummy.gso lineread.gso \
	getopt.gso gethostname.gso printfault.gso \
	getpasswdent.gso getgroupent.gso userparsing.gso \
	timerinit.gso gettimeofday.gso

GSANA2OBJ=   sana2perror.go   sana2errlist.go   sana2printfault.go
GSANA2NBOBJ= sana2perror.gnbo sana2errlist.gnbo sana2printfault.gnbo
GSANA2SOBJ=  sana2perror.gso  sana2errlist.gso  sana2printfault.gso

.SUFFIXES: .c .o .go .nbo .gnbo .so .gso
#
# Generic rules
#
.c.o:
	$(CC) $(CFLAGS) $(OFLAGS) $*.c
.c.nbo:
	$(CC) $(CFLAGS_NB) $(OFLAGS) $*.c OBJNAME=$*.nbo
.c.so:
	$(CC) $(CFLAGS_S) $(OFLAGS) $*.c  OBJNAME=$*.so
.c.go:
	$(CC) $(CFLAGS) $(GFLAGS) $*.c OBJNAME=$*.go
.c.gnbo:
	$(CC) $(CFLAGS_NB) $(GFLAGS) $*.c OBJNAME=$*.gnbo
.c.gso:
	$(CC) $(CFLAGS_S) $(GFLAGS) $*.c  OBJNAME=$*.gso

all: SCOPTIONS $(LIBS) $(DEBUGLIBS) $(DOCS)

debug: SCOPTIONS $(DEBUGLIBS)

install:  all $(DEST)netlib $(DEST)doc
	$(CP) $(LIBS) $(DEBUGLIBS) $(DEST)netlib
#	$(CP) $(DOCS) $(DEST)doc # these are still incomplete...

$(DEST)netlib:
	-$(MKDIR) $@
$(DEST)doc:
	-$(MKDIR) $@
	
netlib.doc:
	$(AUTODOC) -C -I -c $(NETLIBSRC) >$@
sana2lib.doc:
	$(AUTODOC) -C -I -c $(SANA2LIBSRC) >$@

SCOPTIONS: Smakefile
	copy to $@ <from < 
$(SCOPTIONS) 
<

#
# Network libraries
#
net.lib: $(NETOBJ)
	-$(RM) $@
	oml $@ r $(NETOBJ)
netnb.lib: $(NETNBOBJ)
	-$(RM) $@
	oml $@ r $(NETNBOBJ)
nets.lib: $(NETSOBJ)
	-$(RM) $@
	oml $@ r $(NETSOBJ)
#
# Sana2.lib, convenience functions for Sana2 utilities
#
sana2.lib: $(SANA2OBJ)
	-$(RM) $@
	oml $@ r $(SANA2OBJ)
sana2nb.lib: $(SANA2NBOBJ)
	-$(RM) $@
	oml $@ r $(SANA2NBOBJ)
sana2s.lib: $(SANA2SOBJ)
	-$(RM) $@
	oml $@ r $(SANA2SOBJ)
#
# Debugging libraries
#
gnet.lib: $(GNETOBJ)
	-$(RM) $@
	oml $@ r $(GNETOBJ)
gnetnb.lib: $(GNETNBOBJ)
	-$(RM) $@
	oml $@ r $(GNETNBOBJ)
gnets.lib: $(GNETSOBJ)
	-$(RM) $@
	oml $@ r $(GNETSOBJ)
gsana2.lib: $(GSANA2OBJ)
	-$(RM) $@
	oml $@ r $(GSANA2OBJ)
gsana2nb.lib: $(GSANA2NBOBJ)
	-$(RM) $@
	oml $@ r $(GSANA2NBOBJ)
gsana2s.lib: $(GSANA2SOBJ)
	-$(RM) $@
	oml $@ r $(GSANA2SOBJ)

autoinit1.o: autoinit.c
	$(CC) DATA=NEAR DEF SOCKETNAME="bsdsocket.library.1" \
	autoinit.c OBJNAME=$@

autoinit2.o: autoinit.c
	$(CC) DATA=NEAR DEF SOCKETNAME="bsdsocket.library.2" \
	autoinit.c OBJNAME=$@

clean:
	-$(RM) \#?.(lib|o|nbo|so|go|gnbo|gso) SCOPTIONS

# DO NOT DELETE THIS LINE -- make depend depends on it.
