#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 these
           XPMLIB = -lXpm
           XPMINC =
XCOMM (version 3.4h of the XPM library is the earliest supported I know of)

XCOMM To omit PNG image support, uncomment this
XCOMM   NO_PNG_SUPPORT = -DNO_PNG_SUPPORT
XCOMM and comment these
           PNGLIB = -lpng
XCOMM      PNGINC = -I/usr/include/libpng12 -I/usr/include/libpng

XCOMM To omit regular expressions ("RE"s) support, uncomment this
XCOMM NO_REGEX_SUPPORT = -DNO_REGEX_SUPPORT
XCOMM and comment these
         REGEXLIB =
         REGEXINC =
XCOMM (the library must conform to the POSIX 1003.2 specification)

XCOMM To include sound support, uncomment any of the following sounds methods
XCOMM and corresponding library.
XCOMM Sound is supported either by way of the rplay library, esd, oss, or
XCOMM alsa in 'oss compatible' mode.

XCOMM General include dir for headers for any sound method.
XCOMM SOUNDINC = -I/usr/local/include
XCOMM Uncomment the following 2 lines for RPlay Sound Support
XCOMM HAVE_RPLAY=-DHAVE_RPLAY
XCOMM RPLAYLIB = -L/usr/local/lib -lrplay
XCOMM Uncomment the following 2 lines for ESD Sound Support
XCOMM HAVE_ESD=-DHAVE_ESD
XCOMM ESDLIB = -L/usr/local/lib -lesd
XCOMM Uncomment the following line for OSS Sound Support
XCOMM HAVE_OSS=-DHAVE_OSS

XCOMM To add Xft font rendering support, uncomment these
     TWM_USE_XFT = -DTWM_USE_XFT
 EXTRA_LIBRARIES += $(XFTLIB)

XCOMM To include font height dependent text layout spacing, uncomment this
 TWM_USE_SPACING = -DTWM_USE_SPACING

XCOMM To include _NET_WM_WINDOW_OPACITY client windows property support, uncomment this
 TWM_USE_OPACITY = -DTWM_USE_OPACITY

XCOMM To add support for client windows "sloppy" model focus policy, uncomment this
 TWM_USE_SLOPPYFOCUS = -DTWM_USE_SLOPPYFOCUS

XCOMM To add Xinerama support, uncomment these
 TWM_USE_XINERAMA = -DTWM_USE_XINERAMA
 EXTRA_LIBRARIES += $(XINERAMALIB)

XCOMM To add XRANDR support, uncomment these
 TWM_USE_XRANDR = -DTWM_USE_XRANDR
 EXTRA_LIBRARIES += $(XRANDRLIB)

XCOMM To omit m4 pre-processing of resource files, uncomment this
XCOMM    NO_M4_SUPPORT = -DNO_M4_SUPPORT

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 that require sys/select.h, uncomment this
XCOMM    NEED_SELECT_H = -DNEED_SELECT_H

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

XCOMM Installation path for the binary
       VTWMBINDIR = $(BINDIR)

XCOMM Installation path for the system resource file
       VTWMLIBDIR = $(SHAREDIR)/vtwm

XCOMM Installation path for the man page
       VTWMMANDIR = $(MANDIR)

XCOMM Method to manipulate process group so child does not muck with vtwm
        PROCESSGROUP = -DHAS_SETPGID
XCOMM   PROCESSGROUP = -DHAS_SETPGRP
XCOMM   PROCESSGROUP = -DHAS_SETPGRP -DSETPGRP_VOID
XCOMM   PROCESSGROUP = -DHAS_SETSID
XCOMM   PROCESSGROUP =



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

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) $(REGEXLIB)  $(RPLAYLIB) $(ESDLIB) \
                    $(XMULIB) $(EXTENSIONLIB) $(XLIB) $(PNGLIB)
         LINTLIBS = $(LINTXMU) $(LINTEXTENSIONLIB) $(LINTXLIB)
   EXTRA_INCLUDES = $(XPMINC) $(REGEXINC) $(SOUNDINC) $(XFTINCLUDES) $(PNGINC)
          DEFINES = $(SIGNAL_DEFINES) $(NO_XPM_SUPPORT) $(NO_REGEX_SUPPORT) \
                    $(NO_SOUND_SUPPORT)  $(HAVE_RPLAY) $(HAVE_ESD) $(HAVE_OSS) \
		    $(NO_M4_SUPPORT) $(NO_PNG_SUPPORT) \
		    $(TWM_USE_XFT) $(TWM_USE_SPACING) $(TWM_USE_OPACITY) \
		    $(TWM_USE_XINERAMA) \
		    $(TWM_USE_XRANDR) \
		    $(TWM_USE_SLOPPYFOCUS) $(PROCESSGROUP)

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

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

AllTarget(vtwm)

SpecialObjectRule(menus.o,gram.h,$(NO_BUILD_INFO) $(NEED_PROCESS_H))

SpecialObjectRule(util.o,gram.h,$(NEED_PUTENV_F))

SpecialObjectRule(events.o,gram.h,$(NEED_SELECT_H))

SpecialObjectRule(parse.o,gram.h,$(NEED_YYLINENO_V) \
'-DSYSTEM_VTWMRC="'$(VTWMLIBDIR)'/system.vtwmrc"' \
'-DSYSTEM_TWMRC="'$(VTWMLIBDIR)'/system.twmrc"')

SpecialObjectRule(add_window.o applets.o icons.o \
list.o regions.o sound.o twm.o,gram.h,NullParameter)

NormalProgramTarget(vtwm,$(OBJS),$(DEPLIBS),$(LOCAL_LIBRARIES),NullParameter)

InstallProgram(vtwm,$(VTWMBINDIR))
InstallManPage(vtwm,$(VTWMMANDIR))
InstallNonExecFile(system.vtwmrc,$(VTWMLIBDIR))

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

all::
	$(RM) deftwmrc.* lastmake.*

install::
	$(RM) deftwmrc.* lastmake.*
	$(MAKE) install.man

clean::
	$(RM) y.tab.h y.tab.c lex.yy.c gram.h gram.c lex.c deftwmrc.c version-tmp.c \
	lastmake.c system.vtwmrc vtwm.dw vtwm.ser vtwm.html vtwm.ps vtwm.man
	$(RM) -rf .release

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

deftwmrc.c: 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 '/^#/d' -e 's/"/\\"/g' -e 's/^/"/' -e 's/$$/",/' -e 's/[	]\{1,\}/ /g' -e 's/^" /"/' system.vtwmrc >>$@
	echo '(char *)0 };' >>$@

version.o: version.c
	if [ -d .git ]; then sed "s/SUBST/`git describe --tags`/" < version.c > version-tmp.c; else cp version.c version-tmp.c; fi
	$(CC) -c $(CFLAGS) -o version.o version-tmp.c
	rm -f version-tmp.c

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

system.vtwmrc:
	$(RM) $@
	$(CP) $@.$(SYS_VTWMRC_LOOK) $@

vtwm.man:
	$(RM) $@
	$(LN) doc/$@ $@

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) < $< >$@
