#define IHaveSubdirs
#define PassCDebugFlags

      WORLDOPTS = -k
BOOTSTRAPCFLAGS = 
     CHECKFNSRC = $(UTILSRC)/checkfn
        CHECKFN = $(CHECKFNSRC)/checkfn

/**/#
/**/# Preserve this order!
/**/#
  LIBDIRSTOMAKE = \
		$(INCLUDESRC) \
		$(LIBSRC) \
		$(EXTENSIONSRC) 
#if BuildServer
SERVERDIRSTOMAKE = \
		$(SERVERSRC) \
		$(FONTSRC) \
		$(RGBSRC)  
#endif
CLIENTDIRSTOMAKE = \
		$(CLIENTSRC) \
		$(DEMOSRC) \
		$(EXAMPLESRC)
     DIRSTOMAKE = \
		$(LIBDIRSTOMAKE) \
		$(SERVERDIRSTOMAKE) \
		$(CLIENTDIRSTOMAKE) 
        SUBDIRS = \
		$(DIRSTOMAKE) \
		$(UTILSRC) \
		$(DOCSRC)
  LNINSTALLDIRS = \
		$(EXTENSIONSRC) \
		$(LIBSRC)

MakeSubdirs($(SUBDIRS))

MakeDirectories(install.ln, $(LINTLIBDIR))

MakeLintSubdirs($(LNINSTALLDIRS),install.ln,install.ln)

MakeLintSubdirs($(LNINSTALLDIRS),external.ln,lintlib)


/**/#
/**/# before depending, be sure that include has everything in it.
/**/#
depend::
	cd $(INCLUDESRC); $(MAKE)

DependSubdirs($(SUBDIRS))


/**/# 
/**/# install stuff; create the directories that we're going to need
/**/# 

#if BuildServer
  DIRS_SERVER = $(FONTDIR) /* $(ADMDIR) */
#endif
#if InstallxinitConfig
   DIRS_XINIT = $(XINITDIR)
#endif
#if InstallxdmConfig
     DIRS_XDM = $(XDMDIR)
#endif
#if InstallAppDefFiles
  DIRS_APPDEF = $(XAPPLOADDIR)
#endif

 DIRS_CONTRIB = /* $(AWMDIR) $(TWMDIR) */

DIRS_TO_BUILD = $(DIRS_SERVER) \
	$(USRLIBDIR) $(BINDIR) $(INCDIR) $(LIBDIR) /* $(LINTLIBDIR) */ \
	$(DIRS_XINIT) $(DIRS_XDM) $(DIRS_APPDEF) $(DIRS_CONTRIB)

MakeDirectories(install, $(DIRS_TO_BUILD))

MakeDirectories(install.man, $(MANPATH) $(MANDIR) $(LIBMANDIR))
InstallManPage(X,$(MANDIR))


/**/# don't name your log file make.log when you run this ...
World::
	@echo ""
	@echo "Building Release 3 of the X Window System"
	@echo ""
	@echo "##############################################################"
	@echo "# Did you remember to check the configuration parameters in  #"
	@echo "# the directory util/imake.includes and set BOOTSTRAPCFLAGS? #"
	@echo "##############################################################"
	@echo ""
	@date
	@echo ""
	cd $(IMAKESRC); $(MAKE) clean; $(MAKE) BOOTSTRAPCFLAGS="$(BOOTSTRAPCFLAGS)"
	-$(MV) Makefile Makefile.bak
	$(MAKE) -f Makefile.bak Makefile
	$(MAKE) Makefiles
	$(MAKE) clean
	$(MAKE) depend
	$(MAKE) $(WORLDOPTS)
	@echo ""
	@date
	@echo ""
	@echo "Build of the X Window System complete."
	@echo ""

Everything::
	cd $(IMAKESRC); $(MAKE) BOOTSTRAPCFLAGS="$(BOOTSTRAPCFLAGS)"
	-$(MV) Makefile Makefile.bak
	$(MAKE) -f Makefile.bak Makefile
	$(MAKE) Makefiles
	$(MAKE) depend
	$(MAKE) $(WORLDOPTS)

CHANGES.ALL::
	$(RM) $@
	(for i in `find . -name CHANGES -print`; do \
	echo $$i; echo ""; cat $$i; echo ""; \
	echo "==========================================================="; \
	done) >$@

/*
 * This section used for generating distributions will not be useful to most
 * people.
 */
/**/# check all filenames for length, letters, and content
checkfilenames::  $(CHECKFNSRC)/checkfn
	@find . -type d -exec $(CHECKFNSRC)/find.sh $(CHECKFN) {} \;

/**/# clean out link tree looking for stuff that should get checked in
flushlinks::
	make -k clean
	find . -type l -exec rm {} \;
	find . \( \! \( -type d -o -name Makefile \) \) -print

/**/# rebuild the Makefiles in the master source tree
mastermakefiles::
	cd $(IMAKESRC); $(MAKE) clean; $(MAKE) BOOTSTRAPCFLAGS="$(BOOTSTRAPCFLAGS)"
	-$(MV) Makefile Makefile.bak
	$(MAKE) -f Makefile.bak Makefile
	$(MAKE) Makefiles
	cd $(DEPENDSRC); $(MAKE) clean; $(MAKE) all
	$(MAKE) depend
	cd $(IMAKESRC); $(MAKE) clean
	cd $(DEPENDSRC); $(MAKE) clean

