# Makefile for less.

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

srcdir = @srcdir@
VPATH = @srcdir@

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

CFLAGS = @CFLAGS@
CFLAGS_COMPILE_ONLY = -c
LDFLAGS = @LDFLAGS@
O=o

LIBS = @LIBS@

LESS_HLP=less.hlp

prefix = @prefix@
exec_prefix = @exec_prefix@

# Where the installed binary goes.
bindir = @bindir@
binprefix = 

sysconfdir = @sysconfdir@

mandir = @mandir@
manext = 1
manprefix = 

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

SHELL = /bin/sh

# This rule allows us to supply the necessary -D options
# in addition to whatever the user asks for.
.c.o:
	${CC} -I. ${CFLAGS_COMPILE_ONLY} -DBINDIR=\"${bindir}\" -DSYSDIR=\"${sysconfdir}\" ${CPPFLAGS} ${CFLAGS} $<

OBJ =	main.${O} screen.${O} brac.${O} ch.${O} charset.${O} cmdbuf.${O} \
	command.${O} decode.${O} edit.${O} filename.${O} forwback.${O} \
	help.${O} ifile.${O} input.${O} jump.${O} line.${O} linenum.${O} \
	lsystem.${O} mark.${O} optfunc.${O} option.${O} opttbl.${O} os.${O} \
	output.${O} position.${O} prompt.${O} search.${O} signal.${O} \
	tags.${O} ttyin.${O} version.${O}  @REGEX_O@

all: less lesskey

less: ${OBJ}
	${CC} ${LDFLAGS} -o $@ ${OBJ} ${LIBS}

lesskey: lesskey.${O} version.${O}
	${CC} ${LDFLAGS} -o $@ lesskey.${O} version.${O}

${OBJ}: ${srcdir}/less.h ${srcdir}/funcs.h defines.h 

filename.${O}: ${srcdir}/filename.c
	${CC} -I. ${CFLAGS_COMPILE_ONLY} -DHELPFILE=\"${datadir}/${LESS_HLP}\" ${CPPFLAGS} ${CFLAGS} ${srcdir}/filename.c

help.${O}: ${srcdir}/help.c
	${CC} -I. ${CFLAGS_COMPILE_ONLY} -DHELPFILE=\"${datadir}/${LESS_HLP}\" ${CPPFLAGS} ${CFLAGS} ${srcdir}/help.c

install: all
	${INSTALL_PROGRAM} less ${bindir}/${binprefix}less
	${INSTALL_PROGRAM} lesskey ${bindir}/${binprefix}lesskey

install-strip:
	${MAKE} INSTALL_PROGRAM='${INSTALL_PROGRAM} -s' install

#installdirs: mkinstalldirs
#	sh ${srcdir}/mkinstalldirs ${bindir} ${mandir}/man${manext}

uninstall:
	rm -f ${mandir}/man${manext}/${manprefix}less.${manext} ${mandir}/man${manext}/${manprefix}lesskey.${manext}

info:
install-info:
dvi:
check:
installcheck:

TAGS:
	cd ${srcdir} && etags *.c *.h

# config.status might not change defines.h
# Don't rerun config.status if we just configured (so there's no stamp-h).
defines.h: stamp-h
stamp-h: defines.h.in config.status
	test ! -f stamp-h || CONFIG_FILES= CONFIG_HEADERS=defines.h ./config.status
	touch stamp-h
Makefile: ${srcdir}/Makefile.in config.status
	CONFIG_FILES=Makefile CONFIG_HEADERS= ./config.status
config.status: ${srcdir}/configure
	./config.status --recheck

#${srcdir}/configure: ${srcdir}/configure.ac
#	cd ${srcdir}; autoheader; autoconf

clean:
	rm -f *.${O} core less lesskey lessecho

mostlyclean: clean

distclean: clean
	rm -f Makefile config.status config.log config.cache defines.h stamp-h

realclean: distclean
	rm -f TAGS