ssdir = SuiteSparse
sslib = $(sslib1) $(sslib2) $(sslib3) $(sslib4) $(sslib5) $(sslib6) $(sslib7)
sslib1 = $(ssdir)/CHOLMOD/CHOLMOD.a
sslib2 = $(ssdir)/CCOLAMD/CCOLAMD.a
sslib3 = $(ssdir)/CAMD/CAMD.a
sslib4 = $(ssdir)/COLAMD/COLAMD.a
sslib5 = $(ssdir)/AMD/AMD.a
sslib6 = $(ssdir)/CXSparse/CXSparse.a
sslib7 = $(ssdir)/SuiteSparse_config/SuiteSparse_config.a

ssenv = \
	CC="$(CC)" \
	CPPFLAGS="$(CPPFLAGS) -I\"$(R_INCLUDE_DIR)\" -I\"$(R_INCLUDE_DIR)$(R_ARCH)\" -DNDEBUG -DNPRINT -DNTIMER" \
	CFLAGS="$(CFLAGS) $(CPICFLAGS) $(C_VISIBILITY)" \
	AR="$(AR)" \
	RANLIB="$(RANLIB)"

PKG_CPPFLAGS = -I"$(ssdir)/SuiteSparse_config"
PKG_CFLAGS = $(C_VISIBILITY)
PKG_LIBS = $(sslib) $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS)

$(SHLIB): $(sslib)
## NB: INSTALL does not clean subdirectories between subarchitectures
$(sslib1) :
	cd $(@D) && $(MAKE) clean all $(ssenv)
$(sslib2) :
	cd $(@D) && $(MAKE) clean all $(ssenv)
$(sslib3) :
	cd $(@D) && $(MAKE) clean all $(ssenv)
$(sslib4) :
	cd $(@D) && $(MAKE) clean all $(ssenv)
$(sslib5) :
	cd $(@D) && $(MAKE) clean all $(ssenv)
$(sslib6) :
	cd $(@D) && $(MAKE) clean all $(ssenv)
$(sslib7) :
	cd $(@D) && $(MAKE) clean all $(ssenv)

include ../inst/scripts/sources.mk
OBJECTS = $(sources:.c=.o)
include ../inst/scripts/rules.mk
