#
#       Makefile for dcl-6.5
#
#       Copyright (C) 2000-2022 GFD Dennou Club. All rights reserved.
#

include Mkinclude

DIRSCLN 	= src demo
DIRSCLNA 	= src demo bin lib include doc


all: mkldir object library shared-library dbase script

mkldir:
	@if (test ! -d $(LDBASEDIR)) then \
	  echo "Making directory $(LDBASEDIR)" ; \
	  mkdir -p $(LDBASEDIR); \
	fi
object:
	@cd src ; \
	echo "Making object files..." ; \
	$(MAKE) object ; \
	cd ..

library:
	@cd src ; \
	echo "Making a library file..." ; \
	$(MAKE) library ; \
	cd ..

shared-library :
	@TODO_SHARED_LIBRARY@

dbase:
	@cd src ; \
	echo "Making database..." ; \
	$(MAKE) dbase ; \
	cd ..

exec:
	@cd src ; \
	echo "Making exec files..." ; \
	$(MAKE) exec ; \
	cd ..

script:
	@cd bin ; \
	echo "Making command script files..." ; \
	$(MAKE) all ; \
	cd ..

install: mkdir libinstall incinstall bininstall \
         maninstall

mkdir:
	@if (test ! -d $(prefix)) then \
	  echo "Making directory $(prefix)" ; \
	  mkdir -p $(prefix) ; \
	fi
	@if (test ! -d $(LIBDIR)) then \
	  echo "Making directory $(LIBDIR)" ; \
	  mkdir -p $(LIBDIR) ; \
	fi
	@if (test ! -d $(BINDIR)) then \
	  echo "Making directory $(BINDIR)" ; \
	  mkdir -p $(BINDIR) ; \
	fi
	@if (test ! -d $(INCDIR)) then \
	  echo "Making directory $(INCDIR)" ; \
	  mkdir -p $(INCDIR) ; \
	fi
	@if (test ! -d $(DBASEDIR)) then \
	  echo "Making directory $(DBASEDIR)" ; \
	  mkdir -p $(DBASEDIR) ; \
	fi
	@if (test ! -d $(MANDIR)) then \
	  echo "Making directory $(MANDIR)" ; \
	  mkdir -p $(MANDIR) ; \
	fi
	@if (test ! -d $(MANDIR)/man1) then \
	  echo "Making directory $(MANDIR)/man1" ; \
	  mkdir -p $(MANDIR)/man1 ; \
	fi

libinstall:
	@cd lib ; \
	echo "Installing lib..." ; \
	$(MAKE) install ; \
	cd ..

incinstall:
	@cd include ; \
	echo "Installing include..." ; \
	$(MAKE) install ; \
	cd ..

bininstall:
	@cd bin ; \
	echo "Installing bin..." ; \
	$(MAKE) install ; \
	cd ..

maninstall:
	@cd man ; \
	echo "Installing manpage..." ; \
	$(MAKE) install ; \
	cd ..

clean: clean.local clean.dir

distclean: clean.locala clean.dira clean.self

clean.all: clean.locala clean.dira clean.self

clean.local:
	$(RM) *~ *.aux

clean.locala:
	$(RM) *~ *.aux a.exe config.cache config.log config.status config.h

clean.self:
	$(RM) Makefile Mkinclude

clean.dir:
	@for i in $(DIRSCLN) ; do \
	  cd $$i ; \
	  echo "Cleaning $$i/" ; \
	  $(MAKE) clean ; \
	  cd .. ; \
	done

clean.dira:
	@for i in $(DIRSCLNA) ; do \
	  cd $$i ; \
	  echo "Cleaning $$i/" ; \
	  $(MAKE) distclean ; \
	  cd .. ; \
	done

test:
	@./bin/dclconfig650 --libdir > /dev/null
