SubDir TOP ;

MAKE = make ;


## Configure <makefile>
actions Configure {
  cd $(<:D)
  ./configure $(CONFIGURE_ARGS)
}


## Fix <makefile>
actions Fix {
  cd $(<:D)
  fix.bat mingw32
}


## MakeLibrary_ <lib> : <makefile>
actions MakeLibrary_ {
  $(MAKE) -C $(>:D) -f $(>:BS) $(MAKELIBRARY_ARGS)
}

## MakeLibrary <lib> : <makefile>
rule MakeLibrary {
  Depends $(<) : $(>) ;
  MakeLibrary_ $(<) : $(>) ;
}

##--------------------------------------------------------------

## AllegroGL
if ( $(HAVE_ALLEGROGL) = 0 ) {
  Depends all : $(AGL_DEPS) ;

  if ( $(OS) = "UNIX" ) {
    CONFIGURE_ARGS on $(AGL_MAKE) = --disable-shared ;
    Configure $(AGL_MAKE) ;
  }
  else {
    Fix $(AGL_MAKE) ;
  }

  MAKELIBRARY_ARGS on $(AGL_DEPS) = lib ;
  MakeLibrary $(AGL_DEPS) : $(AGL_MAKE) ;
}


## HawkNL
if ( $(HAVE_HAWKNL) = 0 ) {
  Depends all : $(HAWKNL_DEPS) ;
  MakeLibrary $(HAWKNL_DEPS) : $(HAWKNL_MAKE) ;
}


SubInclude TOP src ;
