#; Support for ACL2 Community Books
#; Copyright (C) 2022, Regents of the University of Texas
#; License: A 3-clause BSD license.  See the LICENSE file distributed with ACL2.

#; Written by:  Matt Kaufmann               and J Strother Moore
#; email:       Kaufmann@cs.utexas.edu      and Moore@cs.utexas.edu
#; Department of Computer Sciences
#; University of Texas at Austin
#; Austin, TX 78712-1188 U.S.A.

# This file is to be included in other Makefiles.  The include should be
# preceded by a definition of DIRS, the list of subdirectories.

.PHONY: top
top:
	@my_status=0
	@for dir in $(DIRS) ; \
	do \
	if [ -f $$dir/Makefile ]; then \
	(cd $$dir ; $(MAKE)) ; \
	my_status=$$? ; \
	if [ $$my_status -ne 0 ] ; then exit 1 ; fi ; \
	fi \
	done
	@exit $$my_status

.PHONY: fasl
fasl: fasl-more

.PHONY: fasl-more
fasl-more:
	@for dir in $(DIRS) ; \
	do \
	if [ -f $$dir/Makefile ]; then \
	(cd $$dir ; \
	$(MAKE) fasl ; \
	cd ..) ; \
	fi \
	done

.PHONY: fas
fas: fas-more

.PHONY: fas-more
fas-more:
	@for dir in $(DIRS) ; \
	do \
	if [ -f $$dir/Makefile ]; then \
	(cd $$dir ; \
	$(MAKE) fas ; \
	cd ..) ; \
	fi \
	done

.PHONY: o
o: o-more

.PHONY: o-more
o-more:
	@for dir in $(DIRS) ; \
	do \
	if [ -f $$dir/Makefile ]; then \
	(cd $$dir ; \
	$(MAKE) o ; \
	cd ..) ; \
	fi \
	done

.PHONY: sparcf
sparcf: sparcf-more

.PHONY: sparcf-more
sparcf-more:
	@for dir in $(DIRS) ; \
	do \
	if [ -f $$dir/Makefile ]; then \
	(cd $$dir ; \
	$(MAKE) sparcf ; \
	cd ..) ; \
	fi \
	done

.PHONY: ufsl
ufsl: ufsl-more

.PHONY: ufsl-more
ufsl-more:
	@for dir in $(DIRS) ; \
	do \
	if [ -f $$dir/Makefile ]; then \
	(cd $$dir ; \
	$(MAKE) ufsl ; \
	cd ..) ; \
	fi \
	done

.PHONY: 64ufasl
64ufasl: 64ufasl-more

.PHONY: 64ufasl-more
64ufasl-more:
	@for dir in $(DIRS) ; \
	do \
	if [ -f $$dir/Makefile ]; then \
	(cd $$dir ; \
	$(MAKE) 64ufasl ; \
	cd ..) ; \
	fi \
	done

.PHONY: x86f
x86f: x86f-more

.PHONY: x86f-more
x86f-more:
	@for dir in $(DIRS) ; \
	do \
	if [ -f $$dir/Makefile ]; then \
	(cd $$dir ; \
	$(MAKE) x86f ; \
	cd ..) ; \
	fi \
	done

.PHONY: dfsl
dfsl: dfsl-more

.PHONY: dfsl-more
dfsl-more:
	@for dir in $(DIRS) ; \
	do \
	if [ -f $$dir/Makefile ]; then \
	(cd $$dir ; \
	$(MAKE) dfsl ; \
	cd ..) ; \
	fi \
	done

.PHONY: d64fsl
d64fsl: d64fsl-more

.PHONY: d64fsl-more
d64fsl-more:
	@for dir in $(DIRS) ; \
	do \
	if [ -f $$dir/Makefile ]; then \
	(cd $$dir ; \
	$(MAKE) d64fsl ; \
	cd ..) ; \
	fi \
	done

.PHONY: dx64fsl
dx64fsl: dx64fsl-more

.PHONY: dx64fsl-more
dx64fsl-more:
	@for dir in $(DIRS) ; \
	do \
	if [ -f $$dir/Makefile ]; then \
	(cd $$dir ; \
	$(MAKE) dx64fsl ; \
	cd ..) ; \
	fi \
	done

.PHONY: lx64fsl
lx64fsl: lx64fsl-more

.PHONY: lx64fsl-more
lx64fsl-more:
	@for dir in $(DIRS) ; \
	do \
	if [ -f $$dir/Makefile ]; then \
	(cd $$dir ; \
	$(MAKE) lx64fsl ; \
	cd ..) ; \
	fi \
	done

.PHONY: lx32fsl
lx32fsl: lx32fsl-more

.PHONY: lx32fsl-more
lx32fsl-more:
	@for dir in $(DIRS) ; \
	do \
	if [ -f $$dir/Makefile ]; then \
	(cd $$dir ; \
	$(MAKE) lx32fsl ; \
	cd ..) ; \
	fi \
	done

.PHONY: clean
clean: clean-more

.PHONY: clean-more
clean-more:
	@for dir in $(DIRS) ; \
	do \
	if [ -f $$dir/Makefile ]; then \
	(cd $$dir ; \
	$(MAKE) clean ; \
	cd ..) ; \
	fi \
	done

.PHONY: chk-include-book-worlds
chk-include-book-worlds: chk-include-book-worlds-more

.PHONY: chk-include-book-worlds-more
chk-include-book-worlds-more:
	@for dir in $(DIRS) ; \
	do \
	if [ -f $$dir/Makefile ]; then \
	(cd $$dir ; \
	$(MAKE) chk-include-book-worlds ; \
	cd ..) ; \
	fi \
	done
