/**/###########################################################################
/**/# @(#)XView.rules	1.8 12 May 1993 SMI
/**/# XView.rules for XView release 3.0.  Imake rules needed by distribution.

/*
 ***********************************************************************
 *
 *	Imake rules for XView
 *	*** DO NOT CHANGE ANYTHING BELOW THIS LINE! ***
 *
 ***********************************************************************
 */
/*
 * SubdirNormalLibTarget - create an "all::" target for a library;
 */
#ifndef SubdirNormalLibTarget
#define SubdirNormalLibTarget(libname, objlist)				@@\
AllTarget(lib/**/libname.a)						@@\
									@@\
lib/**/libname.a:: objlist						@@\
	$(AR) $(TARGETDIR)$@ objlist

#endif /* SubdirNormalLibTarget */

/*
 * SubdirProfiledLibTarget - create an "all::" target for a profiled library;
 */
#ifndef SubdirProfiledLibTarget
#define SubdirProfiledLibTarget(libname, objlist)			@@\
AllTarget(lib/**/libname/**/_p.a)					@@\
									@@\
lib/**/libname/**/_p.a:: objlist					@@\
	( cd profiled; $(AR) ../$(TARGETDIR)$@ objlist )

#endif /* SubdirProfiledLibTarget */

/*
 * SubdirDebuggedLibTarget - create an "all::" target for a debugged library;
 */
#ifndef SubdirDebuggedLibTarget
#define SubdirDebuggedLibTarget(libname, objlist)			@@\
AllTarget(lib/**/libname/**/_d.a)					@@\
									@@\
lib/**/libname/**/_d.a:: objlist					@@\
	( cd debugger; $(AR) ../$(TARGETDIR)$@ objlist )

#endif /* SubdirDebuggedLibTarget */

/*
 * SubdirCompoundLibTarget - create an "all::" target for a compound library;
 * --same rule as SubdirNormalLibTarget--compatibility
 */
#ifndef SubdirCompoundLibTarget
#define SubdirCompoundLibTarget(libname, objlist)			@@\
AllTarget(lib/**/libname.a)						@@\
									@@\
lib/**/libname.a:: objlist						@@\
	$(AR) $(TARGETDIR)$@ objlist

#endif /* SubdirCompoundLibTarget */

/* 
 * MakeAnythingSubdirs - go into subdirs to make anything for a given target;
 */
#ifndef MakeAnythingSubdirs
#define MakeAnythingSubdirs(name,dirs)					@@\
name::									@@\
	@case '${MFLAGS}' in *[ik]*) set +e;; esac; \			@@\
	for i in dirs ;\						@@\
	do \								@@\
		(cd $$i ; echo "making name in $$i"; \			@@\
		  $(MAKE) PassCDebugFlags $(MFLAGS) name) || exit $$?; \	@@\
	done

#endif /* MakeAnythingSubdirs */

/*
 * InstallLibraryNoBuild - install a library without first trying to build it;
 * Check if need to do ranlib
 */
#if DoRanlibCmd

#ifndef InstallLibraryNoBuild
#define	InstallLibraryNoBuild(libname,dest)				@@\
install:: 								@@\
	-$(INSTALL) -c $(INSTLIBFLAGS) lib/**/libname.a dest		@@\
	-$(RANLIB) $(RANLIBINSTFLAGS) dest/lib/**/libname.a

#endif /* InstallLibraryNoBuild */

#else /* DoRanlibCmd */

#ifndef InstallLibraryNoBuild
#define	InstallLibraryNoBuild(libname,dest)				@@\
install:: 								@@\
	-$(INSTALL) -c $(INSTLIBFLAGS) lib/**/libname.a dest
#endif /* InstallLibraryNoBuild */

#endif /* DoRanlibCmd */

/*
 * SubdirNormalSharedLibraryTarget - generate rules to create a shared library;
 * do not build it since this is for a subdirectory.  Move the files to the
 * shared library directory for all objects in solist.
 */
#ifndef SubdirNormalSharedLibraryTarget
#define SubdirNormalSharedLibraryTarget(libname,rev,solist,dir,sub)	@@\
AllTarget(lib/**/libname.so.rev)					@@\
									@@\
