#ident "%W% %G%"
 
# Copyright (C) 1994 Kubota Graphics Corp.
# 
# Permission to use, copy, modify, and distribute this material for
# any purpose and without fee is hereby granted, provided that the
# above copyright notice and this permission notice appear in all
# copies, and that the name of Kubota Graphics not be used in
# advertising or publicity pertaining to this material.  Kubota
# Graphics Corporation MAKES NO REPRESENTATIONS ABOUT THE ACCURACY
# OR SUITABILITY OF THIS MATERIAL FOR ANY PURPOSE.  IT IS PROVIDED
# "AS IS", WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE AND KUBOTA GRAPHICS CORPORATION DISCLAIMS ALL WARRANTIES,
# EXPRESS OR IMPLIED.
 
SHELL=/bin/sh

CCCOM= $(CC) -DERRCHK $(CFLAGS)
LDCOM= $(LD) $(LDFLAGS)
OBJ_PATH= $(DORE_LOC)/dore/obj/$(DORE_OBJTYPE)
LIB_PATH= $(DORE_LOC)/dore/lib/$(DORE_OBJTYPE)

GENERIC_DIRS = C_interface/user C_interface/user/pri \
             C_interface/user/misc C_interface/user/studio \
             C_interface/user/geoatt C_interface/user/userext \
             C_interface/user/map C_interface/user/priatt \
             C_interface/user/studioatt C_interface/user/system \
             C_interface/developer objs/pri objs/device objs/glbatt \
             objs/studio objs/geoatt objs/misc objs/map objs/view \
             objs/frame objs/group objs/priatt objs/studioatt subsys \
             subsys/obj subsys/system subsys/render subsys/pick util  \
             radiosity
 

SCCS_DIRS =  C_interface objs subsys util doresys_config render_config \
             device_config fortran_config os_config


##################################################################

compile:
	@ for dir in $(GENERIC_DIRS); do			\
	     echo "Processing `pwd`/$$dir";			\
	     (cd $$dir; $(MAKE) -$(MAKEFLAGS) compile);		\
	done
	@ (cd doresys_config;					\
	echo "Processing `pwd`";				\
	$(MAKE) -$(MAKEFLAGS) compile;)
	@ (cd device_config;					\
	for dir in $(DORE_DEVS) ; do				\
	    echo "Processing `pwd`/$$dir";			\
	    (cd $$dir; $(MAKE) -$(MAKEFLAGS) compile);  	\
	 done)
	@ (cd render_config;					\
	for dir in $(DORE_RNDS) ; do				\
	    echo "Processing `pwd`/$$dir";			\
	    (cd $$dir; $(MAKE) -$(MAKEFLAGS) compile);  	\
	done)	
	@ (cd fortran_config/$(DORE_FORTRAN);			\
	echo "Processing `pwd`";				\
	$(MAKE) -$(MAKEFLAGS) compile;)
	@ (cd os_config/$(DORE_OS);				\
	echo "Processing `pwd`";				\
	$(MAKE) -$(MAKEFLAGS) compile;) 

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #

library: 
	@ for dir in $(GENERIC_DIRS); do			\
	    echo "Processing `pwd`/$$dir";			\
	    (cd $$dir; $(MAKE) -$(MAKEFLAGS) library);		\
	done
	@ (cd doresys_config;					\
	echo "Processing `pwd`";				\
	$(MAKE) -$(MAKEFLAGS) library;)
	@ (cd device_config;					\
	for dir in $(DORE_DEVS) ; do				\
	    echo "Processing `pwd`/$$dir";			\
	    (cd $$dir; $(MAKE) -$(MAKEFLAGS) library);  	\
	done)
	@ (cd render_config;					\
	for dir in $(DORE_RNDS) ; do				\
	    echo "Processing `pwd`/$$dir";			\
	    (cd $$dir; $(MAKE) -$(MAKEFLAGS) library);  	\
	done)
	@ (cd fortran_config/$(DORE_FORTRAN);			\
	echo "Processing `pwd`";				\
	$(MAKE) -$(MAKEFLAGS) library;)
	@ (cd os_config/$(DORE_OS);				\
	echo "Processing `pwd`";				\
	$(MAKE) -$(MAKEFLAGS) library;) 
	@ if [ -n "$(DORE_LIBTOC)" ]; then			\
            echo "$(DORE_LIBTOC) $(LIB_PATH)/$(DORE_LIB_NAME)"; \
            $(DORE_LIBTOC) $(LIB_PATH)/$(DORE_LIB_NAME) ; 	\
	fi

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #

clean:
	@ for dir in $(GENERIC_DIRS); do			\
	     echo "Processing `pwd`/$$dir";			\
	     (cd $$dir; $(MAKE) -$(MAKEFLAGS) clean);		\
	done
	@ (cd doresys_config;					\
	echo "Processing `pwd`";				\
	$(MAKE) -$(MAKEFLAGS) clean;)
	@ (cd device_config;					\
	for dir in $(DORE_DEVS) ; do				\
	    echo "Processing `pwd`/$$dir";			\
	    (cd $$dir; $(MAKE) -$(MAKEFLAGS) clean);  		\
	done)
	@ (cd render_config;					\
	for dir in $(DORE_RNDS) ; do				\
	    echo "Processing `pwd`/$$dir";			\
	    (cd $$dir; $(MAKE) -$(MAKEFLAGS) clean);  		\
	done)
	@ (cd fortran_config/$(DORE_FORTRAN);			\
	echo "Processing `pwd`";				\
	$(MAKE) -$(MAKEFLAGS) clean;)
	@ (cd os_config/$(DORE_OS);				\
	echo "Processing `pwd`";				\
	$(MAKE) -$(MAKEFLAGS) clean;) 

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #

#	For every subdirectory that contains a makefile 
#	(and therefore .c files):
#	    Make an SCCS directory.
#	    Comment out any #ident lines that might be in the files.
#	    Add an #ident line to each file.
#	    Create the sccs files.
#	    Check out a readonly version of the files.
#		
sccs:
	@(PATH=$${PATH}:/usr/sccs ; export PATH;		\
	cd $(DORE_LOC)/dore/src;				\
	for dir in `find $(SCCS_DIRS) -type d -print`; do       \
	    if [ -f $$dir/makefile ] ; then			\
		echo "Processing `pwd`/$$dir"; 			\
	        (cd $$dir;					\
	        if [ ! -d SCCS ]; then				\
	    	    mkdir -p SCCS;					\
		fi;						\
		for i in `ls *`; do				\
		    if [ -f $$i ]; then				\
		        if [ -f SCCS/s.$$i ]; then		\
		            echo "SCCS/s.$$i already exists";	\
		        else					\
			    echo "$$i:";			\
			    echo \#ident \"\%W\%\" \%G\%  > /tmp/1$$$$;	\
			    if [ $$i != makefile ]; then 	\
			    	sed "/^#ident/ s%^\(.*\)%/\* \1\ */%" $$i > /tmp/2$$$$;\
			    else				\
			    	sed "/^#ident/ s/^\(.*\)/## \1\ ##/" $$i > /tmp/2$$$$;\
			    fi;					\
			    chmod 644 $$i;			\
			    cat /tmp/1$$$$ /tmp/2$$$$ > $$i;	\
		    	    admin -n -i$$i SCCS/s.$$i;		\
			    chmod 444 $$i;			\
		    	    get SCCS/s.$$i;			\
			    /bin/rm -f /tmp/1$$$$ /tmp/2$$$$;	\
			fi;					\
		    fi;						\
		done);						\
	    fi;							\
	done )

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #

FORCE_IT:
