#
# Copyright (c) 1991 University College London
# All rights reserved.
#
# Redistribution and use in source and binary forms are permitted
# provided that the above copyright notice and this paragraph are
# duplicated in all such forms and that any documentation,
# advertising materials, and other materials related to such
# distribution and use acknowledge that the software was developed
# by the Department of Computer Science, University College London.
# The name of the University may not be used to
# endorse or promote products derived from this software without
# specific prior written permission.
# THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
# WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
#

# Makefile for OSI Management Information Services
#
# By George Pavlou, June 1991

DIR	 =	util compilers $(LT) kernel msap agent proxy manager mibutil \
		examples $(SIMTIME) $(XMP)
PROGDIR =	util compilers agent proxy manager mibutil examples
CMPLDIR =	util compilers

ITARSRC =	-I osimis/I-tar \
		-I osimis/util/I-tar \
		-I osimis/util/util/I-tar \
		-I osimis/util/sntx/I-tar \
		-I osimis/util/progs/I-tar \
		-I osimis/util/security/I-tar \
		-I osimis/compilers/I-tar \
		-I osimis/compilers/mocompiler/I-tar \
		-I osimis/compilers/mocompiler/flex/I-tar \
		-I osimis/compilers/mocompiler/byacc/I-tar \
		-I osimis/compilers/mocompiler/gdmo/I-tar \
		-I osimis/lt/I-tar \
		-I osimis/kernel/I-tar \
		-I osimis/kernel/example/I-tar \
		-I osimis/msap/I-tar \
		-I osimis/agent/I-tar \
		-I osimis/agent/smi/I-tar \
		-I osimis/agent/gms/I-tar \
		-I osimis/agent/isode_mib/I-tar \
		-I osimis/agent/ux_mib/I-tar \
		-I osimis/agent/monmet_mib/I-tar \
		-I osimis/agent/sma/I-tar \
		-I osimis/manager/I-tar \
		-I osimis/manager/general/I-tar \
		-I osimis/manager/browser/I-tar \
		-I osimis/manager/rmib/I-tar \
		-I osimis/manager/rmib/example/I-tar \
		-I osimis/manager/general2/I-tar \
		-I osimis/mibutil/I-tar \
		-I osimis/simtime/I-tar \
		-I osimis/simtime/library/I-tar \
		-I osimis/simtime/example/I-tar \
		-I osimis/examples/I-tar \
		-I osimis/examples/odp/I-tar \
 		-I osimis/proxy/I-tar \
		-I osimis/xmp/I-tar \
		-I osimis/xmp/provide/I-tar \
		-I osimis/xmp/test/I-tar \
		-I osimis/xmp/use/I-tar \
		-I osimis/misode/I-tar \
		-I osimis/misode/tsap/I-tar \
		-I osimis/misode/tsap-7/I-tar \
		-I osimis/misode/tsap-icr1/I-tar \
		-I osimis/misode/mimisc/I-tar \
		-I osimis/proxy/iqa/I-tar \
		-I osimis/proxy/iqa/pma/I-tar \
		-I osimis/proxy/iqa/proxy/I-tar \
		-I osimis/proxy/iqa/snmp/I-tar \
		-I osimis/proxy/iqa/etc/I-tar \
		-I osimis/proxy/iqa/etc/gdmodir/I-tar \
		-I osimis/proxy/iqa/etc/iqadir/I-tar \
		-I osimis/proxy/iqa/imibtool/mibs/I-tar \
		-I osimis/proxy/iqa/imibtool/vtt.gdmo.doc/I-tar \
		-I osimis/proxy/iqa/imibtool/vtt.gdmo.src/I-tar


# the attribute compiler does not work well yet
#		-I osimis/compilers/osimis-pepsy/I-tar \
#		-I osimis/compilers/attrcompiler/I-tar \
#		-I osimis/agent/ux_mibx/I-tar


# the OIM stuff has not been converted to work with the OSIMIS-4
#		-I osimis/util/sys_info/I-tar \
#		-I osimis/agent/oim_mib/I-tar \
#		-I osimis/agent/oim_sma/I-tar \
#		-I osimis/manager/oim/I-tar


TARBIN =	osimis/lib osimis/bin osimis/man


