       PROGRAMS = x3270 x3270if
LOCAL_LIBRARIES = $(XAWLIB) $(XMULIB) $(XTOOLLIB) $(XLIB)
          SRCS1 = Cme.c CmeBSB.c CmeLine.c CmplxMenu.c \
                  about.c actions.c ansi.c apl.c ctlr.c ft.c ft_cut.c \
		  ft_dft.c keypad.c kybd.c macros.c main.c menubar.c popups.c \
		  print.c save.c screen.c scroll.c select.c sf.c status.c \
		  tables.c telnet.c trace_ds.c util.c
          SRCS2 = x3270if.c
          VOBJS = Cme.o CmeBSB.o CmeLine.o CmplxMenu.o \
                  about.o actions.o ansi.o apl.o ctlr.o fallbacks.o ft.o \
		  ft_cut.o ft_dft.o keypad.o kybd.o macros.o main.o menubar.o \
		  popups.o print.o save.o screen.o scroll.o select.o sf.o \
		  status.o tables.o telnet.o trace_ds.o util.o 
          OBJS1 = $(VOBJS) version.o
          OBJS2 = x3270if.o
          FONTS = 3270.snf     3270b.snf \
                  3270-12.snf  3270-12b.snf \
                  3270-20.snf  3270-20b.snf \
                  3270d.snf \
                  3270h.snf \
                  3270gt8.snf \
                  3270gt12.snf 3270gt12b.snf \
                  3270gt16.snf 3270gt16b.snf \
                  3270gt24.snf 3270gt24b.snf \
                  3270gt32.snf 3270gt32b.snf

    FONTINSTDIR = $(FONTDIR)/misc

    LIBX3270DIR = $(LIBDIR)/x3270
      HOSTSFILE = ibm_hosts

        DEFINES = -DLIBX3270DIR=\"$(LIBX3270DIR)\"

#ifdef HPArchitecture
EXTRA_DEFINES = -D_HPUX_SOURCE
#endif

/* For SVR4, uncomment the following: */
/* EXTRA_LIBRARIES = -lnsl -lsocket */

/* For Dynix/ptx, umcomment the following: */
/* EXTRA_LIBRARIES = -lsocket -linet -lnsl */

AllTarget($(FONTS) x3270 x3270if)

ComplexProgramTarget_1(x3270,,$(LOCAL_LIBRARIES))
ComplexProgramTarget_2(x3270if,,)

InstallManPage(x3270-script,$(MANDIR))
InstallManPage(ibm_hosts,$(MANDIR))

FontTarget(3270)
FontTarget(3270b)
FontTarget(3270-12)
FontTarget(3270-12b)
FontTarget(3270-20)
FontTarget(3270-20b)
FontTarget(3270d)
FontTarget(3270h)
FontTarget(3270gt8)
FontTarget(3270gt12)
FontTarget(3270gt12b)
FontTarget(3270gt16)
FontTarget(3270gt16b)
FontTarget(3270gt24)
FontTarget(3270gt24b)
FontTarget(3270gt32)
FontTarget(3270gt32b)
InstallMultipleFlags($(FONTS),$(FONTINSTDIR),$(INSTDATFLAGS))
MakeDirectories(install,$(LIBX3270DIR))

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

fallbacks.c: mkfb X3270.xad
	./mkfb X3270.xad >fallbacks.c

mkfb: mkfb.c
	$(CC) -o mkfb mkfb.c

/*
 * To use a separate app-defaults file rather than compiling it into x3270,
 * uncomment the following three lines:
 */
/* EXTRA_DEFINES = -DUSE_APP_DEFAULTS */
/* InstallAppDefaults(X3270) */
/* all:: X3270.ad */

/*
 * Rule for building the separate app-defaults file.  By default it builds
 * color app-defaults; to change to monochrome app-defaults, uncomment
 * the second "AD_OPTS=" line below.
 */
AD_OPTS=-DCOLOR
/* AD_OPTS=-UCOLOR */
X3270.ad: X3270.xad qcpp
	$(RM) $@
	qcpp $(AD_OPTS) X3270.xad >$@
qcpp: qcpp.c
	$(CC) -o $@ qcpp.c

/* Extra install rule to regenerate misc/fonts.dir */
install:: $(DESTDIR)$(FONTINSTDIR)/fonts.dir
$(DESTDIR)$(FONTINSTDIR)/fonts.dir::
	-chmod u+w $(DESTDIR)$(FONTINSTDIR) $(DESTDIR)$(FONTINSTDIR)/fonts.dir
	$(BINDIR)/$(MKFONTDIR) $(DESTDIR)$(FONTINSTDIR)
	chmod u=rwx,go=rx $(DESTDIR)$(FONTINSTDIR)
	chmod a=r $(DESTDIR)$(FONTINSTDIR)/fonts.dir

/* Extra install rule for the sample ibm_hosts file (runs only if there is
   no ibm_hosts file installed yet). */
install:: $(HOSTSFILE)
	@[ -r $(DESTDIR)$(LIBX3270DIR)/$(HOSTSFILE) ] || \
	$(INSTALL) -c $(INSTDATFLAGS) $(HOSTSFILE) $(DESTDIR)$(LIBX3270DIR)/$(HOSTSFILE)

clean::
	$(RM) $(FONTS) mkfb fallbacks.c
