/* Imakefile for the X Desktop Manager.
 * ====================================
 *
 * To create a Makefile from this file, use the xmkmf script supplied
 * with X11R4, or use imake directly.
 *
 * XDTM V2.5 requires the existence of the following tools and 
 * libraries:
 *            + The X Window System Release 4 or greater header files 
 *              and libraries
 *            + The Athena Widget Set (header files + library)
 *            + The Xpm3 library from Arnaud Le Hors (lehors@sophia.inria.fr)
 *            + lex or flex
 *            + yacc or bison
 *            + a smile on your face :-)
 */

/**/# X Desktop Manager version 2.5
/**/# =============================
/**/#
/**/# XDTM has four operating system dependent flags which should be added
/**/# to XDTMOPTIONS:
/**/#
/**/# HAS_STRSTR        This flag should be enabled on systems which  
/**/#                   have the strstr(3) string function. If it is
/**/#                   not enabled xdtm will supply a replacement.
/**/#
/**/# USE_CWD           If your system has the getcwd(3) library routine
/**/#                   then define this flag, otherwise the getwd(3)
/**/#                   will be used.
/**/#
/**/# TRUE_SYSV         If your system does NOT have any BSD extensions
/**/#                   like sockets and symbolic links then define
/**/#                   this flag.
/**/#
/**/# ECHO_N            If the echo(1) program on your machine uses the
/**/#                   '-n' flag to specify that a newline should NOT
/**/#                   be printed after the string then define this
/**/#                   flag. If your echo(1) program supports the '\c'
/**/#                   notation then do NOT define this flag.
/**/#                   If your not sure enter '/bin/echo -n hello' if
/**/#                   the '-n' is printed then do not define this flag.
/**/#
/**/# USE_TERMIOS       If Posix termios should be used instead of SysVish
/**/#                   termio.
/**/#
/**/# If make fails with a syntax error try expanding any tabs in this
/**/# file to spaces. (use the expand(1) utility)
/**/#



/* #define BISON /* If you want to use bison instead of yacc */
/* #define FLEX /* If you want to use flex instead of lex */
#define XPM /* If you have the Xpm library installed */

#ifdef XPM
      XPM_DEFINES = -DXPM
     XPM_INCLUDES = -I/usr/include/X11
          XPM_LIB = -lXpm
#else
      XPM_DEFINES =
     XPM_INCLUDES =
          XPM_LIB =
#endif

#ifdef FLEX
     LEX_LIBRARY =
             LEX = flex
          LFLAGS = -f -t
#else
     LEX_LIBRARY = -ll
             LEX = lex
          LFLAGS = -t
#endif

#ifdef BISON
            YACC = bison
          YFLAGS = -y -d
#else
            YACC = yacc
          YFLAGS = -d
#endif

/* If you are going to let imake install xdtm for you in your default
 * directories then define Install_defines below, this will compile the
 * locations of the default system config. and help files into xdtm
 * automatically. 
 * Otherwise comment out Install_defines if you want to edit the xdtm.h
 * file by hand to set the default positions. For example, to compile 
 * the program to use a help file in /tmp/help comment out the
 * Install_defines and edit xdtm.h so that SYSTEM_HELP is "/tmp/help".
 */

XDTMDIR=$(LIBDIR)/xdtm

#define Install_defines   -DSYSTEM_HELP=\"$(XDTMDIR)/help\" \
                          -DSYSTEM_XDTMRC=\"$(XDTMDIR)/xdtmrc\" \
                          -DSYSTEM_HELP_PERM=\"$(XDTMDIR)/perm.help\"

/* Leave the following define even if you comment out the above one. */
#ifndef Install_defines
#define Install_defines  /* Empty */
#endif

/* SunOS defines (Comment LOCAL_LDFLAGS out if you want dynamic linking) */
#ifdef SunArchitecture
         XDTMOPTIONS = -DHAS_STRSTR -DECHO_N
       LOCAL_LDFLAGS = -Bstatic
     EXTRA_LIBRARIES = -Bdynamic -ldl
#endif

/* AIX defines (Comment LOCAL_LDFLAGS out if you want dynamic linking) */
#ifdef RsArchitecture
         XDTMOPTIONS = -DHAS_STRSTR -DECHO_N
       LOCAL_LDFLAGS = -bnso -bI:/lib/syscalls.exp
#endif

/* A/UX defines  */
#ifdef MacIIArchitecture
         XDTMOPTIONS = -D_SYSV_SOURCE -D_BSD_SOURCE
#endif

/* Interactive UNIX 
         XDTMOPTIONS = -Xp -DTRUE_SYSV -D_POSIX_SOURCE -D_XOPEN_SOURCE
*/

/* HP-UX defines (Comment LOCAL_LDFLAGS out if you want dynamic linking) */
#ifdef HPArchitecture
         XDTMOPTIONS = -DECHO_N -DUSE_CWD -DHAS_STRSTR 
       LOCAL_LDFLAGS = -Wl,-a,archive 
#endif

#ifdef i386BsdArchitecture
         XDTMOPTIONS = -DHAS_STRSTR -DUSE_CWD -DECHO_N -DUSE_TERMIOS
#endif

/* Other defines 
         XDTMOPTIONS = -DHAS_STRSTR -DUSE_CWD -DTRUE_SYSV -DECHO_N 
*/