all:;		@for i in $(DIR); \
		    do (echo "cd $$i; ./make all"; \
			      cd $$i; ./make all); \
		    done

cmpl:;		@for i in $(CMPLDIR); \
		    do (echo "cd $$i; ./make all; make install-h"; \
			      cd $$i; ./make all; make install-h); \
		    done

generic:	cmpl glib gprog

install-dirs:   create-etc create-inc create-h create-bin create-lib create-man

lib:		install-dirs cmpl
		@for i in $(DIR); \
		    do (echo "cd $$i; ./make lib"; \
			      cd $$i; ./make lib); \
		    done

glib:		install-dirs cmpl
		@for i in $(DIR); \
		    do (echo "cd $$i; ./make glib"; \
			      cd $$i; ./make glib); \
		    done

prog:		install-dirs cmpl
		@for i in $(PROGDIR); \
		    do (echo "cd $$i; ./make prog"; \
			      cd $$i; ./make prog); \
		    done

gprog:		install-dirs cmpl
		@for i in $(PROGDIR); \
		    do (echo "cd $$i; ./make gprog"; \
			      cd $$i; ./make gprog); \
		    done

install-built:	install-dirs install-etc install-inc install-h-built \
		install-lib-built install-prog-built install-man

install:	install-dirs install-etc install-inc install-h \
		install-lib install-prog install-man

install-g:	install-dirs install-etc install-inc install-gh \
		install-glib install-gprog install-gman

install-etc:	create-etc
		@if [ ! $(ETC) = $(TOP)/etc ]; \
		then \
		    (echo "cd $(TOP)/etc; ./make install"; \
			   cd $(TOP)/etc; ./make install; \
			   cd ..; \
		     echo "cp -r etc/gdmodir $(ETC)"; \
			   cp -r etc/gdmodir $(ETC)); \
		else \
		     echo "$(TOP)/etc in the OSIMIS tree, not installing"; \
		fi

install-inc:	create-inc
		-@if [ ! $(OSIMIS-INC) = $(TOP)/include ]; \
		then \
		    (echo "cp -r include/isode $(OSIMIS-INC)"; \
		           cp -r include/isode $(OSIMIS-INC); \
		     echo "cp -r include/netinet $(OSIMIS-INC)"; \
		           cp -r include/netinet $(OSIMIS-INC); \
		     echo "cp include/netdb-gnu.h $(OSIMIS-INC)"; \
		           cp include/netdb-gnu.h $(OSIMIS-INC); \
		     echo "cp include/time-gnu.h $(OSIMIS-INC)"; \
		           cp include/time-gnu.h $(OSIMIS-INC); \
		     echo "cp include/tkConfig.h $(OSIMIS-INC)"; \
		           cp include/tkConfig.h $(OSIMIS-INC)); \
		else \
		     echo "$(OSIMIS-INC) in the OSIMIS tree, not installing"; \
		fi

