# Makefile for GNU C Preprocessor.
#
# hacked from gcc Makefile by kvigor.
#
#   Copyright (C) 1987, 1988, 1990, 1991, 1992, 1993, 1994, 1995
#   1996, 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.

#This file is part of GNU CC.

#GNU CC 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 CC 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 CC; see the file COPYING.  If not, write to
#the Free Software Foundation, 59 Temple Place - Suite 330,
#Boston MA 02111-1307, USA.

EXEEXT = @EXEEXT@
PRJDIR = ../..
TARGET = $(PRJDIR)/bin/sdcpp$(EXEEXT)

# This is the default target.
all: $(TARGET)

# Directory where sources are, from where we are.
srcdir = @srcdir@



LIBS = @LIBS@
CFLAGS = @CFLAGS@
ALL_CFLAGS = $(INTERNAL_CFLAGS) $(X_CFLAGS) $(T_CFLAGS) \
  $(CFLAGS) $(WARN_CFLAGS) $(XCFLAGS) @DEFS@
ALL_CPPFLAGS = $(CPPFLAGS) $(X_CPPFLAGS) $(T_CPPFLAGS)
LDFLAGS = @LDFLAGS@

CC = @CC@
AR = ar
AR_FLAGS = rc
RANLIB = @RANLIB@
SHELL = /bin/sh
STRIP = @STRIP@
# on sysV, define this as cp.
INSTALL = @INSTALL@
# Some systems may be missing symbolic links, regular links, or both.
# Allow configure to check this and use "ln -s", "ln", or "cp" as appropriate.
LN=@LN@
LN_S=@LN_S@
# These permit overriding just for certain files.
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@
@SET_MAKE@
# Some compilers can't handle cc -c blah.c -o foo/blah.o.
# In stage2 and beyond, we force this to "-o $@" since we know we're using gcc.
OUTPUT_OPTION = @OUTPUT_OPTION@

# Some versions of `touch' (such as the version on Solaris 2.8)
# do not correctly set the timestamp due to buggy versions of `utime'
# in the kernel.  So, we use `echo' instead.
STAMP = echo timestamp >

# Where to find some libiberty headers.
LIBIBERTY_DIR = $(srcdir)/libiberty
OBSTACK_H   = $(LIBIBERTY_DIR)/obstack.h
SPLAY_TREE_H= $(LIBIBERTY_DIR)/splay-tree.h

# Test to see whether <limits.h> exists in the system header files.
LIMITS_H_TEST = [ -f $(SYSTEM_HEADER_DIR)/limits.h ]

# Common prefix for installation directories.
# NOTE: This directory must exist when you start installation.
prefix = @prefix@
# Directory in which to put localized header files. On the systems with
# gcc as the native cc, `local_prefix' may not be `prefix' which is
# `/usr'.
# NOTE: local_prefix *should not* default from prefix.
local_prefix = @local_prefix@
# Directory in which to put host dependent programs and libraries
exec_prefix = @exec_prefix@
# Directory in which to put the executable for the command `gcc'
bindir = @bindir@
includedir = $(local_prefix)/include
# where the info files go
exeext = @host_exeext@

transform       = @program_transform_name@

# Top build directory, relative to here.
top_builddir = .

# Whether we were configured with NLS.
USE_NLS = @USE_NLS@

# Internationalization library.
INTLLIBS = @INTLLIBS@

# Change this to a null string if obstacks are installed in the
# system library.
OBSTACK=obstack.o

# End of variables for you to override.

install: all
	mkdir -p $(bindir)
	$(INSTALL) $(TARGET) `echo $(bindir)/sdcpp$(EXEEXT)|sed '$(transform)'`
	$(STRIP) `echo $(bindir)/sdcpp$(EXEEXT)|sed '$(transform)'`

uninstall:
	rm -f $(bindir)/sdcpp$(EXEEXT)
clean:
	-rm -f $(TARGET) *.o core libcpp.a

distclean: clean
	-rm -f auto-host.h auto-build.h cstamp-h Makefile
	-rm -f config.status config.run config.cache config.bak config.log *~

# This tells GNU Make version 3 not to put all variables in the environment.
.NOEXPORT:

# GCONFIG_H lists the config files that the generator files depend on, while
# CONFIG_H lists the the ones ordinary gcc files depend on, which includes
# a file generated by gencodes.
CONFIG_H = config.h
SYSTEM_H = system.h hwint.h

# sed inserts variable overrides after the following line.
####target overrides
#@target_overrides@

####host overrides
#@host_overrides@

####cross overrides
#@cross_defines@
#@cross_overrides@

####build overrides
#@build_overrides@
#

INCLUDES = -I$(srcdir) -I$(LIBIBERTY_DIR)

# Always use -I$(srcdir)/config when compiling.
.c.o:
	$(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) $< $(OUTPUT_OPTION)

# cstamp-h.in controls rebuilding of config.in.
# It is named cstamp-h.in and not stamp-h.in so the mostlyclean rule doesn't
# delete it.  A stamp file is needed as autoheader won't update the file if
# nothing has changed.
# It remains in the source directory and is part of the distribution.
# This follows what is done in shellutils, fileutils, etc.
# "echo timestamp" is used instead of touch to be consistent with other
# packages that use autoconf (??? perhaps also to avoid problems with patch?).
# ??? Newer versions have a maintainer mode that may be useful here.
$(srcdir)/config.in: $(srcdir)/cstamp-h.in $(srcdir)/acconfig.h
$(srcdir)/cstamp-h.in: $(srcdir)/configure.in $(srcdir)/acconfig.h
	(cd $(srcdir) && autoheader)
	@rm -f $(srcdir)/cstamp-h.in
	echo timestamp > $(srcdir)/cstamp-h.in
