# Makefile for SAS/C 6.3
# Arn-(C)opyright by Roland Bless of Blessed Software Products
# All rights reserved. (C) 1990-93, R. Bless
# $@ target filename
# $? list of dependent files that are not current (full path)
# $* name of 1st dependent file, full path, w/o extension
# $< name of dependent file, no full path, incl. extension
# $>  "         "        " , "   "     " , excl.    "
######################################################################
#NOTES:
# - Type "smake world" if you compile the first time,
#   then type "smake" to build Arn
# - You need to type "smake protos" only if you defined new functions.
#   If you did, don't forget to include the prototype between "proto$start"
#   and "proto$end"

CC = sc
LINKER = slink
MAKE = smake

#dirs
SRCDIR =
OBJDIR= obj/
PROTODIR= proto/
REGEXPDIR= regexp/
DOCDIR= doc/


#Startup-Code
STARTUP= LIB:c.o
#Standard-Lib
STDLIB= LIB:sc.lib
#Standard-Libraries to link with
LINKLIBS= lib $(STDLIB) regexp.lib
#DEBUG=
DEBUG= debug=full
#Options for Linker
LOPTS= stripdebug quiet
#LOPTS= quiet


#Standard ANSI-Check
COPTS= noversion ansi $(DEBUG)
#COPTS= noversion ansi
#Standard ANSI-Check
COPTS1= noversion ansi $(DEBUG)
#
COPTS2= noversion ansi $(DEBUG)

#global symbol table goes here
GLOBAL_SYMTAB = $(OBJDIR)globalvars.gst
SYM1 = $(GLOBAL_SYMTAB)
#command for including global symbol table
GST= gst=$(SYM1)
MAKESYMBOLTABLE= makegst

#main targets
ARN_EXE = Arn
ARNMASTER_EXE = ArnMaster
ARNDAEMON_EXE = ArnDaemon
REGEXPLIB = regexp.lib
ARN_DOCS = $(DOCDIR)Arn.dvi $(DOCDIR)Arn.guide $(DOCDIR)Arn.doc

#these need enums.h,globalvars,includes
ARN_OBJS1 = $(OBJDIR)Arn.o $(OBJDIR)followup.o $(OBJDIR)functions.o\
            $(OBJDIR)getconfig.o $(OBJDIR)grouplist.o $(OBJDIR)time.o\
            $(OBJDIR)cmdline.o $(OBJDIR)pager.o $(OBJDIR)readgroup.o\
            $(OBJDIR)choosegroups.o $(OBJDIR)kill.o $(OBJDIR)strprocs.o\
            $(OBJDIR)mimesupport.o $(OBJDIR)ArnIO.o $(OBJDIR)reply.o

#no enums.h, but gobalvars,includes
ARN_OBJS2 = $(OBJDIR)arnhelp.o $(OBJDIR)mimedecode.o

#only includes.h
ARN_OBJS3= $(OBJDIR)globalvars.o1 $(OBJDIR)dirfunc.o1 $(OBJDIR)termcap.o1 $(OBJDIR)tgoto.o1

#these need enums.h,globalvars,includes
ARN_SRC1 = Arn.c followup.c functions.c getconfig.c grouplist.c\
           time.c cmdline.c pager.c readgroup.c choosegroups.c kill.c\
           strprocs.c mimesupport.c ArnIO.c reply.c

#no enums.h, but gobalvars,includes
ARN_SRC2 = arnhelp.c mimedecode.c

#only includes.symtab
ARN_SRC3 = globalvars.c dirfunc.c termcap.c tgoto.c


