# This Makefile will make a program file in the current directory
# and will call it t3270.


# Site-dependent information:


# Place where libraries (news, help, mhelp etc.) go

LIBDIR = /usr/local/lib/3270
DLIB = -DLIBDIR=\"$(LIBDIR)/\"

# Place where the map3270 (keyboard mapping) file goes

PROFILE = /usr/local/lib/3270/map3270
DPRO = -DPROFILE=\"$(PROFILE)\"


# The next two are optional: the compiled code includes the necessary
# #ifdef checks on the symbols OPTDIR / LOGFILE
# If you do NOT want either option then comment out the setting of
# DOPT/DLOG and uncomment the dummy setting which follows it.

# The DIRECTORY in which to put files of different user's saved options.
# Note that the program must be able to write into this directory. This
# may require having it as world or group writeable or by making the
# program set user or group ID on execution.

OPTDIR = /usr/local/lib/3270/options
DOPT = -DOPTDIR=\"$(OPTDIR)/\"
#DOPT=

# The FILE in which to write a log file.

LOGFILE = /tmp/3270log
DLOG = -DLOGFILE=\"$(LOGFILE)\"
#DLOG=

# The DIRECTORY in which to put files of screen prints.
# Note that the program must be able to write into this directory. This
# may require having it as world or group writeable or by making the
# program set user or group ID on execution.
# If undefined then the current directory will be used.

PRINTDIR = /tmp
DPRINT = -DPRINTDIR=\"$(PRINTDIR)/\"
#DPRINT=

# Now for the saving and possible printing of screen dumps.
# The compiled code looks at the various symbols: if these symbols are
# not defined then the compiled code makes suitable choices.
# The symbols involved are :-

#   PRINTDIR    The directory in which to put screen dumps. If not defined
#               then use the current directory.
#   PRINTCMD    The command to be used to print the screen dumps.
#   PC_REDIRECT The possibility to redirect the sysout or syserr output
#               so as not to spoil the 3270 screen.


# The COMMAND to be used to print the screen print files.
# The standard print command is lpr and the printer is chosen according
# to the value of the environment variable PRINTER.
# However, some places have procedures which can print to an extended
# set of printers.

PRINTCMD = lpr
DPRINTC = -DPRINTCMD=\"$(PRINTCMD)\"
#DPRINTC=

# The trailer to the above command, designed to stop any output to
# the print process coming onto the 3270 screen.

PC_REDIRECT = ">/dev/null 2>&1"
DPRINTR = -DPC_REDIRECT='$(PC_REDIRECT)'
#DPRINTR=

# The command to be used to send the screen print files as electronic
# mail to the user's specified e-mail address.
# The most common is mail.

SENDCMD = mail
DSENDC = -DSENDCMD=\"$(SENDCMD)\"
#DSENDC=

# The trailer to the above command, designed to stop any output to
# the mail sending process coming onto the 3270 screen.

SM_REDIRECT = ">/dev/null 2>&1"
DSENDR = -DSM_REDIRECT='$(SM_REDIRECT)'
#DSENDR=

# Choice of compiler (e.g. normal: cc , gnu: gcc , DEC C: c89 )
# plus basic options.

# apollo        The ansi version ( -A ansi ) seems to fail because of
#               the socket.h and associated header files, which don't
#               see the defined types for some reason!
#               The default seems to be bsd4.3, which requires a different
#               form of signal() call!

CC = cc

# Ultrix new DEC compiler
#CC = /usr/bin/c89 -O

# gcc
#CC = /usr/local/bin/gcc

# Generic workstation type
# (3b2, alpha, apollo, hpux, rs6000, sgi, solaris, sun, ultrix)

# Choose just one of these!

#SYSTEM_TYPE = 3b2
#SYSTEM_TYPE = alpha
#SYSTEM_TYPE = apollo
#SYSTEM_TYPE = hpux
#SYSTEM_TYPE = rs6000
#SYSTEM_TYPE = sgi
SYSTEM_TYPE = solaris
#SYSTEM_TYPE = sun
#SYSTEM_TYPE = ultrix


