# Makefile for hbf2gf -- wl@gnu.org

# Copyright (C) 1994-2021  Werner Lemberg <wl@gnu.org>
#
# This program 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 2 of the License, or
# (at your option) any later version.
#
# This program 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 this program in doc/COPYING; if not, write to the Free
# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
# MA 02110-1301 USA

VPATH = @srcdir@
srcdir = @srcdir@

prefix = @prefix@
exec_prefix = @exec_prefix@
libdir = @libdir@
bindir = @bindir@
mandir = @mandir@

RM = @RM@
RMF = @RM@ -f

TEX = tex
CTANGLE = ctangle
CWEAVE = cweave

INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@

CC = @CC@
CPP = @CPP@

MKINSTALLDIRS = $(srcdir)/mkinstalldirs

CFLAGS = @CFLAGS@
CPPFLAGS = @CPPFLAGS@ @DEFS@ @no_strdup@ -Dunix
MY_CFLAGS = $(CFLAGS) $(CPPFLAGS) @XX_CFLAGS@
LDFLAGS = @LDFLAGS@ @LIBS@

SRC = hbf2gf.c $(srcdir)/hbf.c
OBJ = hbf2gf.o hbf.o


.SUFFIXES: .dvi .tex .w


.w.c:
	$(CTANGLE) $<
.c.o:
	$(CC) -c $(MY_CFLAGS) $<

.w.tex:
	$(CWEAVE) +ai $<

.tex.dvi:
	$(TEX) $<



PROGRAMS = hbf2gf

default all: $(PROGRAMS)

hbf2gf.c: $(srcdir)/hbf2gf.w

hbf2gf: $(OBJ)
	$(CC) $(MY_CFLAGS) -o hbf2gf $(OBJ) $(LDFLAGS)

documentation: hbf2gf.dvi

install: $(PROGRAMS)
	$(MKINSTALLDIRS) $(bindir) $(mandir)/man1
	for P in $(PROGRAMS) ; do \
          $(INSTALL_PROGRAM) $$P $(bindir)/$$P ; \
          $(INSTALL_DATA) $(srcdir)/$$P.1 $(mandir)/man1 ; \
        done

uninstall:
	-for P in $(PROGRAMS) ; do \
          $(RMF) $(bindir)/$$P ; \
          $(RMF) $(mandir)/man1/$$P.1 ; \
        done

clean: do_clean

distclean: do_clean
	-$(RMF) dep.end $(PROGRAMS) *.dvi
	-$(RMF) *~ *.orig core *.core
	-$(RMF) config.cache config.log config.status Makefile

do_clean:
	-$(RMF) *.o
	-$(RMF) *.scn *.toc *.idx *.log

maintainer-clean: distclean
	-$(RMF) hbf2gf.c

depend: $(SRC)
	(echo '/^#.* PUT NO STUFF BELOW/,$$d'; echo w; echo q) | \
         ed - Makefile
	echo '# Dependencies generated by make depend: PUT NO STUFF BELOW' \
          >> Makefile
	for file in $(SRC) ; do \
          $(CPP) $(CPPFLAGS) $$file | \
           sed -n -e 's|^# [1-9][0-9]* "\([^/].*\.h\)".*|\1|p' \
                  -e 's|^# [1-9][0-9]* "\($(srcdir)/.*\.h\)".*|\1|p' | \
           sed -e 's|/\./|.|g' -e "s/^/`basename $$file .c`.o: /" ; \
        done | \
         sort -u | \
         awk '{ if (LINE == 1) \
                  { line = last = $$1 } \
                else if ($$1 != last) \
                  { print line ; line = last = $$1 } \
                line = line " " $$2 } \
              END { print line }' >> Makefile

# Dependencies generated by make depend: PUT NO STUFF BELOW
