# $Id: Smakefile,v 4.4 1994/05/18 16:00:14 ppessi Exp $
#
# Smakefile for usergroup.library
#
# Copyright  1993 AmiTCP/IP Group, <amitcp-group@hut.fi>
#                  Helsinki University of Technology, Finland.
#
# Created      : Sun Nov 28 17:25:35 1993 ppessi
# Last modified: Wed May 18 18:56:54 1994 ppessi
#
# $Log: Smakefile,v $
# Revision 4.4  1994/05/18  16:00:14  ppessi
# Added FD into installed include files
#
# Revision 4.3  1994/05/18  00:18:59  ppessi
# Updated version number
#
# Revision 4.2  1994/05/17  07:38:06  ppessi
# Added a warning for libinit.c patching
#
# Revision 4.1  1994/05/16  14:09:07  ppessi
# Added a patch rule for libinit.c
#
# Revision 3.3  1994/02/25  21:45:19  ppessi
# Changed the installing order
#
# Revision 3.2  1994/02/25  15:02:14  ppessi
# Added rules for include directories
#
# Revision 3.1  1994/02/24  16:49:34  ppessi
# Release 3.
#
# Revision 2.3  1994/02/17  12:09:16  ppessi
# Release 2
#
# Revision 2.2  1994/02/17  02:24:08  ppessi
# Saving before downgrading library
#
# Revision 2.1  1994/01/23  03:25:56  ppessi
# Added line debugging and document generation
#
# Revision 1.4  1994/01/21  12:36:33  ppessi
# Updated include handling. Added documentation extraction.
#
# Revision 1.3  1994/01/20  16:15:09  ppessi
# Changed default flags to optimize
#
# Revision 1.2  1994/01/20  08:30:31  ppessi
# Don't use SAS supplied libintr.o, use mine.
#
# Revision 1.1  94/01/19  10:05:16  ppessi
# Initial revision
#

NAME=  usergroup
VERS= 4
REV=  1

SRCS=	$(NAME).c credential.c resource.c \
	getutent.c getpwent.c getgrent.c \
	initgroups.c loginname.c time.c \
	getpass.c crypt.c console.c \
	random.c assert.c libinit.c 
OBJS=   $(NAME).o credential.o resource.o \
	getutent.o getpwent.o getgrent.o \
	initgroups.o loginname.o time.o \
	getpass.o crypt.o console.o \
	random.o assert.o
STARTUP= libinitr.o

RESOURCE= #credential.resource

RSRCS=  credres.c 
ROBJS=  credres.o 

LIBS=
DEBUGLIBS=

# These include and FD files are created with gawk
INCS_CLIB=   include/clib/$(NAME)_protos.h 
INCS_PRAGMA= include/pragmas/$(NAME)_pragmas.h
FD=          fd/$(NAME)_lib.fd
INCS_GEN=    $(INCS_CLIB) $(INCS_PRAGMA) $(FD)

DOCS=   usergroup.doc

CC=      sc
LD=      slink
MAKE=    smake
TAGS=    etags
RM=      delete quiet
MKDIR=   makedir
INSTALL= copy nopro dates all
BUMPREV= BumpRev
RCSREV=  rcsrev
CAT=     type 
AWK=     gawk
AUTODOC= autodoc  -C -I -c -t8
PATCH=   sc:c/spatch

DEST=    AmiTCP:

DESTINCLUDE= $(DEST)netinclude $(DEST)netinclude/clib \
	$(DEST)netinclude/pragmas $(DEST)netinclude/fd

OPTFLAGS= Optimize Stripdebug Debug=Line
CFLAGS = $(OPTFLAGS)
LDFLAGS= stripdebug noicons

# "DEF=RCS_ID_C=static char *rcsid"
DEFS=    DEF=RCS_ID_C=// DEF=AMIGA=1  DEF=FAR
IDIRS=   IDIR=include IDIR=netinclude: 
SCOPTIONS= stringmerge structureequivalence \
	 nostackcheck nomultipleincludes \
	 noerrorsource noversion noerrorhighlight \
	 smallcode smalldata \
	 map maphunk mapsymbols maplib mapxreference \
	 linkeroptions=plain noicons batch \
	 optinl opttime optcomp=5 optdep=5 optrdep=5 \
	 $(IDIRS) $(DEFS) \
	 LibCode

all: $(NAME).library $(RESOURCE)