lib/**/libname.so.rev::  solist						@@\
	-@if [ ! -d dir ]; then mkdir dir; else exit 0; fi		@@\
	@case '${MFLAGS}' in *[i]*) set +e;; esac; \			@@\
	for i in solist; do (set -x; $(CP) sub/$$i dir; $(CP) sub/$$i .) || exit $$?; done

#endif /* SubdirNormalSharedLibraryTarget */

/*
 * SubdirNormalSharedLibraryDataTarget - generate rules to create shlib data file;
 * do not build it since this is for a subdirectory.  Copy the files to the
 * shared library data directory for all objects in salist.  Delete the
 * unneeded data modules from the ./shared directory.
 */
#ifndef SubdirNormalSharedLibraryDataTarget
#define SubdirNormalSharedLibraryDataTarget(libname,rev,salist,dir,sub)	@@\
AllTarget(lib/**/libname.sa.rev)					@@\
									@@\
lib/**/libname.sa.rev::  salist						@@\
	-@if [ ! -d dir ]; then mkdir dir; else exit 0; fi		@@\
	@case '${MFLAGS}' in *[i]*) set +e;; esac; \			@@\
	for i in salist; do \						@@\
	(set -x; $(CP) sub/$$i dir; $(CP) shared/$$i $(SHARED_DIR)) || exit $$?; done

#endif /* SubdirNormalSharedLibraryDataTarget */


/*
 * SubdirBuildNormalSharedLibraryTarget - generate rules to create a shared library;
 * build it into a different name so that the we don't hose people by having
 * the library gone for long periods.  The lib<foo>.so part contains the entire
 * library both text and data modules.  The globally initialized data must be
 * included in both the .so and the .sa parts of the library.
 */
#ifndef SubdirBuildNormalSharedLibraryTarget
#if UseElfFormat == YES
#define SubdirBuildNormalSharedLibraryTarget(libname,rev,solist,sodir)		@@\
AllTarget(lib/**/libname.so.rev)					@@\
									@@\
lib/**/libname.so.rev:: solist 						@@\
	$(RM) $@~ sodir/lib/**/libname.so.xs.o				@@\
	@if [ -f xstrings ]; then \                                     @@\
        	$(RM) strings; $(CP) xstrings strings; fi               @@\
	(cd sodir; $(CC) -o ../$@~ $(SHLIBLDFLAGS) ?*.o) || exit $$?	@@\
	-@if [ -f strings~ ]; then $(RM) strings~; else exit 0; fi	@@\
	$(RM) $@  							@@\
	$(MV) $@~ $@							@@\
									@@\
clean::									@@\
	$(RM) lib/**/libname.so.rev sodir/?*.o strings*

#else
#define SubdirBuildNormalSharedLibraryTarget(libname,rev,solist,sodir)		@@\
AllTarget(lib/**/libname.so.rev)					@@\
									@@\
lib/**/libname.so.rev:: solist 						@@\
	$(RM) $@~ sodir/lib/**/libname.so.xs.o				@@\
	@if [ -f xstrings ]; then \                                     @@\
        	$(RM) strings; $(CP) xstrings strings; fi               @@\
	(cd sodir; $(LD) -o ../$@~ $(SHLIBLDFLAGS) ?*.o) || exit $$?	@@\
	-@if [ -f strings~ ]; then $(RM) strings~; else exit 0; fi	@@\
	$(RM) $@  							@@\
	$(MV) $@~ $@							@@\
									@@\
clean::									@@\
	$(RM) lib/**/libname.so.rev sodir/?*.o strings*

#endif
#endif /* SubdirBuildNormalSharedLibraryTarget */

/*
 * SubdirBuildSortedSharedLibraryTarget - rules to create a sorted shlib;
 * build it into a different name so that the we don't hose people by having
 * the library gone for long periods.  The lib<foo>.so part contains the entire
 * library both text and data modules.  The globally initialized data must be
 * included in both the .so and the .sa parts of the library.  Must have the
 * sorting script and a list of objects to sort.
 */
#ifndef SubdirBuildSortedSharedLibraryTarget
#define SubdirBuildSortedSharedLibraryTarget(libname,rev,solist,sodir,objsort,objlist) @@\
AllTarget(lib/**/libname.so.rev)					@@\
									@@\
lib/**/libname.so.rev:: solist 						@@\
	$(RM) $@~ sodir/lib/**/libname.so.xs.o				@@\
	@if [ -f xstrings ]; then \                                     @@\
        	$(RM) strings; $(CP) xstrings strings; fi               @@\
	-@if [ ! -x objsort ];then $(CHMOD) 755 objsort;else exit 0;fi	@@\
	$(LD) `objsort objlist sodir` -o $@~ $(SHLIBLDFLAGS) 		@@\
	@if [ -f strings~ ]; then $(RM) strings~; else exit 0; fi	@@\
	$(RM) $@  							@@\
	$(MV) $@~ $@							@@\
									@@\
clean::									@@\
	$(RM) lib/**/libname.so.rev sodir/?*.o strings* xstrings*

#endif /* SubdirBuildSortedSharedLibraryTarget */

/*
 * SubdirBuildNormalSharedLibraryDataTarget - generate rules to create shlib data file;
 * Do not use xstr or pic on the data file segments.
 * The lib<foo>.sa part defines the interface for globally initialized data.
 * Check if ranlib is needed.
 */
#if DoRanlibCmd

#ifndef SubdirBuildNormalSharedLibraryDataTarget
#define SubdirBuildNormalSharedLibraryDataTarget(libname,rev,sadir)	@@\
AllTarget(lib/**/libname.sa.rev)					@@\
									@@\
lib/**/libname.sa.rev::  						@@\
	$(RM) $@~							@@\
	(cd sadir; $(AR) ../$@~ ?*.o) || exit $$?			@@\
	$(RM) $@ 							@@\
	$(MV) $@~ $@							@@\
	$(RANLIB) $@							@@\
									@@\
clean::									@@\
	$(RM) lib/**/libname.sa.rev sadir/?*.o

#endif /* SubdirBuildNormalSharedLibraryDataTarget */

#else /* DoRanlibCmd */

#ifndef SubdirBuildNormalSharedLibraryDataTarget
#define SubdirBuildNormalSharedLibraryDataTarget(libname,rev,sadir)	@@\
AllTarget(lib/**/libname.sa.rev)					@@\
									@@\
lib/**/libname.sa.rev::  						@@\
	$(RM) $@~							@@\
	(cd sadir; $(AR) ../$@~ ?*.o) || exit $$?			@@\
	$(RM) $@ 							@@\
	$(MV) $@~ $@							@@\
									@@\
clean::									@@\
	$(RM) lib/**/libname.sa.rev sadir/?*.o

#endif /* SubdirBuildNormalSharedLibraryDataTarget */

#endif /* DoRanlibCmd */

/*
 * SubdirSharedLibraryObjectRule - generate make rules to build 
 * "normal" SunOS style shared object files.  XView absolutely requires
 * the use of xstr to build a shared library; otherwise, the library will
 * overflow the GLOBAL_OFFSET_TABLE for some architectures.
 */
#ifndef SubdirSharedLibraryObjectRule
#define SubdirSharedLibraryObjectRule()					@@\
all::									@@\
	-@if [ ! -d shared ]; then mkdir shared; else exit 0; fi	@@\
	-@if [ ! -f $(XSTR_STRINGS_FILE) ]; then \                      @@\
		touch $(XSTR_STRINGS_FILE);  else exit 0; fi            @@\
	-@if [ ! -f strings ]; then \                                   @@\
		$(LN) $(XSTR_STRINGS_FILE) strings; else exit 0; fi     @@\
									@@\
.c.o:									@@\
	$(RM) $@ shared/$@						@@\
	$(CC) -c $(PIC) $(SHAREDCODEDEF) \                              @@\
		$(SHLIBDEF) $(CFLAGS) $(STRCONST) $*.c			@@\
	$(CP) $*.o shared/$*.o						@@\
									@@\
clean::									@@\
	$(RM) strings*							@@\
	-@if [ -d shared ]; then echo "	$(RM) shared/?*.o"; \		@@\
		$(RM) shared/?*.o; else exit 0; fi			@@\

#endif /* SubdirSharedLibraryObjectRule */

/*
 * SubdirSharedAndDebuggedLibraryObjectRule - generate make rules to
 * build shared, debuggable, and "normal" object files.
 */
