/* 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 :-)
 */

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

/* Define NotUsrLibLX11 if you wish toinstall Xdtm default config
 * file and help files elsewhere than /usr/lib/X11 (default location in
 * xdtm.h). It may be that LIBDIR is different that /usr/lib/X11.
 */
#define NotUsrLibX11
#ifdef NotUsrLibX11
XDTMDIR=$(LIBDIR)/xdtm
#define Install_defines   -DSYSTEM_LIB_DIR=\"$(XDTMDIR)\" -DSYSTEM_XDTMRC=\"$(XDTMDIR)/xdtmrc\"
#endif

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

/* SunOS defines (Uncomment LOCAL_LDFLAGS out if you want static linking) */
#if defined(SunArchitecture) && !SystemV4
         XDTMOPTIONS = -DHAS_STRSTR -DECHO_N
/*       LOCAL_LDFLAGS = -Bstatic
         EXTRA_LIBRARIES = -Bdynamic -ldl */
#endif

/* AIX defines (Uncomment LOCAL_LDFLAGS out if you want static 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 (Uncomment LOCAL_LDFLAGS out if you want static linking) */
#ifdef HPArchitecture
         XDTMOPTIONS = -DUSE_CWD -DHAS_STRSTR 
      /* LOCAL_LDFLAGS = -Wl,-a,archive */
#endif

/* OSF/1 defines (Uncomment "-non_shared" out if you want static linking) */
#ifdef AlphaArchitecture
       LOCAL_LDFLAGS = -call_shared /*-non_shared*/
       XDTMOPTIONS = -DECHO_N -DUSE_CWD -DHAS_STRSTR -UFUNCPROTO
#endif

/* SGI defines (Uncomment "-non_shared" out if you want static linking) */
#ifdef SGIArchitecture
       LOCAL_LDFLAGS = /*-non_shared*/
#endif

/* Solaris defines (Uncomment "-Bstatic" out if you want static linking) */
#if defined(SunArchitecture) && SystemV4
       LOCAL_LDFLAGS = -R$(LIBDIR):/usr/openwin/lib:/usr/lib /*-Bstatic*/
#endif

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

#if defined(LinuxArchitecture)
         XDTMOPTIONS = -DHAS_STRSTR -DUSE_CWD -DECHO_N -DUSE_TERMIOS
#endif

#if SystemV4		/* SVR4 is mostly POSIX */
	 XDTMOPTIONS = -DHAS_STRSTR -DUSE_CWD -DUSE_TERMIOS
#endif

/* NCR defines */
#ifdef NCRArchitecture
         XDTMOPTIONS = -DSYSV -DUSE_CWD
#endif

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

XCOMM Put the name of your C compiler in here, I find gcc best but xdtm 
XCOMM will now compile with non-ANSI (K&R) compilers (usually cc).
XCOMM
XCOMM If using the A/UX cc add '-B /usr/lib/big/ to use the compiler
XCOMM 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

XCOMM Make xdtm 
all:: Message xdtm

ComplexProgramTarget(xdtm)

XCOMM Make the lexical analyzer as a seperate program for debugging.

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

XCOMM 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)

XCOMM Insert the icon directory into the system xdtmrc, keep the original
XCOMM in xdtmrc.orig, which is moved back to xdtmrc after the modified 
XCOMM 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

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

XCOMM Install the helpfile, system xdtmrc, icon bitmaps and the default
XCOMM 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)

XCOMM 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.5.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 ""; \
	)
