# Generated automatically from Makefile.in by the
# configure script.
#
# If you haven't read the file README yet, now would
# be a good time to do so.
#
# Master Makefile for man, manpath, apropos, whatis, and makewhatis
#
# Copyright (c) 1990, 1991, John W. Eaton.
#
# You may distribute under the terms of the GNU General Public
# License as specified in the README file that comes with the man 1.0
# distribution.  
#
# John W. Eaton
# jwe@che.utexas.edu
# Department of Chemical Engineering
# The University of Texas at Austin
# Austin, Texas  78712

SHELL = /bin/sh

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

# If you modify these values, you should also modify the corresponding
# portions of config.h.in.

srcdir = .


CC = gcc -O

pager = /usr/bin/less -sC
man_install_flags = 

DEFS =  -DSTDC_HEADERS -DPOSIX -DHAS_TROFF -DCOMPRESS -DALT_SYSTEMS

CDEBUG = 
CFLAGS = $(CDEBUG) -I. $(DEFS)
LDFLAGS = -s

# Where to install the executables.
bindir = $(BINROOTDIR)/usr/bin
# Where to put manpath.config
libdir = $(BINROOTDIR)/usr/lib
manpath_config_file = $(BINROOTDIR)/usr/lib/manpath.config

# Where to put the manual pages.
mandir = $(BINROOTDIR)/usr/man/man1
# Extension (not including `.') for the installed manual page filenames.
manext = 1

LIBOBJS = 

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

all: man manpath apropos whatis makewhatis manpages

manpath: manpath.c config.h manpath.h gripes.o util.o $(LIBOBJS)
	$(CC) $(CFLAGS) -DMAIN -o manpath manpath.c gripes.o util.o \
	$(LIBOBJS) $(LIBS)

man: man.c config.h gripes.h manpath.c manpath.h gripes.o glob.o \
	util.o $(LIBOBJS)
	$(CC) $(CFLAGS) -o man man.c manpath.c gripes.o glob.o util.o \
	$(LIBOBJS) $(LIBS)

gripes.o: gripes.h
util.o: gripes.h

apropos: apropos.sh
	sed -e 's,%libdir%,/usr/lib,' -e 's,%bindir%,/usr/bin,' \
	    -e 's,%pager%,/usr/bin/less -sC,' \
		apropos.sh > apropos

whatis: whatis.sh
	sed -e 's,%libdir%,/usr/lib,' -e 's,%bindir%,/usr/bin,' \
	    -e 's,%pager%,/usr/bin/less -sC,' \
		whatis.sh > whatis


install: all install.man apropos whatis makewhatis
	install -c $(man_install_flags) man $(BINROOTDIR)/usr/bin/man
	install -c -m 755 manpath $(BINROOTDIR)/usr/bin/manpath
	install -c -m 755 apropos $(BINROOTDIR)/usr/bin/apropos
	install -c -m 755 whatis $(BINROOTDIR)/usr/bin/whatis
	install -c -m 754 makewhatis $(BINROOTDIR)/usr/lib/makewhatis
	install -c -m 644 manpath.config $(BINROOTDIR)/usr/lib/manpath.config

manpages: man.$(manext) manpath.$(manext) apropos.$(manext) whatis.$(manext) 

man.$(manext): man.man
	sed -e 's,%libdir%,/usr/lib,' -e 's,%bindir%,/usr/bin,' \
	    -e 's,%pager%,/usr/bin/less -sC,' -e 's,%troff%,/usr/bin/groff -Tps -man,' \
	    -e 's,%manpath_config_file%,/usr/lib/manpath.config,' \
	man.man > man.$(manext)

manpath.$(manext): manpath.man
	sed -e 's,%libdir%,/usr/lib,' -e 's,%bindir%,/usr/bin,' \
	    -e 's,%pager%,/usr/bin/less -sC,' -e 's,%troff%,/usr/bin/groff -Tps -man,' \
	    -e 's,%manpath_config_file%,/usr/lib/manpath.config,' \
	manpath.man > manpath.$(manext)

apropos.$(manext): apropos.man
	sed -e 's,%libdir%,/usr/lib,' -e 's,%bindir%,/usr/bin,' \
	    -e 's,%pager%,/usr/bin/less -sC,' -e 's,%troff%,/usr/bin/groff -Tps -man,' \
	    -e 's,%manpath_config_file%,/usr/lib/manpath.config,' \
	apropos.man > apropos.$(manext)

whatis.$(manext): whatis.man
	sed -e 's,%libdir%,/usr/lib,' -e 's,%bindir%,/usr/bin,' \
	    -e 's,%pager%,/usr/bin/less -sC,' -e 's,%troff%,/usr/bin/groff -Tps -man,' \
	    -e 's,%manpath_config_file%,/usr/lib/manpath.config,' \
	whatis.man > whatis.$(manext)

install.man:
	install -c -m 644 man.$(manext) $(mandir)/man.$(manext)
	install -c -m 644 manpath.$(manext) $(mandir)/manpath.$(manext)
	install -c -m 644 apropos.$(manext) $(mandir)/apropos.$(manext)
	install -c -m 644 whatis.$(manext) $(mandir)/whatis.$(manext)

DISTFILES = COPYING Makefile.in README TODO apropos.man apropos.sh \
	config.h.in configure glob.c gripes.c gripes.h makewhatis.sh \
	man.c man.man manpath.c manpath.config manpath.h manpath.man \
	ndir.h strdup.c util.c version.h whatis.man whatis.sh

dist:
	echo man-`sed -e '/version[]/!d' -e 's/[^0-9.]*\([0-9.]*\).*/\1/' -e q < version.h` > .fname
	rm -rf `cat .fname`
	mkdir `cat .fname`
	ln $(DISTFILES) `cat .fname`
	tar chZf `cat .fname`.tar.Z `cat .fname`
	rm -rf `cat .fname` .fname
	
clean:
	rm -f *.o *~ core manpath man apropos whatis 

spotless: clean
	rm -f manpath man apropos whatis makewhatis
	rm -f man.$(manext) manpath.$(manext)
	rm -f apropos.$(manext) whatis.$(manext)
	rm -f Makefile config.status config.h