#ifndef SubdirSharedAndDebuggedLibraryObjectRule
#define SubdirSharedAndDebuggedLibraryObjectRule()			@@\
all::									@@\
	-@if [ ! -d shared ]; then mkdir shared; else exit 0; fi	@@\
	-@if [ ! -f $(XSTR_STRINGS_FILE) ]; then \                      @@\
		touch $(XSTR_STRINGS_FILE);  else exit 0; fi            @@\
	-@if [ ! -f strings ]; then \                                   @@\
		$(LN) $(XSTR_STRINGS_FILE) strings; else exit 0; fi     @@\
	-@if [ ! -d debugger ]; then mkdir debugger; else exit 0; fi	@@\
									@@\
.c.o:									@@\
	$(RM) $@ shared/$@ debugger/$@					@@\
	$(CC) -c -g $(SHLIBDEF) $(CFLAGS) $(STRCONST) $*.c		@@\
	$(CP) $*.o debugger/$*.o					@@\
	$(CC) -c $(PIC) $(SHAREDCODEDEF) \                              @@\
		$(SHLIBDEF) $(CFLAGS) $(STRCONST) $*.c			@@\
	$(CP) $*.o shared/$*.o						@@\
									@@\
clean::									@@\
	$(RM) strings*                                                  @@\
	-@if [ -d shared ]; then echo "	$(RM) shared/?*.o"; \		@@\
		$(RM) shared/?*.o; else exit 0; fi			@@\
	-@if [ -d debugger ]; then echo "	$(RM) debugger/?*.o"; \ @@\
		$(RM) debugger/?*.o; else exit 0; fi			@@\

#endif /* SubdirSharedAndDebuggedLibraryObjectRule */

/*
 * SubdirSpecialSharedAndDebuggedObjectRule - generate rules to compile a file 
 * with special flags and to make shared and debuggable versions.
 * This rule does not use xstr so it may be used for data modules.
 */
#ifndef SubdirSpecialSharedAndDebuggedObjectRule
#define	SubdirSpecialSharedAndDebuggedObjectRule(objs,depends,options)	@@\
all::									@@\
	-@if [ ! -d shared ]; then mkdir shared; else exit 0; fi	@@\
	-@if [ ! -d debugger ]; then mkdir debugger; else exit 0; fi	@@\
									@@\
objs:	depends								@@\
	$(RM) $@ shared/$@ debugger/$@					@@\
	$(CC) $(PIC) -c $(SHAREDCODEDEF) $(SHLIBDEF) $(CFLAGS) options $*.c @@\
	$(CP) $*.o shared/$*.o						@@\
	$(CC) -g -c $(SHLIBDEF) $(CFLAGS) options $*.c			@@\
	$(CP) $*.o debugger/$*.o					@@\
	$(CC) -c $(SHLIBDEF) $(CFLAGS) options $*.c

#endif /* SubdirSpecialDebuggedAndProfiledObjectRule */

/*
 * SubdirSpecialSharedObjectRule - generate rules to compile a file 
 * with special flags and to make shared versions.
 * This rule does not use xstr so it may be used for data modules.
 */
#ifndef SubdirSpecialSharedObjectRule
#define	SubdirSpecialSharedObjectRule(objs,depends,options)		@@\
all::									@@\
	-@if [ ! -d shared ]; then mkdir shared; else exit 0; fi	@@\
									@@\
objs:	depends								@@\
	$(RM) $@ shared/$@ 						@@\
	$(CC) $(PIC) -c $(SHAREDCODEDEF) $(SHLIBDEF) $(CFLAGS) options $*.c @@\
	$(CP) $*.o shared/$*.o						@@\
	$(CC) -c $(SHLIBDEF) $(CFLAGS) options $*.c

#endif /* SubdirSpecialSharedObjectRule */

/*
 * AssemblerObjectRule - generate an object rule for assembler sources
 */
#ifndef AssemblerObjectRule
#define AssemblerObjectRule(objs,depends)				@@\
									@@\
objs:	depends								@@\
	$(AS) $(AFLAGS) $*.s -o $*.o 

#endif /* AssemblerObjectRule */

