#define IHaveSubdirs
#define PassCDebugFlags

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

/**/#
/**/# The order given here is necessary for some things to build; note that in
/**/# R4beta, the "fonts" and "rgb" directories will become subdirectories of
/**/# server so that BuildServer is no longer necessary.
/**/#
#if BuildServer
SERVERDIRSTOMAKE = server fonts rgb
#endif
#if BuildExamples
EXAMPLESDIRS = examples
#endif
        SUBDIRS = config include lib extensions $(SERVERDIRSTOMAKE) \
			clients demos $(EXAMPLESDIRS) util doc
  LNINSTALLDIRS = $(EXTENSIONSRC) $(LIBSRC)

MakeSubdirs($(SUBDIRS))

MakeDirectories(install.ln, $(LINTLIBDIR))

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

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


/**/#
/**/# Watch out!!!  Make sure you do make includes after removing X11....
/**/#
clean::
	$(RM) -r X11

includes::
	$(RM) -r X11


/**/#
/**/# before depending, be sure to have run make includes
/**/#
/* depend::  includes */

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_CREATE = $(DIRS_SERVER) /* $(LINTLIBDIR) */ \
	$(USRLIBDIR) $(BINDIR) $(INCDIR) $(LIBDIR) $(CONFIGDIR) \
	$(DIRS_XINIT) $(DIRS_XDM) $(DIRS_APPDEF) $(DIRS_CONTRIB)

MakeDirectories(install, $(DIRS_TO_CREATE))

MakeDirectories(install.man, $(MANPATH) $(MANDIR) $(LIBMANDIR))
InstallManPage(X,$(MANDIR))
InstallManPageLong(Consortium,$(MANDIR),XConsortium)
InstallManPageLong(Standards,$(MANDIR),XStandards)


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

Everything::
	@echo ""
	@echo "Rebuilding Release 4 of the X Window System"
	@echo ""
	@echo "##############################################################"
	@echo "# Did you remember to check the configuration parameters in  #"
	@echo "# the directory ./config and set BOOTSTRAPCFLAGS if needed?  #"
	@echo "##############################################################"
	@echo ""
	@date
	@echo ""
	cd $(IMAKESRC); $(MAKE) -f Makefile.ini BOOTSTRAPCFLAGS="$(BOOTSTRAPCFLAGS)"
	-$(MV) Makefile Makefile.bak
	$(MAKE) -f Makefile.bak Makefile
	$(MAKE) Makefiles
	$(MAKE) includes
	$(MAKE) depend
	$(MAKE) $(WORLDOPTS)
	@echo ""
	@date
	@echo ""
	@echo "Rebuild of Release 4 of the X Window System complete."
	@echo ""


RELNOTES.PS::  RELNOTES.ms
	tbl RELNOTES.ms | ptroff -t -ms >$@

RELNOTES.lpt:  RELNOTES.ms
	tbl RELNOTES.ms | nroff -ms >$@

RELNOTES.txt:  RELNOTES.ms
	tbl RELNOTES.ms | nroff -ms | colcrt >$@

    RESOLUTION = 75

RELNOTES.dit:  RELNOTES.ms
	tbl RELNOTES.ms | ditroff -TX$(RESOLUTION) -ms >$@

preview::
	xditview '| tbl RELNOTES.ms | ditroff -TX$(RESOLUTION) -ms'


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


InstallSubdirs(config)

/*
 * 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 \! -name RCS -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) -f Makefile.ini clean; $(MAKE) -f Makefile.ini BOOTSTRAPCFLAGS="$(BOOTSTRAPCFLAGS)"
	-$(MV) Makefile Makefile.bak
	$(MAKE) -f Makefile.bak Makefile
	$(MAKE) Makefiles
	cd $(IMAKESRC); $(MAKE) clean

