# GNUmakefile for EDB subdir "lisp".
# Copyright (C) 2008 Thien-Thi Nguyen
#
# This file is part of EDB.
#
# EDB is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free
# Software Foundation; either version 3, or (at your option) any later
# version.
#
# EDB is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License
# along with EDB; see the file COPYING.  If not, write to the Free
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301, USA.

srcdir = .
top_srcdir = ..

prefix = /tmp/buildd/edb-1.31/debian/edb/usr
datarootdir = ${prefix}/share
datadir = ${datarootdir}
infodir = ${datarootdir}/info
sitelisp = ${datarootdir}/emacs/site-lisp

INSTALL = /usr/bin/install -c
INSTALL_DATA = ${INSTALL} -m 644
mkinstalldirs = $(top_srcdir)/install-sh -d

EDB-VERSION = 1.31

edb-elc-dir = $(sitelisp)/edb

EMACS = emacs
EXTRABATCHOPTS = --no-site-file

ebatch = $(EMACS) -batch $(EXTRABATCHOPTS)



badnamesp = true
badnames-el = db-nosetf.el db-oldnames.el

edbcore-lispfrags = system state connection
edbcore-dbfrags = util rep format file-io interfa types summary
edbcore-components = \
 $(edbcore-lispfrags:%=%.el) \
 $(edbcore-dbfrags:%=db-%.el)

generated = edbcore.el

dontcompile = db-lemacs.el db-nosetf.el db-oldnames.el

typelibs-frags = human-names places-usuk timedate1
typelibs = $(typelibs-frags:%=edb-t-%.el)

normal-lispfrags = 1int-to-single meta
normal-frags = isbn rdb search sort tagged two-dbs
normal = database.el \
 $(normal-frags:%=db-%.el) \
 $(normal-lispfrags:%=edb-%.el)

source-el-files = $(edbcore-components) $(normal) $(typelibs)
installed-el-files = $(generated) $(normal) $(typelibs)
installed-elc-files = $(addsuffix c, $(installed-el-files))

all: $(installed-elc-files)

$(installed-elc-files): $(source-el-files)
	$(ebatch) \
		--eval '(setq vc-handled-backends nil)' \
		--eval '(setq load-path (cons "$(srcdir)" load-path))' \
		-l bfuncs \
		-f edb-bfunc-make-all

clean:
	$(RM) $(installed-elc-files) $(generated)

# Install *.elc after *.el in case $(INSTALL_DATA) clobbers mtime.
install: all
	$(mkinstalldirs) $(edb-elc-dir)
	$(RM) $(edb-elc-dir)/*.el $(edb-elc-dir)/*.elc
	$(INSTALL_DATA) $(installed-el-files) $(edb-elc-dir)
	$(INSTALL_DATA) $(installed-elc-files) $(edb-elc-dir)
	$(INSTALL_DATA) $(dontcompile) $(edb-elc-dir)
	$(badnamesp) || $(RM) $(addprefix $(edb-elc-dir)/, $(badnames-el))

installcheck:
	$(ebatch) --eval '(message "%s" load-path)' --kill 2>&1 \
	  | sed 's, ,:,g;s,(,,;s,),,' > TMP
	EMACSLOADPATH=$(sitelisp):`cat TMP` \
	  $(ebatch) --load database --kill
	$(RM) TMP

# GNUmakefile ends here