/**/# Put the name of your C compiler in here, I find gcc best but xdtm 
/**/# will now compile with non-ANSI (K&R) compilers (usually cc).
/**/#
/**/# If using the A/UX cc add '-B /usr/lib/big/ to use the compiler
/**/# with the large symbol table.

       DEFINES = $(XPM_DEFINES) $(XDTMOPTIONS) Install_defines
  STD_INCLUDES = -I. -I.. $(XPM_INCLUDES)

/* IBM AIX TO FIX A COMPILER BUG WHEN -O IS SET*/
#ifdef RsArchitecture
     CDEBUGFLAGS =     /* put -g or nothing here, DO NOT OPTIMIZE */
#endif

            SRCS = main.c menus.c appman.c dirman.c \
                   fileman.c parse.c Ext/termwindow.c Ext/iconman.c \
                   Xedw/XedwList.c Xedw/XedwForm.c lexical.l parser.y \
                   scroll_hack.c mystrstr.c buttons.c \
                   display.c listoption.c map.c newfile.c \
                   quit.c doubleclick.c dialogs.c locicon.c

            OBJS = appman.o \
                   buttons.o \
                   dialogs.o \
                   display.o \
                   dirman.o \
                   doubleclick.o \
                   fileman.o \
                   listoption.o \
                   map.o \
                   main.o \
                   menus.o \
                   mystrstr.o \
                   newfile.o \
                   parse.o \
                   parser.o \
                   lexical.o \
                   quit.o \
                   scroll_hack.o \
                   locicon.o

         DEPLIBS = Ext Xedw regexp

 LOCAL_LIBRARIES = -LExt -lExt -Lregexp -lregexp -LXedw -lXedw
   SYS_LIBRARIES = $(XPM_LIB) $(XAWLIB) $(XMULIB) $(XTOOLLIB) $(XLIB) $(LEX_LIBRARY) -lm



#define IHaveSubdirs
#define PassCDebugFlags 'CC=$(CC)' 'CFLAGS=$(CFLAGS)' 

         SUBDIRS = Ext Xedw regexp

/**/# Make xdtm 
all:: Message xdtm

ComplexProgramTarget(xdtm)

/**/# Make the lexical analyzer as a seperate program for debugging.

NormalProgramTarget(lexical, lexical.c,,$(LOCAL_LIBRARIES),-DDEBUG_LEX)

/**/# Make the parser as a seperate program for debugging

NormalProgramTarget(parser, lexical.c parser.c,,$(LOCAL_LIBRARIES),-DDEBUG_YACC)

NamedMakeSubdirs(Ext, Ext)

NamedMakeSubdirs(Xedw, Xedw)

NamedMakeSubdirs(regexp, regexp)

/**/# Insert the icon directory into the system xdtmrc, keep the original
/**/# in xdtmrc.orig, which is moved back to xdtmrc after the modified 
/**/# xdtmrc has been installed.

install::
	$(MV) xdtmrc xdtmrc.orig
	sed -e 's^\"{icon dir}\"^\"$(XDTMDIR)/icons\"^' \
	   xdtmrc.orig > xdtmrc
	sed -e 's^iconfile^$(XDTMDIR)/new_xdtm.xbm^' Xdtm.ad.tmpl > Xdtm.ad

/**/# Install the xdtm execute script file, used to prevent xterms closing
/**/# when the inferier process dies.
InstallProgram(xdtm.sh, $(BINDIR))

/**/# Install the helpfile, system xdtmrc, icon bitmaps and the default
/**/# application defaults.

MakeDirectories(install, $(XDTMDIR))
InstallNonExec(help, $(XDTMDIR))
InstallNonExec(perm.help, $(XDTMDIR))
InstallNonExec(xdtmrc, $(XDTMDIR))
InstallNonExec(bitmaps/new_xdtm.xbm, $(XDTMDIR))
MakeDirectories(install, $(XDTMDIR)/icons)
InstallAppDefaults(Xdtm)

install::
	$(CP) icons$(PATHSEP)*$(PATHSEP)*.icon $(XDTMDIR)/icons
	$(RM) xdtmrc
	$(MV) xdtmrc.orig xdtmrc
	chmod -R a+r $(XDTMDIR)

/**/# Make the emacs TAGS file

etags:
	etags -t *.h $(SRCS)  

clean::
	$(RM) lexical.c parser.c parser.h xdtmrc.new *.tab.*

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

lexical.c: parser.h lexical.l
	$(LEX) $(LFLAGS) lexical.l > lexical.c

lexical.o: parser.h

tar: clean
	(cd ..;tar chf - -I ./xdtm/xdtm.MANIFEST  | gzip > xdtm-2.5.1.tar.gz)

Message:
	@( \
	echo "********************************************************"; \
	echo "*        Compiling the X Desktop Manager V2.5          *"; \
	echo "*                                                      *"; \
	echo "*   Have you configured the master Imakefile in this   *"; \
	echo "*            directory for this machine?               *"; \
	echo "*                                                      *"; \
	echo "*   Have you made the Makefiles in Xedw and regexp?    *"; \
	echo "*           if not type 'make Makefiles'               *"; \
	echo "*                                                      *"; \
	echo "* Available targets: xdtm          (default)           *"; \
	echo "*                    install     - install xdtm        *"; \
	echo "*                    install.man - install man page    *"; \
	echo "*                    etags       - Make emacs tags     *"; \
	echo "*                    clean       - Clean directory     *"; \
	echo "*                    tar         - Archive xdtm        *"; \
	echo "********************************************************"; \
	echo ""; \
	)