$(NAME).library: SCOPTIONS $(STARTUP) $(OBJS) $(FD)
	$(LD) with <<
	TO $(NAME).library $(LDFLAGS)
	LIBPREFIX _R_ LIBFD $(FD)
	FROM lib:libent.o $(STARTUP) $(OBJS) LIB lib:sc.lib 
	noicons SD batch MAP $(NAME).map FHLSX
	Libversion $(VERS) Librevision $(REV)
<
#	$(CC) LINK TO $@ OBJ $(OBJS) BATCH $(LIBS) $(CFLAGS)

debug:
	$(MAKE) "CFLAGS=$(DEBUGFLAGS)" "LIBS=$(DEBUGLIBS)" all

$(NAME).doc: $(SRCS)
	$(AUTODOC) $(SRCS) >$@

include/clib/$(NAME)_protos.h: libfunc.h include/clib
	$(AWK) -f make_fd.awk -v "what=protos" $< > $@

include/pragmas/$(NAME)_pragmas.h: libfunc.h include/pragmas
	$(AWK) -f make_fd.awk -v "what=pragmas" $< > $@

$(FD): libfunc.h fd
	$(AWK) -f make_fd.awk -v "what=fd" $< > $@
#
# Create libinit.c 
#
# If you can not apply this patch, probably because your SAS C is newer or
# older than our compiler, you can use the sc:source/libinit.c as such.
# There are a few bugs but nothing fatal.
# 
libinit.c: sc:source/libinit.c libinit.pch
	$(PATCH) -o$@ -plibinit.pch sc:source/libinit.c

.c.o:
	-@$(RM) $*.o  > nil:
	$(CC) $(CFLAGS) $*.c

credres.o: credres.c
	$(CC) $(CFLAGS) nolibcode DATA=faronly credres.c 

credential.resource: credres.o
	$(CC) $(CFLAGS) link credres.o to $@ noicons nostartup

$(STARTUP): libinit.c
	$(CC) optimize debug=line libinit.c OBJNAME=$@

$(NAME).library_rev.h: $(NAME).c
	-$(RCSREV) $(NAME).library $(NAME).c

credential_rev.h: credential.h
	-$(RCSREV) credential credential.h
resource.o: credential_rev.h

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

mininstall: all $(DEST)libs
	$(INSTALL) $(NAME).library $(RESOURCE) $(DEST)libs

install: mininstall $(DOCS) $(DEST)doc $(DESTINCLUDE) $(INCS_GEN)
	$(CAT) $(DOCS) > $(DEST)doc/$(NAME).doc
	$(INSTALL) $(INCS_CLIB) $(DEST)netinclude/clib
	$(INSTALL) $(INCS_PRAGMA) $(DEST)netinclude/pragmas
	$(INSTALL) $(FD) $(DEST)netinclude/fd

$(DEST)libs:
	-$(MKDIR) $@
$(DEST)doc:
	-$(MKDIR) $@	
$(DEST)netinclude:
	-$(MKDIR) $@	
$(DEST)netinclude/clib:
	-$(MKDIR) $@	
$(DEST)netinclude/pragmas:
	-$(MKDIR) $@	
$(DEST)netinclude/fd:
	-$(MKDIR) $@	
fd: 
	-$(MKDIR) $@	
include: 
	-$(MKDIR) $@	
include/clib: include
	-$(MKDIR) $@	
include/pragmas: include
	-$(MKDIR) $@	

TAGS:	$(SRCS)
	$(TAGS) $(SRCS)

clean:
	-$(RM) \#?(_rev.?|.o|.map|.lnk|.info) SCOPTIONS

cleaner: clean
	-$(RM) $(NAME).library $(RESOURCE)

# DO NOT DELETE THIS LINE -- make depend depends on it.
$(NAME).o: $(NAME).c libfunc.h base.h credential.h $(GINCS)
credres.o : credres.c base.h credential_rev.h credential.h $(GINCS)
credential.o : credential.c libfunc.h base.h credential.h $(GINCS)
getpwent.o: getpwent.c libfunc.h base.h $(GINCS)
getgrent.o: getgrent.c libfunc.h base.h $(GINCS)
crypt.o: crypt.c libfunc.h base.h $(GINCS)
loginname.o: loginname.c libfunc.h base.h credential.h $(GINCS)
getutent.o: getutent.c libfunc.h base.h credential.h $(GINCS)
getpass.o : getpass.c libfunc.h base.h $(GINCS)
console.o: console.c libfunc.h base.h $(GINCS)
assert.o: assert.c  base.h $(GINCS)
