#ifndef XCOMM
#define XCOMM #
#endif

XCOMM $XConsortium: Imakefile,v 1.33 91/07/17 00:48:06 gildea Exp $
XCOMM
XCOMM Here is an Imakefile for VTWM.
XCOMM I like to use Imakefiles for everything, and I am sure other
XCOMM people do also, so perhaps you could do us all a favor and
XCOMM distribute this one.

XCOMM =============== Start of common editables =====================

XCOMM To omit XPM image support, uncomment this
XCOMM   NO_XPM_SUPPORT = -DNO_XPM_SUPPORT
XCOMM and comment this
           XPMLIB = -lXpm
XCOMM (version 3.4h of the XPM library is the earliest supported I know of)

XCOMM To omit platform and build info in the version window, uncomment this
XCOMM    NO_BUILD_INFO = -DNO_BUILD_INFO

XCOMM For those systems that don't have putenv(), uncomment this
XCOMM    NEED_PUTENV_F = -DNEED_PUTENV_F

XCOMM For those systems require sys/select.h, uncomment this
XCOMM    NEED_SELECT_H = -DNEED_SELECT_H

XCOMM For those systems require process.h, uncomment this
XCOMM   NEED_PROCESS_H = -DNEED_PROCESS_H

XCOMM For those systems that have TWM installed in locations other than
XCOMM the default for the $(LIBDIR) macro, change this to match
          VTWMDIR = $(LIBDIR)/twm

XCOMM For the traditional look of TWM as the system fallback,
XCOMM change this to "2D"
  SYS_VTWMRC_LOOK = 3D

XCOMM ================ End of common editables ======================

XCOMM ============= Start of less common editables ==================

XCOMM Handy for developers to check man page editions
XCOMM (see the end of this file)
           DEROFF = deroff
               DW = dw
            SPELL = spell

XCOMM Required to generate HTML or Postscript versions of the man page
XCOMM (see the end of this file)
         MAN2HTML = man2html
           MAN2PS = man2ps

XCOMM ============== End of less common editables ===================

XCOMM ========= Editing below here should not be necessary ==========

           YFLAGS = -d
          DEPLIBS = $(DEPXMULIB) $(DEPEXTENSIONLIB) $(DEPXLIB)
  LOCAL_LIBRARIES = $(LEXLIB) $(XPMLIB) $(XMULIB) $(EXTENSIONLIB) $(XLIB)
         LINTLIBS = $(LINTXMU) $(LINTEXTENSIONLIB) $(LINTXLIB)
          DEFINES = $(SIGNAL_DEFINES)

             SRCS = gram.c lex.c deftwmrc.c add_window.c gc.c list.c twm.c \
                    parse.c menus.c events.c resize.c util.c version.c iconmgr.c \
                    cursor.c icons.c desktop.c doors.c lastmake.c

             OBJS = gram.o lex.o deftwmrc.o add_window.o gc.o list.o twm.o \
                    parse.o menus.o events.o resize.o util.o version.o iconmgr.o \
                    cursor.o icons.o desktop.o doors.o lastmake.o

AllTarget(vtwm)

SpecialObjectRule(menus.o,menus.c,$(NO_BUILD_INFO) $(NEED_PROCESS_H) $(NEED_PUTENV_F))

SpecialObjectRule(util.o,util.c,$(NO_XPM_SUPPORT) $(NEED_PUTENV_F))

SpecialObjectRule(events.o,events.c,$(NEED_SELECT_H))

SpecialObjectRule(icons.o,icons.c,$(NO_XPM_SUPPORT))

SpecialObjectRule(add_window.o,add_window.c,$(NO_XPM_SUPPORT))

SpecialObjectRule(desktop.o,desktop.c,$(NO_XPM_SUPPORT))

SpecialObjectRule(parse.o,parse.c,\
'-DSYSTEM_VTWMRC="'$(VTWMDIR)'/system.vtwmrc"' \
'-DSYSTEM_TWMRC="'$(VTWMDIR)'/system.twmrc"')

depend:: lex.c gram.c deftwmrc.c lastmake.c

ComplexProgramTarget(vtwm)
InstallNonExecFile(system.vtwmrc,$(VTWMDIR))

gram.h gram.c: gram.y
	$(YACC) $(YFLAGS) gram.y
	$(MV) y.tab.c gram.c
	$(MV) y.tab.h gram.h

clean::
	$(RM) y.tab.h y.tab.c lex.yy.c gram.h gram.c lex.c deftwmrc.c lastmake.c system.vtwmrc

deftwmrc.c: system.vtwmrc.$(SYS_VTWMRC_LOOK)
	$(CP) system.vtwmrc.$(SYS_VTWMRC_LOOK) system.vtwmrc
	$(RM) $@
	echo '/* ' >>$@
	echo ' * This file is generated automatically from the default' >>$@
	echo ' * VTWM bindings file system.vtwmrc.'$(SYS_VTWMRC_LOOK)' by the VTWM Makefile.' >>$@
	echo ' */' >>$@
	echo '' >>$@
	echo 'char *defTwmrc[] = {' >>deftwmrc.c
	sed -e '/^#/d' -e 's/"/\\"/g' -e 's/^/    "/' -e 's/$$/",/' system.vtwmrc >>$@
	echo '    (char *) 0 };' >>$@

lastmake.c:
	$(RM) $@
	echo '/* ' >>$@
	echo ' * This file is generated automatically by the VTWM Makefile.' >>$@
	echo ' */' >>$@
	echo '' >>$@
	echo 'char *lastmake[] = {' >>lastmake.c
	echo '    "Platform:  '`uname -s`' Version '`uname -v`' Release '`uname -r`'",' >>$@
	echo '    "Build:  '`date`'",' >>$@
	echo '    "" };' >>$@

XCOMM Handy for developers to check the man page
dw vtwm.dw: vtwm.man
	$(DEROFF) vtwm.man | $(DW) >vtwm.dw
	@if test -s vtwm.dw ; \
	then \
	    echo Doubled words in vtwm.man ... ; \
	    cat vtwm.dw ; \
	fi
spell vtwm.ser: vtwm.man vtwm.sok
	$(DEROFF) vtwm.man | $(SPELL) +vtwm.sok >vtwm.ser
	@if test -s vtwm.ser ; \
	then \
	    echo Spelling exceptions in vtwm.man ... ; \
	    cat vtwm.ser ; \
	fi

XCOMM If you wish to generate HTML or Postscript versions of the man page,
XCOMM enter 'make vtwm.html' or 'make vtwm.ps'
vtwm.html: vtwm.man
	$(MAN2HTML) vtwm.man
vtwm.ps: vtwm.man
	$(MAN2PS) < $< >$@
