COMM       @(#)$RCSfile: Imakefile,v $ $Revision: 1.34 $ $Date: 2009/02/18 23:14:09 $ CERN IT-PDP/DM Jean-Philippe Baud
COMM
COMM  Copyright (C) 1990-2008 by CERN/IT/PDP/DM
COMM  All rights reserved
COMM

COMM		Make DPM/LFC libraries and executables

#include <Project.tmpl>

include VERSION
#if BuildNameServerAsLFC
PACKAGE = LFC
#else
#if BuildNameServerAsDPNS
PACKAGE = DPM
#else
PACKAGE = lcg-dm-common
#endif
#endif

#if UseOracle
SPECFILE = $(PACKAGE)-oracle.spec
#else
#if UsePostgres
SPECFILE = $(PACKAGE)-postgres.spec
#else
SPECFILE = $(PACKAGE).spec
#endif
#endif

SUBDIRS = h $(LIBDIR) $(SHLIBDIR) $(COMMONDIR) $(NSDIR) $(RFIODIR) $(DPMDIR) \
	  $(SRMV1DIR) $(SRMV2DIR) $(SRMV2_2DIR) $(SECURITYDIR) $(DLIDIR) \
	  $(DICOMCOPYDIR) $(DPMCOPYDIR)
#if BuildSecurity
SECURITY = sec
#endif
distdir = $(PACKAGE)-$(VERSION)
sources = Imakefile Makefile.ini Makefile.ini.Win32 README VERSION \
	config test setosflags configure doc scripts $(SUBDIRS)

EXPORTSUBDIRS = $(LIBDIR) $(SHLIBDIR) $(COMMONDIR) $(NSDIR) h

DEPENDDIRS = $(COMMONDIR) $(NSDIR) $(RFIODIR) $(DPMDIR) $(SRMV1DIR) $(SRMV2DIR) \
	     $(SRMV2_2DIR) $(SECURITYDIR) $(DLIDIR) $(DICOMCOPYDIR) $(DPMCOPYDIR)

EXPORTBIN=$(EXPORT)/bin
EXPORTSBIN=$(EXPORT)/sbin
EXPORTLIB=$(EXPORT)/lib
EXPORTINC=$(EXPORTSHR)/include
EXPORTH=$(EXPORTINC)/shift

MakeSubdirs(all,$(SUBDIRS))
MakeSubdirs(install,$(SUBDIRS))
MakeSubdirs(install.man,$(SUBDIRS))
MakeSubdirs(clean,$(SUBDIRS))
MakeSubdirs(clobber,$(SUBDIRS))

export:
	(if [ "x$(EXPORT)" = "x" ] ; \
	 then \
	 echo "EXPORT must be set (thru make or environment)" ; exit 1 ; \
	 else \
	 echo "exporting to $(EXPORT)" ; \
	fi ; \
	for i in $(EXPORTSUBDIRS) ;\
	do (echo " $$i (EXPORT):" ; cd $$i ; \
	    $(MAKE) $(MFLAGS) EXPORTSBIN=$(EXPORTSBIN) EXPORTBIN=$(EXPORTBIN) EXPORTLIB=$(EXPORTLIB) $@ ; \
	 ) ; done ; \
	) ;

exportman:
	(if [ "x$(EXPORTMAN)" = "x" ] ; \
	 then \
	 echo "EXPORTMAN must be set (thru make or environment)" ; exit 1 ; \
	 else \
	 echo "exporting to $(EXPORTMAN)" ; \
	fi ; \
	for i in $(EXPORTSUBDIRS) ;\
	do (echo " $$i (EXPORTMAN):" ; cd $$i ; \
	    $(MAKE) $(MFLAGS) EXPORTMAN=$(EXPORTMAN) $@ ; \
	 ) ; done ; \
	) ;

exportshr:
	(if [ "x$(EXPORTSHR)" = "x" ] ; \
	 then \
	 echo "EXPORTSHR must be set (thru make or environment)" ; exit 1 ; \
	 else \
	 echo "exporting to $(EXPORTSHR)" ; \
	fi ; \
	for i in $(EXPORTSUBDIRS) ;\
	do (echo " $$i (EXPORTSHR):" ; cd $$i ; \
	    $(MAKE) $(MFLAGS) EXPORTSHR=$(EXPORTSHR) EXPORTINC=$(EXPORTINC) EXPORTH=$(EXPORTH) $@ ; \
	 ) ; done ; \
	) ;

#if defined(_WIN32)
test: Makefiles
	cd test & $(MAKE) all & cd ..

Makefiles:
	@for %i in ( $(SUBDIRS) test ) \
	do @(echo %i - & cd %i & \
		imake -Ui386 -I..\config ; \
		$(MAKE) $(MFLAGS) $@ & cd .. )

depend:
	@echo Not supported on this platform
#else
test: Makefiles
	(cd test; $(MAKE) all)

Makefiles:
	@. ./setosflags ;\
	for i in $(SUBDIRS) test ;\
	do (echo " $$i:" ; cd $$i ;\
		imake -I../config -DOSMajorVersion="$$OSMAJNO" -DOSMinorVersion="$$OSMINNO" ;\
		$(MAKE) $(MFLAGS) $@ \
	) ; done ;

depend:
	for i in $(DEPENDDIRS) test ;\
	do (echo " $$i:" ; cd $$i ;\
		$(MAKE) $(MFLAGS) $@ \
	) ; done ;

dist:
	-rm -rf $(distdir)
	mkdir $(distdir)
	-cp -rp $(sources) $(distdir)
	tar cvzf $(distdir).src.tar.gz $(distdir)
	-rm -rf $(distdir)

OS=$(shell scripts/get-platform-os)

rpm:
	$(MAKE) -C rpm rpm-$(PACKAGE)-mysql

rpm-oracle : 
	$(MAKE) -C rpm rpm-$(PACKAGE)-oracle

rpm-postgres : 
	$(MAKE) -C rpm rpm-$(PACKAGE)-postgres

#endif