/*
 * InstallSharedLibraryDataNoBuild - rules to install the shared library data
 * Check if ranlib is needed
 */
#if DoRanlibCmd

#ifndef InstallSharedLibraryDataNoBuild
#define	InstallSharedLibraryDataNoBuild(libname,rev,dest)		@@\
install:: 								@@\
	-$(INSTALL) -c $(INSTSHAREDLIBFLAGS) lib/**/libname.sa.rev dest	@@\
	-$(RANLIB) $(RANLIBINSTFLAGS) dest/lib/**/libname.sa.rev
	

#endif /* InstallSharedLibraryDataNoBuild */

#else /* DoRanlibCmd */

#ifndef InstallSharedLibraryDataNoBuild
#define	InstallSharedLibraryDataNoBuild(libname,rev,dest)		@@\
install:: 								@@\
	-$(INSTALL) -c $(INSTSHAREDLIBFLAGS) lib/**/libname.sa.rev dest

#endif /* InstallSharedLibraryDataNoBuild */

#endif /* DoRanlibCmd */

/*
 * InstallSharedLibraryNoBuild - generate rules to install the shared library.
 */
#ifndef InstallSharedLibraryNoBuild
#define	InstallSharedLibraryNoBuild(libname,rev,dest)				@@\
install::  								@@\
	$(RM) /dest/lib/**/libname.so                                   @@\
	$(INSTALL) -c $(INSTSHAREDLIBFLAGS) lib/**/libname.so.rev dest	@@\
	(cd dest; $(LN) lib/**/libname.so.rev lib/**/libname.so) || exit $$?

#endif /* InstallSharedLibraryNoBuild */

/*
 * SubdirLintLibraryTarget - rules to build a lint library when have subdirs;
 */
#ifndef SubdirLintLibraryTarget
#define SubdirLintLibraryTarget(libname,destdir,srcs)			@@\
lintlib::								@@\
	-@if [ ! -d destdir ]; then mkdir destdir; else exit 0; fi	@@\
	$(RM) ?*.ln;							@@\
	@case '${MFLAGS}' in *[ik]*) set +e;; esac; \			@@\
	for i in srcs ;\						@@\
	do \								@@\
		echo "linting $$i"; \					@@\
		$(LINT) $(LINTFLAGS) -i -c $$i; \ 			@@\
		if [ ! -f ?*.ln ]; then \				@@\
			echo "lint failed for $$i"; \			@@\
		else \							@@\
			$(MV) ?*.ln destdir; \				@@\
		fi \							@@\
	done
#endif /* SubdirLintLibraryTarget */


/*
 * SubdirLintLibraryBuild - rules to create a lint library with subdirs;
 * Note that the lint library is always forced to be newer than the library 
 * itself.
 */
#ifndef SubdirLintLibraryBuild
#define	SubdirLintLibraryBuild(libname,lintdir)				@@\
lintlib:: llib-l/**/libname.ln						@@\
									@@\
llib-l/**/libname.ln: 							@@\
	$(RM) $@							@@\
	$(LINT) $(LINTLIBFLAG)/**/libname $(LINTFLAGS) lintdir/?*.ln	@@\
									@@\
clean::									@@\
	$(RM) llib-l/**/libname.ln					@@\
	$(RM) lint/?*.ln						@@\
									@@\
install.ln:: lintlib
#endif /* LintLibraryBuild */

/*
 * PopulateSCCSTree - rule to populate build tree from an SCCS archive
 */
#ifndef PopulateSCCSTree
#define PopulateSCCSTree(type,srcs)					@@\
populate::								@@\
	@case '${MFLAGS}' in *[i]*) set +e;; esac; 			@@\
	-@if [ -type SCCS ]; then \					@@\
		for i in srcs ; do sccs get $$i ; done ; \		@@\
	elif [ -type SCCS- ]; then \					@@\
		$(MV) SCCS- SCCS ; \					@@\
		for i in srcs ; do sccs get $$i ; done ; \		@@\
		$(MV) SCCS SCCS- ; \					@@\
	else \								@@\
		echo "SCCS or SCCS- do not exist" ; \			@@\
	fi
#endif /* PopulateSCCSTree */

/*
 * PopulateSubdirs - generate rules to recursively populate a source tree.
 */
