# $Header: /home/amb/cxref/cpp/RCS/Makefile.in 1.2 1999/01/16 12:20:10 amb Exp $
#
# C Cross Referencing & Documentation tool. Version 1.5.
#
# CPP Makefile.
#
# Written by Andrew M. Bishop
#
# This file Copyright 1995,96,99 Andrew M. Bishop
# It may be distributed under the GNU Public License, version 2, or
# any higher version.  See section COPYING of the GNU Public license
# for conditions under which this file may be redistributed.
#

# autoconf things

srcdir=@srcdir@
VPATH=@srcdir@

# The installation locations

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

# The installation program.

INSTALL=@INSTALL@

# The C compiler and linker

CC=@CC@
LD=@CC@

# The Yacc program

YACC=@YACC@ -l

########

INCLUDE=
LIBRARY=@LIBS@

########

INCLUDE_DIR1=@INCLUDE_DIR1@
INCLUDE_DIR2=@INCLUDE_DIR2@
INCLUDE_DIR3=@INCLUDE_DIR3@
PREDEFINES=@PREDEFINES@

########

programs : @CXREF_CPP@

########

OBJ_FILES=cccp.o cexp.o version.o

####

cxref-cpp : $(OBJ_FILES)
	$(LD) $(LDFLAGS) $(OBJ_FILES) -o $@ $(LIBRARY)
	@touch $@

########

install : @CXREF_CPP@
	[ ! -f cxref-cpp ] || $(INSTALL) -m 755 cxref-cpp $(bindir)
	[ ! -f cxref-cpp ] || $(INSTALL) -m 644 README.man $(mandir)/man1/cxref-cpp.1

install-win32 : @CXREF_CPP@
	[ ! -f cxref-cpp ] || $(INSTALL) -m 755 cxref-cpp.exe $(bindir)

########

clean :
	-rm -f cxref-cpp core *.o *~ y.tab.c

####

distclean : clean
	-rm -f Makefile autoconfig.h \
	config.log config.status config.cache conftest.gcc

########

cexp.c : cexp.y
	$(YACC) cexp.y
	@touch $@
	@mv y.tab.c cexp.c

####

cccp.o: cccp.c config.h tm.h pcp.h autoconfig.h
	$(CC) -c -w $(CFLAGS) cccp.c -o $@ $(INCLUDE) \
	 '-DLOCAL_INCLUDE_DIR="$(INCLUDE_DIR1)"' \
	 '-DTOOL_INCLUDE_DIR="$(INCLUDE_DIR2)"' \
	 '-DGCC_INCLUDE_DIR="$(INCLUDE_DIR3)"' \
	 '-DGPLUSPLUS_INCLUDE_DIR="."' \
	 '-DCPP_PREDEFINES="$(PREDEFINES)"'
	@touch $@

####

%.o:%.c
	$(CC) -c -w $(CFLAGS) $< -o $@ $(INCLUDE)
	@touch $@

version.o    : version.c
cexp.o       : cexp.c config.h tm.h autoconfig.h

########
