#
# Copyright (c) 2004-2005, Doug Harple.  All rights reserved.
# 
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
# 
# 1. Redistributions of source code must retain the above copyright
#    notice, this list of conditions and the following disclaimer.
# 
# 2. Redistributions in binary form must reproduce the above copyright
#    notice, this list of conditions and the following disclaimer in the
#    documentation and/or other materials provided with the distribution.
# 
# 3. Neither the name of author nor the names of its contributors may be
#    used to endorse or promote products derived from this software
#    without specific prior written permission.
# 
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# 
# $Id: Makefile.in,v 1.24.2.7 2005/03/13 07:47:13 purgedhalo Exp $
#

prefix = @prefix@
exec_prefix = @exec_prefix@
bindir = @bindir@
mandir = @mandir@
sysconfdir = @sysconfdir@
datadir = @datadir@

CFLAGS = @CFLAGS@
L_OPT = @LEXLIB@ @LIBS@

CC = @CC@
LEX = @LEX@
YACC = @YACC@
INSTALL = @INSTALL@

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

detoxOBJS = detox.o clean_string.o file.o table.o parse_table.o \
	config_file_l.o config_file_y.o \
	parse_options_@option_parser@.o parse_options_generic.o

detoxSRC = `echo ${detoxOBJS} | sed -e "s/[.]o/.c/g"`

all: detox

#
# Compile Rules
#

detox: ${detoxOBJS}
	${CC} -o detox ${detoxOBJS} ${L_OPT}

#
# Special Source Compiles
#

config_file_l.c: config_file.l config_file_y.h
	${LEX} config_file.l
	mv lex.yy.c config_file_l.c

config_file_y.c: config_file.y
	${YACC} -d config_file.y
	mv y.tab.c config_file_y.c
	mv y.tab.h config_file_y.h

# In case some future rule depends on config_file_y.h
config_file_y.h: config_file_y.c

detox_path.h: config.status
	> detox_path.h
	echo "char default_etc_dir[]=\"${sysconfdir}\";" >> detox_path.h
	echo "char default_data_dir[]=\"${datadir}/detox\";" >> detox_path.h

# This is done by make dep too
detox.o: detox.c detox_path.h

#
# Actions
#

install: install-base install-sample-config

force-install: install-base install-unsafe-config install-sample-config

install-base: detox
	${INSTALL} -d ${DESTDIR}${bindir}
	${INSTALL} -d ${DESTDIR}${mandir}/man1
	${INSTALL} -d ${DESTDIR}${mandir}/man5
	${INSTALL} -d ${DESTDIR}${sysconfdir}
	${INSTALL} -d ${DESTDIR}${datadir}/detox
	${INSTALL} detox ${DESTDIR}${bindir}
	${INSTALL} detox.1 ${DESTDIR}${mandir}/man1
	${INSTALL} detoxrc.5 detox.tbl.5 ${DESTDIR}${mandir}/man5

install-safe-config:
	@if [ ! -f ${DESTDIR}${sysconfdir}/detoxrc ]; then \
		${INSTALL} detoxrc ${DESTDIR}${sysconfdir}; \
	else \
		echo "${DESTDIR}${sysconfdir}/detoxrc exists, skipping"; \
	fi
	@if [ ! -f ${DESTDIR}${datadir}/detox/iso8859_1.tbl ]; then \
		${INSTALL} iso8859_1.tbl ${DESTDIR}${datadir}/detox; \
	else \
		echo "${DESTDIR}${datadir}/detox/iso8859_1.tbl exists, skipping"; \
	fi
	@if [ ! -f ${DESTDIR}${datadir}/detox/unicode.tbl ]; then \
		${INSTALL} unicode.tbl ${DESTDIR}${datadir}/detox; \
	else \
		echo "${DESTDIR}${datadir}/detox/unicode.tbl exists, skipping"; \
	fi

install-unsafe-config:
	${INSTALL} detoxrc ${DESTDIR}${sysconfdir}
	${INSTALL} iso8859_1.tbl ${DESTDIR}${datadir}/detox
	${INSTALL} unicode.tbl ${DESTDIR}${datadir}/detox

install-sample-config:
	${INSTALL} detoxrc ${DESTDIR}${sysconfdir}/detoxrc.sample
	${INSTALL} iso8859_1.tbl ${DESTDIR}${datadir}/detox/iso8859_1.tbl.sample
	${INSTALL} unicode.tbl ${DESTDIR}${datadir}/detox/unicode.tbl.sample

clean:
	rm -f *.o core *~ a.out *.core
	rm -f detox

devclean: clean
	rm -f *.BAK
	rm -f detox_path.h
	rm -f config_file_l.c config_file_y.[ch]

distclean: clean
	rm -f config.log config.status config.cache
	rm -f Makefile config.h install.sh
	rm -f detox_path.h
	rm -f config_file_l.c config_file_y.[ch]
	rm -f .depend

dep: depend

depend:
	mkdep ${CFLAGS} ${detoxSRC}

dummy: 


syntax highlighted by Code2HTML, v. 0.9.1