ARN_PROTOS = $(PROTODIR)Arn_proto.h\
             $(PROTODIR)followup_proto.h\
             $(PROTODIR)functions_proto.h\
             $(PROTODIR)getconfig_proto.h\
             $(PROTODIR)grouplist_proto.h\
             $(PROTODIR)time_proto.h\
             $(PROTODIR)cmdline_proto.h\
             $(PROTODIR)pager_proto.h\
             $(PROTODIR)readgroup_proto.h\
             $(PROTODIR)choosegroups_proto.h\
             $(PROTODIR)kill_proto.h\
             $(PROTODIR)strprocs_proto.h\
             $(PROTODIR)mimesupport_proto.h\
             $(PROTODIR)ArnIO_proto.h\
             $(PROTODIR)reply_proto.h\
             $(PROTODIR)arnhelp_proto.h\
             $(PROTODIR)mimedecode_proto.h\
             $(PROTODIR)dirfunc_proto.h\
             $(PROTODIR)termcap_proto.h\
             $(PROTODIR)tgoto_proto.h


###################################################################################
# targets and actions
#.DEFAULT:
#          ; this target needs remaking $@

#transformation rule for .c into _proto.h
.c.h:
      execute makecompactproto $>.c $@
#transformation for all normal sources
.c.o:
      $(CC) $(COPTS) $(GST) objname=$@ $*.c
#transformation for sources that need only includes.h
.c.o1:
      $(CC) $(COPTS1) $(GST) objname=$@ $*.c

#######
# default target
all: $(ARN_EXE) $(ARNMASTER_EXE) $(ARNDAEMON_EXE)

#docs: $(ARN_DOCS)

globalvars.h: includes.h
              setdate globalvars.h

#global symbol table
$(GLOBAL_SYMTAB): globalvars.h includes.h
                  $(CC) $(COPTS1) $(MAKESYMBOLTABLE)=$(GLOBAL_SYMTAB) globalvars.h

#prototype files dependencies
$(PROTODIR)Arn_proto.h: Arn.c
$(PROTODIR)followup_proto.h: followup.c
$(PROTODIR)functions_proto.h: functions.c
$(PROTODIR)getconfig_proto.h: getconfig.c
$(PROTODIR)grouplist_proto.h: grouplist.c
$(PROTODIR)time_proto.h:      time.c
$(PROTODIR)cmdline_proto.h:   cmdline.c
$(PROTODIR)pager_proto.h:     pager.c
$(PROTODIR)readgroup_proto.h: readgroup.c
$(PROTODIR)choosegroups_proto.h: choosegroups.c
$(PROTODIR)kill_proto.h:         kill.c
$(PROTODIR)strprocs_proto.h:     strprocs.c
$(PROTODIR)mimesupport_proto.h:  mimesupport.c
$(PROTODIR)ArnIO_proto.h:        ArnIO.c
$(PROTODIR)reply_proto.h:        reply.c
$(PROTODIR)arnhelp_proto.h:      arnhelp.c
$(PROTODIR)mimedecode_proto.h:   mimedecode.c
$(PROTODIR)dirfunc_proto.h:      dirfunc.c
$(PROTODIR)termcap_proto.h:      termcap.c
$(PROTODIR)tgoto_proto.h:        tgoto.c

#obj 1
$(OBJDIR)Arn.o:         Arn.c
$(OBJDIR)followup.o:    followup.c
$(OBJDIR)functions.o:   functions.c
$(OBJDIR)getconfig.o:   getconfig.c
$(OBJDIR)grouplist.o:   grouplist.c
$(OBJDIR)time.o:        time.c
$(OBJDIR)cmdline.o:     cmdline.c
$(OBJDIR)pager.o:       pager.c
$(OBJDIR)readgroup.o:   readgroup.c
$(OBJDIR)choosegroups.o: choosegroups.c
$(OBJDIR)kill.o:         kill.c
$(OBJDIR)strprocs.o:     strprocs.c
$(OBJDIR)mimesupport.o:  mimesupport.c
$(OBJDIR)ArnIO.o: ArnIO.c
$(OBJDIR)reply.o: reply.c
#obj2
$(OBJDIR)arnhelp.o: arnhelp.c
$(OBJDIR)mimedecode.o: mimedecode.c