# Top level choice : For particular workstation type.

#       This will imply a default option for the Middle and Bottom level
#       choices unless overridden by those choices.
#       It is simply the inclusion of SYSTEM_TYPE as defined above.
#       I don't see why you would need to change it!


# Middle level choice : For different operating systems: (put in SFLAGS)

#       These will imply a default option for the Bottom level choices
#       unless overridden by those choices.


# -DBSD                 - Set if compiling for BSD (default)
# -DBSD43               - Set if compiling for BSD4.3 or beyond
# -DAIX                 - Set if compiling for AIX
# -DSYSV                - Set if compiling for Unix System V
# -DSVR4                - Set if compiling for Unix System V Release 4

# Choose at most one of these, and only if it is not the standard for!
# the specified SYSTEM_TYPE!

#SFLAGS = -DBSD
#SFLAGS = -DBSD43
#SFLAGS = -DAIX
#SFLAGS = -DSYSV
#SFLAGS = -DSVR4


# Bottom level choice : options within a system: (put in OFLAGS)

# Terminal Interface (choose at most one: default is set according to
# operating system / system type as set above)

# -DUSE_NEWTTY          - Set if using the new BDS tty terminal interface (default)
# -DUSE_SYSV_TERMIO     - Set if using the SystemV termio terminal interface
# -DUSE_TERMIOS         - Set if using the POSIX termios terminal interface

# Miscellaneous.
# (I try to follow the X11 standard methods)

# -DNOT_POSIX           - Does not have the unistd.h include file
#                         with the proper prototypes for standard
#                         routines such as ttyname().
#                         (applies to the ultrix systems before 4.?)

# -DNOT_STDC_ENV        - Does not have the stdlib.h include file
#                         (applies to the ultrix systems before 4.?)

# -DANSI_ALL            - Force in some basic standard ANSI sequences
#                         regardless of the terminal type.

# -DANSI_VT             - Force in some basic standard ANSI sequences
#                         for any terminal whose name starts with "vt"
#                         (assuming that it is a DEC VTx00 terminal)

# -DANSI_XTERM          - Force in some basic standard ANSI sequences
#                         for any terminal whose name starts with "xterm"
#                         (assuming that it is an xterm of some kind)

# -DSIGNALRETURNSINT    - The signal() routine is the bsd4.3 style: it
#                         expects to call an integer function routine.

OFLAGS = -DANSI_VT


# Mode of operation/compilation flags: (put in MFLAGS)

# -DTTY         - Set if the program is serving several users on tty connections.
#                 This is especially important if the ttys are LAT devices.
#                 The code will include checking as to whether the tty is
#                 still ready for output (a LAT user might have switched to
#                 another session). There is also a check for idle users, who
#                 will be thrown off after a number of warnings.
#                 This flag also includes Kermit file transfer code.
#                 Clearly, a workstation user does not want this code.

# -DGRAPHICS    - Set this if you are going to connect to an IBM having
#                 special graphics drivers (not gddm) which allow programs
#                 to do graphics I/O on terminals which support Tektronix
#                 style graphics.

# -DIPAD_ONLY   - Set this if the program is only to be called with direct
#                 IP addresses. It does not then use gethostbyname which
#                 saves a LOT of space.

# -DNOSIZER     - Set this to suppress automatic screen sizing, i.e. if
#                 the termcap entry for the number of lines and columns
#                 is guaranteed always to be correct.

# -DUSE_STDIO   - Set this to use stdio, rather than opening new I/O files.
#                 We normally open these new files to avoid any problems
#                 with redirection.

# -DNO_SL_CLEAR - Set only if all ts (host-writeable status line) sequences
#                 refrain from blanking out the status line. This is highly
#                 recommended when using ASCII terminals on LAT lines.

# -DXTERM_SL    - Set only if the xterm to be used can have a host-writeable
#                 status line, to be manipulated as described in the termcap
#                 entry for xterm (the ds/es/fs/hs/ts entries). Beware: the
#                 fact that these are defined in termcap does NOT imply
#                 that the xterm handles them!

