# Copyright (c) 1999-2009, Paul Mattes.
# All rights reserved.
# 
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#     * Redistributions of source code must retain the above copyright
#       notice, this list of conditions and the following disclaimer.
#     * Redistributions in binary form must reproduce the above copyright
#       notice, this list of conditions and the following disclaimer in the
#       documentation and/or other materials provided with the distribution.
#     * Neither the name of Paul Mattes nor his contributors may be used
#       to endorse or promote products derived from this software without
#       specific prior written permission.
# 
# THIS SOFTWARE IS PROVIDED BY PAUL MATTES "AS IS" AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
# NO EVENT SHALL PAUL MATTES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

# Makefile for s3270 (scripted 3270 emulator)

RM = rm -f
CC = @CC@

all:: s3270 x3270if

SRCS = actions.c ansi.c apl.c charset.c ctlr.c ft.c ft_cut.c \
	ft_dft.c glue.c host.c idle.c kybd.c macros.c print.c proxy.c \
	resolver.c readres.c resources.c rpq.c see.c sf.c smain.c tables.c \
	telnet.c toggles.c trace_ds.c unicode.c unicode_dbcs.c utf8.c util.c \
	xio.c XtGlue.c
VOBJS = actions.o ansi.o apl.o charset.o ctlr.o fallbacks.o ft.o ft_cut.o \
	ft_dft.o glue.o host.o idle.o kybd.o macros.o print.o proxy.o \
	resolver.o readres.o resources.o rpq.o see.o sf.o smain.o tables.o \
	telnet.o toggles.o trace_ds.o unicode.o unicode_dbcs.o utf8.o util.o \
	xio.o XtGlue.o
OBJS1 = $(VOBJS) version.o

LIBDIR = @libdir@
prefix = @prefix@
exec_prefix = @exec_prefix@
sysconfdir = @sysconfdir@
datarootdir = @datarootdir@
LIBX3270DIR = @LIBX3270DIR@
MANDIR = @mandir@
BINDIR = @bindir@
INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@

#CDEBUGFLAGS = -g -Wall

XCPPFLAGS = -I. -DLIBX3270DIR=\"$(LIBX3270DIR)\" @CPPFLAGS@ @XANSI@ @XPRECOMP@
CFLAGS = @CFLAGS@ $(XCPPFLAGS) $(CDEBUGFLAGS)
LDFLAGS = @LDFLAGS@
LIBS = @LIBS@

version.o: $(VOBJS) version.txt mkversion.sh
	@chmod +x mkversion.sh version.txt
	sh ./mkversion.sh $(CC) s3270

fallbacks.c: mkfb X3270.xad
	$(RM) $@
	./mkfb -c X3270.xad $@

s3270: $(OBJS1)
	$(CC) -o $@ $(OBJS1) $(LDFLAGS) $(LIBS)
x3270if: x3270if.c
	$(CC) $(CFLAGS) -o $@ x3270if.c $(LDFLAGS) $(LIBS)

install:: s3270 x3270if
	[ -d $(DESTDIR)$(BINDIR) ] || \
		mkdir -p $(DESTDIR)$(BINDIR)
	$(INSTALL_PROGRAM) s3270 $(DESTDIR)$(BINDIR)/s3270
	$(INSTALL_PROGRAM) x3270if $(DESTDIR)$(BINDIR)/x3270if

install.man:
	[ -d $(DESTDIR)$(MANDIR)/man1 ] || \
		mkdir -p $(DESTDIR)$(MANDIR)/man1
	$(INSTALL_DATA) s3270.man $(DESTDIR)$(MANDIR)/man1/s3270.1
	$(INSTALL_DATA) x3270if.man $(DESTDIR)$(MANDIR)/man1/x3270if.1
	$(INSTALL_DATA) x3270-script.man $(DESTDIR)$(MANDIR)/man1/x3270-script.1

clean::
	$(RM) s3270 *.o

depend:
	gccmakedep $(XCPPFLAGS) -s "# DO NOT DELETE" $(SRCS)

# -------------------------------------------------------------------------
# dependencies generated by makedepend

# DO NOT DELETE