#ifndef PopulateSubdirs
#define PopulateSubdirs(dirs)						@@\
NamedTargetSubdirs(populate,dirs,"populating", /**/,populate)
#endif /* PopulateSubdirs */

/*
 * LinkToFile - rule to make a link to one file
 */
#ifndef LinkToFile
#define LinkToFile(step,filename,linkname,dir)				@@\
step:: filename								@@\
	@case '${MFLAGS}' in *[i]*) set +e;; esac; 			@@\
	-@if [ ! -f dir/linkname ]; then \				@@\
		echo "linking dir/linkname to filename..." \		@@\
		echo "  cd" dir; cd dir ; $(RM) linkname ; \		@@\
		(set -x; $(LN) filename linkname) || exit $$?; \	@@\
	else \								@@\
		echo "dir/linkname exists, no link made." ; \		@@\
	fi
#endif /* LinkToFile */

/*
 * StartNamedTarget - rule to enter a directory and start a target
 */
#ifndef StartNamedTarget
#define StartNamedTarget(step,dir,flags)				@@\
step:: 									@@\
	(cd dir ; $(MAKE) $(MFLAGS) flags step ) || exit $$?;
#endif /* StartNamedTarget */

/*
 * InstallSupportList - rule to install a list of support files
 */
#ifndef InstallSupportList
#define InstallSupportList(srcs,dest)					@@\
install::								@@\
	@case '${MFLAGS}' in *[i]*) set +e;; esac; 			@@\
	for i in srcs ;\						@@\
	do \								@@\
		echo "installing $$i"; \				@@\
		$(RM) dest/$$i dest/.$$i; \				@@\
		$(INSTALL) -c $(INSTDATFLAGS) $$i dest ; \ 		@@\
		( cd dest; $(MV) $$i .$$i; $(LN) .$$i $$i ) || exit $$?; \ @@\
	done
#endif /* InstallSupportList */

/*
 * InstallNonExecList - rule to install a list of help files
 */
#ifndef InstallNonExecList
#define InstallNonExecList(srcs,dest)					@@\
install::								@@\
	@case '${MFLAGS}' in *[i]*) set +e;; esac; 			@@\
	for i in srcs ;\						@@\
	do \								@@\
		echo "installing $$i"; \				@@\
		$(RM) dest/$$i ; \					@@\
		$(INSTALL) -c $(INSTDATFLAGS) $$i dest ; \ 		@@\
	done
#endif /* InstallNonExecList */

/*
 * InstallExampleSrcs - rule to install example sources.
 */
#ifndef InstallExampleSrcs
#define InstallExampleSrcs(files,makefile,dest)				@@\
install.srcs::								@@\
	@case '${MFLAGS}' in *[i]*) set +e;; esac; 			@@\
	for i in files ;\						@@\
	do \								@@\
		echo "installing $$i"; \				@@\
		$(RM) dest/$$i ; \					@@\
		$(INSTALL) -c $(INSTDATFLAGS) $$i dest ; \ 		@@\
	done 								@@\
	$(RM) dest/Makefile ;		 				@@\
	$(INSTALL) -c $(INSTDATFLAGS) makefile dest/Makefile 
#endif /* InstallExampleSrcs */

/*
 * InstallExampleSrcsNoMakefile - rule to install example sources that
 * do not have Makefiles.
 */
#ifndef InstallExampleSrcsNoMakefile
#define InstallExampleSrcsNoMakefile(files,dest)			@@\
install.srcs::								@@\
	@case '${MFLAGS}' in *[i]*) set +e;; esac; 			@@\
	for i in files ;\						@@\
	do \								@@\
		echo "installing $$i"; \				@@\
		$(RM) dest/$$i ; \					@@\
		$(INSTALL) -c $(INSTDATFLAGS) $$i dest ; \ 		@@\
	done 
#endif /* InstallExampleSrcsNoMakefile */

/*
 * InstallSrcsSubdirs - generate rules to recursively install sources.
 */
#ifndef InstallSrcsSubdirs
#define InstallSrcsSubdirs(dirs)					@@\
NamedTargetSubdirs(install.srcs,dirs,"installing srcs", /**/,install.srcs)
#endif /* InstallSrcsSubdirs */