auto-host.h: cstamp-h ; @true
cstamp-h: config.in config.status
	CONFIG_HEADERS=auto-host.h:config.in LANGUAGES="$(CONFIG_LANGUAGES)" $(SHELL) config.status

# Really, really stupid make features, such as SUN's KEEP_STATE, may force
# a target to build even if it is up-to-date.  So we must verify that
# config.status does not exist before failing.
config.status: $(srcdir)/configure  version.c
	@if [ ! -f config.status ] ; then \
	  echo You must configure gcc.  Look at http://gcc.gnu.org/install/ for details.; \
	  false; \
	else \
	  LANGUAGES="$(CONFIG_LANGUAGES)" $(SHELL) config.status --recheck; \
	fi

version.o: version.c version.h

hashtable.o: hashtable.c hashtable.h $(CONFIG_H) $(SYSTEM_H) $(OBSTACK_H)

prefix.o: prefix.c $(CONFIG_H) $(SYSTEM_H) Makefile prefix.h
	$(CC) $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \
	-DPREFIX=\"$(prefix)\" \
	  -c $(srcdir)/prefix.c

intl.o: intl.c intl.h Makefile
	$(CC) $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \
	  -DLOCALEDIR=\"$(localedir)\" \
	  -c $(srcdir)/intl.c

#
# Remake cpp and protoize.

PREPROCESSOR_DEFINES = \
  -DGCC_INCLUDE_DIR=\"$(libsubdir)/include\" \
  -DGPLUSPLUS_INCLUDE_DIR=\"$(gcc_gxx_include_dir)\" \
  -DGPLUSPLUS_TOOL_INCLUDE_DIR=\"$(gcc_gxx_include_dir)/$(target_alias)\" \
  -DGPLUSPLUS_BACKWARD_INCLUDE_DIR=\"$(gcc_gxx_include_dir)/backward\" \
  -DLOCAL_INCLUDE_DIR=\"$(includedir)\" \
  -DCROSS_INCLUDE_DIR=\"$(gcc_tooldir)/sys-include\" \
  -DTOOL_INCLUDE_DIR=\"$(gcc_tooldir)/include\"

LIBCPP_OBJS =	cpplib.o cpplex.o cppmacro.o cppexp.o cppfiles.o \
		cpphash.o cpperror.o cppinit.o cppdefault.o \
		hashtable.o mkdeps.o prefix.o version.o mbchar.o

LIBCPP_DEPS =	cpplib.h cpphash.h hashtable.h intl.h $(OBSTACK_H) $(SYSTEM_H)

# Most of the other archives built/used by this makefile are for
# targets.  This one is strictly for the host.
libcpp.a: $(LIBCPP_OBJS)
	-rm -rf libcpp.a
	$(AR) $(AR_FLAGS) libcpp.a $(LIBCPP_OBJS)
	-$(RANLIB) libcpp.a

MY_LIBIBERTY_BITS = safe-ctype.o obstack.o splay-tree.o \
		    lbasename.o

$(TARGET): cppmain.o intl.o $(MY_LIBIBERTY_BITS) libcpp.a $(LIBDEPS) 
	$(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ cppmain.o \
	$(MY_LIBIBERTY_BITS) libcpp.a $(LIBS)

cppmain.o:  cppmain.c  $(CONFIG_H) cpplib.h intl.h $(SYSTEM_H)

cpperror.o: cpperror.c $(CONFIG_H) $(LIBCPP_DEPS)
cppexp.o:   cppexp.c   $(CONFIG_H) $(LIBCPP_DEPS)
cpplex.o:   cpplex.c   $(CONFIG_H) $(LIBCPP_DEPS) mbchar.h
cppmacro.o: cppmacro.c $(CONFIG_H) $(LIBCPP_DEPS)
cpplib.o:   cpplib.c   $(CONFIG_H) $(LIBCPP_DEPS)
cpphash.o:  cpphash.c  $(CONFIG_H) $(LIBCPP_DEPS)
cppfiles.o: cppfiles.c $(CONFIG_H) $(LIBCPP_DEPS) $(SPLAY_TREE_H) mkdeps.h
cppinit.o:  cppinit.c  $(CONFIG_H) $(LIBCPP_DEPS) cppdefault.h \
		mkdeps.h prefix.h output.h version.h
safe-ctype.o: $(LIBIBERTY_DIR)/safe-ctype.c $(LIBIBERTY_DIR)/safe-ctype.h $(CONFIG_H) $(LIBCPP_DEPS)
	$(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) $< $(OUTPUT_OPTION)
obstack.o: $(LIBIBERTY_DIR)/obstack.c $(LIBIBERTY_DIR)/obstack.h $(CONFIG_H) $(LIBCPP_DEPS)
	$(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) $< $(OUTPUT_OPTION)
splay-tree.o: $(LIBIBERTY_DIR)/splay-tree.c $(LIBIBERTY_DIR)/splay-tree.h $(CONFIG_H) $(LIBCPP_DEPS)
	$(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) $< $(OUTPUT_OPTION)
lbasename.o: $(LIBIBERTY_DIR)/lbasename.c  $(CONFIG_H) $(LIBCPP_DEPS)
	$(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) $< $(OUTPUT_OPTION)
cppdefault.o: cppdefault.c $(CONFIG_H) $(SYSTEM_H) cppdefault.h Makefile
	$(CC) $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \
	  $(PREPROCESSOR_DEFINES) \
	  -c $(srcdir)/cppdefault.c

mkdeps.o: mkdeps.c $(CONFIG_H) $(SYSTEM_H) mkdeps.h

