# Makefile template for GNU indent
# Copyright (C) 1992, Free Software Foundation, Inc.
#
# This file is part of GNU indent.
#
# GNU indent 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, or (at your option)
# any later version.
# 
# GNU indent 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 GNU indent; see the file COPYING.  If not, write to
# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.

#### Start of system configuration section. ####

srcdir = @srcdir@
VPATH = @srcdir@

CC = @CC@

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

AWK = awk
MAKEINFO = makeinfo

# Used only for making distributions.  If you don't have GNU tar,
# you must change the make command below in the `tarfile:' section.
TAR = tar

DVITOGHOSTSCRIPT = dvi2ps indent.dvi > indent.ps
CTAGS = etags

CFLAGS = -g
LDFLAGS = -g

# C compiler -D options.
DEFS = @DEFS@

# Where to install indent and its documentation.
prefix = /usr/local
exec_prefix = ${prefix}
bindir = $(exec_prefix)/bin
infodir = ${prefix}/info

#### End of system configuration section. ####

SHELL =   /bin/sh
SRC =	  indent.c io.c lexi.c parse.c pr_comment.c args.c globs.c \
	  backup.c memcpy.c
OBJ =	  indent.o io.o lexi.o parse.o pr_comment.o args.o globs.o \
	  backup.o @LIBOBJS@
HEADERS = indent.h sys.h version.h backup.h
MAN =	  indent.texinfo texinfo.tex
NOTES =   ChangeLog OChangeLog Projects

CONFIG = configure.in configure CONF-README

MANJUNK = indent.dvi indent.cp indent.cps indent.aux indent.dlog \
indent.fn indent.fns indent.ky indent.kys indent.log indent.pg   \
indent.pgs indent.toc indent.tp indent.tps indent.vr indent.vrs indent.ps 

# What to put in a distribution
TARFILES = ${SRC} Makefile makefile.in ${MAN} indent.info ${HEADERS} \
${NOTES} indent.gperf ${CONFIG} indent.1
RELEASEFILES = RELEASE-NOTES README comments.texinfo


# Make the program and documentation
#
all: indent indent.info

indent: ${OBJ}
	${CC} -o indent ${LDFLAGS} ${OBJ}

.c.o:
	${CC} -c ${CFLAGS} ${CPPFLAGS} ${DEFS} $<


backup.o: backup.c backup.h sys.h makefile
globs.o: globs.c sys.h makefile

indent.o: indent.c indent.h sys.h makefile
args.o: args.c version.h indent.h sys.h makefile
io.o: io.c indent.h sys.h makefile
lexi.o: lexi.c indent.h sys.h makefile
parse.o: parse.c indent.h sys.h makefile
pr_comment.o: pr_comment.c indent.h sys.h makefile
memcpy.o: memcpy.c indent.h sys.h makefile


# Build tag tables
tags: ${SRC}
	${CTAGS} -t ${SRC} ${HEADERS}
TAGS: tags



# Documents
#
indent.ps: indent.dvi
	${DVITOGHOSTSCRIPT}

indent.dvi: indent.toc
	tex ${srcdir}/indent.texinfo

indent.toc: ${MAN}
	tex ${srcdir}/indent.texinfo

indent.info: ${MAN}
	${MAKEINFO} ${srcdir}/indent.texinfo



# Installation of indent
#
install: all
	${INSTALL_PROGRAM} indent ${bindir}/indent
	${INSTALL_DATA} ${srcdir}/indent.info ${infodir}/indent.info


# Cleaning up
#

# Delete all files generated by building indent or making the manual
clean: mostlyclean
	rm -f ${MANJUNK}

# Delete all files created by configuring or building indent
distclean: clean
	rm -f makefile indent-*.tar*
	rm -rf indent-*

# Clean up the .o files, leaving the man stuff
mostlyclean:
	rm -f ${OBJ} indent

# Clean up tar files, indent-generated backup files, and indent
# subdirectories
realclean: distclean
	rm -f indent.info TAGS core



# Create a distribution file
#
DISTDIR = indent-${VERSION}
TARFILE = indent-${VERSION}.tar
DISTFILE = ${TARFILE}.Z
AWKVERSION = ${AWK} '/define VERSION_STRING/ {printf "%s", \
                     substr($$NF, 1, length($$NF) - 1)}' version.h


dist: ${TARFILES}
	@export VERSION ; VERSION=`${AWKVERSION}` ; \
	${MAKE} tarfile
#	@unset VERSION

tar: dist

# NOTE: GNU tar has a compress option, -z, used below.  If you
# do not have GNU tar, replace the tar line below with the following
# two lines:
#	tar -c -h -f ${TARFILE} ${DISTDIR}
#	compress ${TARFILE}
tarfile:
	@test -f README-${VERSION} || (echo Missing file README-${VERSION}; exit 1)
	@test -f RELEASE-NOTES-${VERSION} || (echo Missing file RELEASE-NOTES-${VERSION}; exit 1)
	@echo Making compressed tar file, indent ${VERSION}
	@echo
	@rm -f README
	@ln -s README-${VERSION} README
	@rm -f RELEASE-NOTES
	@ln -s RELEASE-NOTES-${VERSION} RELEASE-NOTES
	@rm -rf ${DISTDIR}
	@rm -f ${DISTFILE}
	@mkdir ${DISTDIR}
	@cd ${DISTDIR} ; for i in ${TARFILES} ${RELEASEFILES} ; do ln -s ../$$i . ; done
	@${TAR} -c -v -h -z -f ${DISTFILE} ${DISTDIR}
	@rm -rf ${DISTDIR}