install-h-built:	create-h
		-@if [ ! $(H) = $(TOP)/h ]; \
		then \
		    (echo "cp $(TOP)/h/* $(H)"; \
			   cp $(TOP)/h/* $(H)); \
		else \
		     echo "$(H) in the OSIMIS tree, not installing"; \
		fi

install-h:	create-h cmpl
		@for i in $(DIR) syntax; \
		    do (echo "cd $$i; ./make install-h"; \
			      cd $$i; ./make install-h); \
		    done

install-gh:	create-h cmpl
		@for i in $(DIR) syntax; \
		    do (echo "cd $$i; ./make install-gh"; \
			      cd $$i; ./make install-gh); \
		    done

install-lib-built:	create-lib
		-@if [ ! $(LIB) = $(TOP)/lib ]; \
		then \
		    (echo "cp -r $(TOP)/lib/* $(LIB); ranlib $(LIB)/*"; \
			   cp -r $(TOP)/lib/* $(LIB); ranlib $(LIB)/*); \
		else \
		     echo "$(LIB) in the OSIMIS tree, not installing"; \
		fi

install-lib:	create-lib
		@for i in $(DIR); \
		    do (echo "cd $$i; ./make install-lib"; \
			      cd $$i; ./make install-lib); \
		    done

install-glib:	create-lib
		@for i in $(DIR); \
		    do (echo "cd $$i; ./make install-glib"; \
			      cd $$i; ./make install-glib); \
		    done

install-prog-built:	create-bin
		-@if [ ! $(BIN) = $(TOP)/bin ]; \
		then \
		    (echo "strip $(TOP)/bin/*; cp $(TOP)/bin/* $(BIN)"; \
			   strip $(TOP)/bin/*; cp $(TOP)/bin/* $(BIN)); \
		else \
		     echo "$(BIN) in the OSIMIS tree, not installing"; \
		fi

install-prog:	create-bin
		@for i in $(PROGDIR); \
		    do (echo "cd $$i; ./make install-prog"; \
			      cd $$i; ./make install-prog); \
		    done
		@echo "striping symbols from installed binaries"
		-@(cd $(BIN); strip *)

install-gprog:	create-bin
		@for i in $(PROGDIR); \
		    do (echo "cd $$i; ./make install-gprog"; \
			      cd $$i; ./make install-gprog); \
		    done
		@echo "striping symbols from installed binaries"
		-@(cd $(BIN); strip *)

install-man-built:	create-man
		-@if [ ! $(MAN) = $(TOP)/man ]; \
		then \
		    (echo "cp -r $(TOP)/man/* $(MAN)"; \
			   cp $(TOP)/man/* $(MAN)); \
		else \
		     echo "$(MAN) in the OSIMIS tree, not installing"; \
		fi

install-man:	create-man
		@for i in msap $(PROGDIR); \
		    do (echo "cd $$i; ./make install-man"; \
			      cd $$i; ./make install-man); \
		    done

install-gman:	create-man
		@for i in msap $(PROGDIR); \
		    do (echo "cd $$i; ./make install-gman"; \
			      cd $$i; ./make install-gman); \
		    done

create-etc:;	@if test ! -d $(ETC) ; \
		then \
		    echo "creating $(ETC)" ; \
		    mkdir $(ETC) ; \
		fi
		@if test ! -d $(ETC)/gdmodir ; \
		then \
		    echo "creating $(ETC)/gdmodir" ; \
		    mkdir $(ETC)/gdmodir ; \
		fi

create-inc:;	@if test ! -d $(OSIMIS-INC) ; \
		then \
		    echo "creating $(OSIMIS-INC)" ; \
		    mkdir $(OSIMIS-INC) ; \
		fi

create-h:;	@if test ! -d $(H) ; \
		then \
		    echo "creating $(H)" ; \
		    mkdir $(H) ; \
		fi

create-lib:;	@if test ! -d $(LIB) ; \
		then \
		    echo "creating $(LIB)" ; \
		    mkdir $(LIB) ; \
		fi
		@if test ! -d $(LIB)/lint ; \
		then \
		    echo "creating $(LIB)/lint" ; \
		    mkdir $(LIB)/lint ; \
		fi

create-bin:;	@if test ! -d $(BIN) ; \
		then \
		    echo "creating $(BIN)" ; \
		    mkdir $(BIN) ; \
		fi

create-man:;	@if test ! -d $(MAN) ; \
		then \
		    echo "creating $(MAN)" ; \
		    mkdir $(MAN) ; \
		fi
		@echo "cd $(MAN); checking man1, man3, man8 subdirectories"; \
		    cd $(MAN); \
		    if test ! -d man1 ; then mkdir man1 ; fi ; \
		    if test ! -d man3 ; then mkdir man3 ; fi ; \
		    if test ! -d man8 ; then mkdir man8 ; fi

clean:;		@for i in $(DIR); \
		    do (echo "cd $$i; ./make clean"; \
			      cd $$i; ./make clean); \
		    done


tar:;		@( cd ..; echo "tape archiving osimis-4.0..."; \
		tar -cvf osimis/osimis-4.0.tar $(ITARSRC) )

#tar-built:	install-lib install-prog install-man
tar-built:
		@( cd ..; echo "tape archiving osimis-4.0-built..."; \
		tar -cvf osimis/osimis-4.0-built.tar \
		$(TARBIN) $(ITARSRC) )

tar-sbuilt:
		@( cd ..; echo "tape archiving osimis-4.0-sbuilt..."; \
		tar -cvf osimis/osimis-4.0-sbuilt.tar \
		$(TARBIN) )

