#*=====================================================================*/
#*    serrano/prgm/project/bigloo/api/Makefile                         */
#*    -------------------------------------------------------------    */
#*    Author      :  Manuel Serrano                                    */
#*    Creation    :  Thu Mar 24 05:30:44 2005                          */
#*    Last change :  Mon Jun 20 09:30:42 2005 (serrano)                */
#*    Copyright   :  2005 Manuel Serrano                               */
#*    -------------------------------------------------------------    */
#*    The API Makefile                                                 */
#*=====================================================================*/

#*---------------------------------------------------------------------*/
#*    The default configuration                                        */
#*---------------------------------------------------------------------*/
include ../Makefile.config

#*---------------------------------------------------------------------*/
#*    DIRECTORIES                                                      */
#*---------------------------------------------------------------------*/
DIRECTORIES = fthread pthread mail ssl web

#*---------------------------------------------------------------------*/
#*    Booting on a bare system                                         */
#*---------------------------------------------------------------------*/
boot: boot-c boot-jvm boot-dotnet

fullbootstrap:
	@ for d in $(APIS) ; do \
            (cd $$d && $(MAKE) boot) || exit 1; \
	  done

boot-c:
	@ for d in $(APIS) ; do \
	    echo "[0m[1;33m$$d:[0m"; \
            (cd $$d && $(MAKE) boot-c) || exit 1; \
          done;

boot-jvm:
	@ for d in $(APIS) ; do \
            if [ "$(JVMBACKEND)" = "yes" ]; then \
	      echo "[0m[1;33m$$d:[0m"; \
              (cd $$d && $(MAKE) boot-jvm) || exit 1; \
            fi; \
          done;

boot-dotnet:
	@ for d in $(APIS) ; do \
            if [ "$(DOTNETBACKEND)" = "yes" ]; then \
	      echo "[0m[1;33m$$d:[0m"; \
              (cd $$d && $(MAKE) boot-dotnet) || exit 1; \
            fi \
          done;

#*---------------------------------------------------------------------*/
#*    clean                                                            */
#*---------------------------------------------------------------------*/
.PHONY: clean cleanall distclean

clean:
	@ for d in $(DIRECTORIES) ; do \
             (cd $$d && $(MAKE) clean); \
          done;

cleanall: 
	@ for d in $(DIRECTORIES) ; do \
             (cd $$d && $(MAKE) cleanall); \
          done;

distclean: 
	@ for d in $(DIRECTORIES) ; do \
             (cd $$d && $(MAKE) distclean); \
          done;

#*---------------------------------------------------------------------*/
#*    install & uninstall                                              */
#*---------------------------------------------------------------------*/
.PHONY: install install-init install-c install-jvm install-dotnet uninstall

install: install-init
	@ $(MAKE) install-c
	@ if [ "$(JVMBACKEND)" = "yes" ]; then \
             $(MAKE) install-jvm; \
          fi
	@ if [ "$(DOTNETBACKEND)" = "yes" ]; then \
             $(MAKE) install-dotnet; \
          fi

install-init:
	@ for d in $(APIS) ; do \
            (cd $$d && $(MAKE) install-init); \
          done;

install-c:
	@ for d in $(APIS) ; do \
            (cd $$d && $(MAKE) install-c); \
          done;

install-jvm:
	@ for d in $(APIS) ; do \
            (cd $$d && $(MAKE) install-jvm); \
          done;

install-dotnet:
	@ for d in $(APIS) ; do \
            (cd $$d && $(MAKE) install-dotnet); \
          done;

uninstall:
	@ for d in $(APIS) ; do \
            (cd $$d && $(MAKE) uninstall); \
          done;

#*---------------------------------------------------------------------*/
#*    Populating the APIs                                              */
#*---------------------------------------------------------------------*/
pop: 
	@ for d in $(DIRECTORIES) ; do \
             for f in `cd $$d && $(MAKE) -s pop;`; do \
                echo api/$$f; \
             done; \
          done;
	@ echo api/Makefile

#*---------------------------------------------------------------------*/
#*    distrib                                                          */
#*    -------------------------------------------------------------    */
#*    Prepare for a distribution                                       */
#*---------------------------------------------------------------------*/
distrib: 
	@ if [ `pwd` = $(BOOTDIR)/api ]; then \
             echo "*** ERROR:Illegal dir to make a distrib `pwd`"; \
             exit 1; \
          fi
	@ for d in $(DIRECTORIES); do \
             if [ -d $$d ]; then \
               (cd $$d && $(MAKE) ude); \
             fi; \
          done;
	@ $(RM) -f api/Makefile~