#obj3
$(OBJDIR)globalvars.o1: globalvars.c
$(OBJDIR)dirfunc.o1: dirfunc.c
$(OBJDIR)termcap.o1: termcap.c
$(OBJDIR)tgoto.o1:   tgoto.c

$(ARN_OBJS1) : $(SYM1) enums.h

$(ARN_OBJS2) : $(SYM1)

$(ARN_OBJS3) : $(SYM1)

$(ARN_EXE): $(ARN_OBJS1) $(ARN_OBJS2) $(ARN_OBJS3) version.c $(REGEXPLIB)
            $(CC) $(COPTS) objname=$(OBJDIR)version.o version.c
            $(LINKER) <WITH <
               $(STARTUP)
               $(ARN_OBJS1) $(ARN_OBJS2) $(ARN_OBJS3)
               $(OBJDIR)version.o $(LINKLIBS) TO $(ARN_EXE) $(LOPTS)
               <
            @ echo "$(ARN_EXE) is now ready!"

$(ARNMASTER_EXE): $(OBJDIR)arnmaster.o $(OBJDIR)dirfunc.o1
           $(LINKER) $(STARTUP) $(OBJDIR)arnmaster.o $(OBJDIR)arnmaster_ver.o $(OBJDIR)dirfunc.o1\
 LIB $(STDLIB) TO $(ARNMASTER_EXE) $(LOPTS)

$(OBJDIR)arnmaster.o: arnmaster.c arnmaster_ver.c
             $(CC) $(COPTS) objname=$(OBJDIR)arnmaster.o $*
             $(CC) $(COPTS) objname=$(OBJDIR)arnmaster_ver.o arnmaster_ver.c

#additional options for DAEMON
DAEMONCOPTS = $(COPTS) nostackcheck opt optsize
DAEMONLOPTS =

$(ARNDAEMON_EXE): $(OBJDIR)arndaemon.o
           $(LINKER) $(STARTUP) $(OBJDIR)arndaemon.o $(OBJDIR)arndaemon_ver.o\
 LIB $(STDLIB) TO $(ARNDAEMON_EXE) $(DAEMONLOPTS)

$(OBJDIR)arndaemon.o: arndaemon.c
             $(CC) $(COPTS) $(DAEMONCOPTS) objname=$@ $>.c
             $(CC) $(COPTS) $(DAEMONCOPTS) objname=$(OBJDIR)arndaemon_ver.o arndaemon_ver.c

#regexp
$(REGEXPLIB): $(REGEXPDIR)regexp.c $(REGEXPDIR)regsub.c $(REGEXPDIR)regerror.c
              $(CC) $(COPTS) OBJLIB=$@ $?

clean:
          - delete $(OBJDIR)\#? $(PROTODIR)\#?.h
          - delete \#?.gst snapshot.TB
          - delete \#?.(o|map|lnk|oml)
          - delete $(REGEXPLIB)

makedis: all docs
         lha -x -idvlp/disfiles a T:Arn
         lha -x -idvlp/srcfiles a T:ArnSrc

binarc: all docs
        lha -x -idvlp/disfiles a T:Arn

betadis:
         lha -idvlp/betafiles a T:Arn100beta

archive:
         lha -x -idvlp/files u T:Arn100

docs: $(DOCDIR)Arn.texi
      execute < <
      echo "Making documentation for Arn:" $(ARN_DOCS)
      cd $(DOCDIR)
      virtex Arn.texi
      SPAT texindex Arn.??
      virtex Arn.texi
      makeinfo --amiga Arn.texi
      makeinfo --amiga --no-headers -oArn.doc Arn.texi
      echo "Docs ready!"
      <

protos: $(ARN_PROTOS)

makeprotos: makeprotos.c
            $(CC) LINK makeprotos
            delete makeprotos.o

mkdirs:
            - makedir obj
            - makedir proto

world: mkdirs makeprotos protos
       @ echo "Now type $(MAKE)"

upload:
        uucp UUPUB:Arn.lha pilhuhn!~nuucp/incoming

#end of makefile for Arn (SAS/C)
