VPATH = @srcdir@
include ../include/config.Makefile
BUILT_TARGETS = patch fetch all check unconfigure reinstall
ALL_TARGETS = $(BUILT_TARGETS) clean distclean
all:fetch
$(ALL_TARGETS): Makefile.library
$(foreach d,@LIBLIST@ @PROGLIST@ libtool M2,		\
	$(foreach t, $(ALL_TARGETS),			\
		$(eval $t-in-$d:; + $$(MAKE) -C $d $t)	\
		$(eval .PHONY: $t $t-in-$d)))
$(foreach d,@BUILDLIST@,			\
	$(foreach t, $(BUILT_TARGETS),		\
		$(eval $t: $t-in-$d)		\
		$(eval .PHONY: $t $t-in-$d)))
$(foreach d,@LIBLIST@ @PROGLIST@,		\
	$(foreach t, distclean clean,		\
		$(eval $t: $t-in-$d)		\
		$(eval .PHONY: $t $t-in-$d)))
$(foreach d,@LIBLIST@ @PROGLIST@,		\
	$(foreach t, $(BUILT_TARGETS),		\
		$(eval $t-all: $t-in-$d)	\
		$(eval .PHONY: $t-all)))

ifeq (@HIGHLIGHTJS@,yes)
fetch fetch-all:
	$(MAKE) -C ../Macaulay2/editors highlightjs/node_modules
endif

uninstall:; rm -rf */.installed* $(BUILTLIBPATH)
all:install-programs install-licenses
install-programs:
	: installing programs in @pre_programsdir@
	$(MKDIR_P) $(BUILTLIBPATH)/bin ; \
	@INSTALL@ -d @pre_programsdir@ ; \
	@TAR@ cf - -C $(BUILTLIBPATH)/bin/. . | @TAR@ xf - -C @pre_programsdir@ ;
install-licenses:
	: installing library and submodule licenses in @pre_licensesdir@
	$(MKDIR_P) $(BUILTLIBPATH)/licenses ; \
	@INSTALL@ -d @pre_licensesdir@ ; \
	@TAR@ cf - -C $(BUILTLIBPATH)/licenses/. . | @TAR@ xf - -C @pre_licensesdir@ ;
install-dynamic-libraries:
	: installing sharable library files in @pre_librariesdir@
	$(MKDIR_P) $(BUILTLIBPATH)/lib ; \
	@INSTALL@ -d @pre_librariesdir@ ;			     \
	cd $(BUILTLIBPATH)/lib &&				     \
	for i in *.dll *.so.* *[0-9].dylib ;			     \
	do if [ -e $$i ] ;					     \
	   then @TAR@ cf - $$i | @TAR@ xfv - -C @pre_librariesdir@ ; \
	   fi ;							     \
	done ;
ifeq (@SHARED@,yes)
all: install-dynamic-libraries
endif

$(foreach f,Makefile Makefile.library,					\
	$(eval $f: $f.in; cd .. && ./config.status libraries/$f))
show-licenses:; grep -wnH license @srcdir@/*/Makefile.in
clean:; rm -rf final
distclean:clean ; rm -f Makefile
# Local Variables:
# compile-command: "make -C $M2BUILDDIR/libraries "
# End:
.NOTPARALLEL:
