# -*- make -*-

#This is a UNIX-only makefile.  For other systems, get a makefile from
#src/mkfiles/

# If you want to change these variables, re-run the configure script.
INSTALL= @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
prefix = @prefix@
exec_prefix = @exec_prefix@
libdir = @libdir@
pkgconfigdir = @pkgconfigdir@
#---------------------------------------------------------------------------
# DESTDIR is designed to facilitate making packages.  Normally it is empty
#---------------------------------------------------------------------------
#DESTDIR =
DEST_PKGCONFIGDIR = $(DESTDIR)$(pkgconfigdir)
#
MKINSDIR = autoconf/mkinsdir.sh

@SET_MAKE@
SHELL = /bin/sh

all: elf
Makefile: configure autoconf/Makefile.in
	@echo "Makefile is older than the configure script".
	@echo "Please re-run the configure script."
	@exit 1
slsh/Makefile: configure slsh/Makefile.in
	@echo "slsh/Makefile is older than its dependencies".
	@echo "Please re-run the configure script."
	@exit 1
modules/Makefile: configure modules/Makefile.in
	@echo "modules/Makefile is older than its dependencies".
	@echo "Please re-run the configure script."
	@exit 1
src/Makefile: configure src/Makefile.in src/config.hin
	@echo "src/Makefile is older than its dependencies".
	@echo "Please re-run the configure script."
	@exit 1
#
makefiles: Makefile slsh/Makefile modules/Makefile src/Makefile
help:
	@echo "make install ==> shared version of the library, slsh and modules"
	@echo "make install-static ==> static version of the library and slsh; no modules"
	@echo "make install-all ==> shared/static versions of the library/modules + shared slsh."
	@echo "make install-modules ==> install the modules"
	@echo "make check ==> Build the library and run the regression tests"
slang.pc: configure autoconf/slangpc.in
	@echo "slang.pc needs to be updated -- rerun configure"
	@exit 1
static: makefiles slang.pc
	cd src; $(MAKE) static
	cd slsh; $(MAKE) static
modules:
	cd modules; $(MAKE) all
elf: makefiles slang.pc
	cd src; $(MAKE) elf
	cd slsh; $(MAKE) all
	cd modules; $(MAKE) all
	@echo Use make install to install it.
runtests: all
	@failed=0; \
	cd src; $(MAKE) runtests || failed=1; cd ..; \
	cd modules; $(MAKE) runtests || failed=1; cd ..; \
	cd slsh; $(MAKE) runtests || failed=1; cd ..; \
	exit $$failed
check: runtests

demos:
	cd demo; $(MAKE)
clean:
	/bin/rm -f *~
	cd src; $(MAKE) clean
	cd modules; $(MAKE) clean
	cd slsh; $(MAKE) clean
	cd demo; $(MAKE) clean
install-static: install-pkgconfig
	cd src; $(MAKE) install-static
	cd slsh; $(MAKE) install-static
install-pkgconfig: slang.pc
	$(MKINSDIR) $(DEST_PKGCONFIGDIR)
	$(INSTALL_DATA) slang.pc $(DEST_PKGCONFIGDIR)/
install-elf: install-pkgconfig
	cd src; $(MAKE) install-elf
	@echo Now installing slsh
	cd slsh; $(MAKE) install
	@echo Now installing the modules
	cd modules; $(MAKE) install
	@echo ""
	@echo "On some systems, e.g., linux, you may also have to run ldconfig."
	@echo ""
install: install-elf install-pkgconfig
install-all: install-elf
	cd src; $(MAKE) install-static
install-modules:
	cd modules; $(MAKE) install
install-links:
	cd src; $(MAKE) install-links
#
distclean:
	/bin/rm -f *~ Makefile config.status config.log config.cache files.pck slang.pc
	cd src; $(MAKE) distclean
	cd demo; $(MAKE) distclean
	cd modules; $(MAKE) distclean
	cd slsh; $(MAKE) distclean
#
.PHONY: all help static elf install clean check install-elf install-static makefiles install-pkgconfig
#