# -DDENSE       - Set only if you have the special IBM code that implements
#                 the possibility of a 132-column screen for the alternate
#                 display of an IBM Model 3278-2 (which is normally just a
#                 24*80 screen). This is implemented in CERN and is found
#                 very useful. However, it is possible to find VM application
#                 programs which choose to use the alternate screen, thinking
#                 that it is also 24*80, and which therefore go wrong on
#                 a 24*132 alternate screen.
#                 If in doubt leave this out!

# -DEXTENDED    - Set for use with extended data stream, which allows
#                 for extended highlighting and colours.
#                 The colours can be set by termcap sequences
#                 c0, c1, ... , c7 for the 8 IBM extended colours
#                 r0, r1, ... , r7 for the corresponding reverse video.
#                 These can be in the termcap if you want, but if you
#                 want them to be included anyway then just use the
#                 ANSI_VT, ANSI_XTERM or ANSI_ALL symbols mentioned above.
#                 They should work for a real VT340, a DECterm on a colour
#                 display or the colour version of xterm.
#                 Of course, I disclaim responsibility for what might
#                 happen on any other type of terminal or emulation.
#                 The extended highlighting (blinking, reverse video and
#                 underscoring) require the standard termcap entries
#                 for mb, mr (and me) and us (and ue).

MFLAGS = -DUSE_STDIO


# Debugging options: (put in DFLAGS)
# -DDEBUG       - simple debugging (onto file /tmp/outf) showing 3270 dialogue
# -DLDEBUG      - logging of exact terminal I/O:
#                 This only takes place if the call has the -d option.
#                 If DEBUG is also set then it goes onto /tmp/outf
#                 If DEBUG is not set then it goes ontl /tmp/log
# -DFROMNET     - save all characters received from the network connection
# -DTONET       - save all characters sent to the network connection
# -DSHOWFIELDS  - Include code to show field markers of IBM screen

# Mike's full debugging version

DFLAGS=   -DDEBUG -DLDEBUG -DFROMNET -DTONET -DSHOWFIELDS


# Where to find any extra library.
# We often need the library for the old termcap routines (tgetent etc),
# which is normally termlib (but not on the RS6000!)
# This may change if we go to standard terminfo!

EXTRALIB = -ltermlib -lsocket -lnsl

#Now put the whole lot together for the compilation flags.

CFLAGS=   -Dsys_$(SYSTEM_TYPE) $(SFLAGS) $(OFLAGS) $(MFLAGS) $(DFLAGS) $(DLOG) $(DPRINT) $(DPRINTC) $(DPRINTR) $(DSENDC) $(DSENDR) $(DLIB) $(DOPT) $(DPRO)

LINT = lint $(CFLAGS)

P3270 = telnet.o 3270.o curscr.o globals.o iomodule.o sizer.o statusline.o parse.o finddef.o initscr.o cr_tty.o

all: 3270 mset

3270: $(P3270)
	 $(CC) $(CFLAGS) -o t3270 $(P3270) $(EXTRALIB)

mset: mset.o finddef.o
	 $(CC) $(CFLAGS) -o mset mset.o finddef.o


lint: telnet.c 3270.c curscr.c globals.c iomodule.c sizer.c statusline.c parse.c finddef.c initscr.c cr_tty.c
	  $(LINT) telnet.c 3270.c curscr.c globals.c iomodule.c sizer.c statusline.c parse.c finddef.c initscr.c cr_tty.c $(EXTRALIB)

clean:
	    -/bin/rm -f *.o a.out core mset t3270

telnet.o: telnet.h globals.h 3270.h
3270.o: telnet.h globals.h 3270.h
curscr.o: telnet.h globals.h 3270.h
globals.o: globals.h
iomodule.o: telnet.h globals.h 3270.h
statusline.o: telnet.h globals.h 3270.h
sizer.o: globals.h
parse.o: globals.h 3270.h
initscr.o:
cr_tty.o:
