# @configure_input@ -*- makefile -*-
ifneq ($(CONFIG_MAKEFILE),)
$(error config.Makefile already loaded)
endif
CONFIG_MAKEFILE = loaded
.PHONY: all check initialize clean distclean install always reconfigure big-check
all:

SHELL = /bin/sh

.DELETE_ON_ERROR:

# here we set the variables that "make" uses
CC = @CC@
CXX = @CXX@
FC = @FC@
CFLAGS = @CFLAGS@
CPPFLAGS = @CPPFLAGS@
CXXFLAGS = @CXXFLAGS@
FCFLAGS = @FCFLAGS@
LDFLAGS = @LDFLAGS@

# Macaulay 2 file system layout definitions, dependent on $(prefix) and PackageName.
#  see http://www.pathname.com/fhs/
#      http://fink.sourceforge.net/doc/packaging/fslayout.php
#      http://cr.yp.to/unix.html, the section on "Filesystem layout"

### Here we set the make-variables that configure uses as make-variables inside configure-variables.
# The user may override only "prefix" and "exec_prefix"
prefix = @prefix@
exec_prefix = @exec_prefix@
datarootdir = @datarootdir@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
docdir = @docdir@

# We assume relative positions of files within the tree are known to the configure script.
# Thus the user should not override these on the "make" command line, but may
# override them on the "configure" command line instead:
pre_prefix = @pre_prefix@
pre_exec_prefix = @pre_exec_prefix@
# we want to ignore the --datarootdir setting, whatever that means, so here we we mention it: @datarootdir@
abs_top_srcdir = @abs_top_srcdir@


INSTALL = @INSTALL@

# we can't use -isystem instead of -I for our library include files, because then they might be supplanted
# by older include files in a directory specified by the user with CPPFLAGS=-I/foo/bar, causing
# version skew (gcc preprocessor searches -I directories first, then -isystem directories)

BUILTLIBPATH = @abs_top_builddir@/libraries/final
CPPFLAGS := \
	 -I@abs_top_srcdir@/include \
	 -I@abs_top_builddir@/include \
	 -I$(BUILTLIBPATH)/include \
	 $(CPPFLAGS)
vpath %.h $(BUILTLIBPATH)/include
LDFLAGS := -L$(BUILTLIBPATH)/lib $(LDFLAGS)
vpath %.a $(BUILTLIBPATH)/lib
vpath %.o $(BUILTLIBPATH)/lib
vpath %.so $(BUILTLIBPATH)/lib
LD_LIBRARY_PATH := $(BUILTLIBPATH)/lib:$(LD_LIBRARY_PATH)
export LD_LIBRARY_PATH
export PATH := @abs_top_srcdir@/bin:${PATH}
AR = ar
ifeq (,$(findstring --no-print-directory,$(word 1,$(MAKEFLAGS))))
MAKEFLAGS += -w
endif
ifeq "@OS@ @ARCH@" "Linux alpha"
AS = gcc -c -x assembler-with-cpp
endif
M2_CPPFLAGS += @M2_CPPFLAGS@
ifeq "@GCC@" "yes"
# if it's gcc, we can get stricter warning and error messages
ifneq ($(RELAX),yes)
# but sometimes that's bad, e.g., during configure scripts with loosely written test programs
# -Winline gives too many warning messages

M2_BOTH = -pipe -Wall -Wshadow -Wcast-qual

# use no GNU extensions
# CXXFLAGS += -std=c++98
# using -std=c99 is a bad idea, because in ubuntu, this standard causes __USE_POSIX to be undefined, 
#   hence sigjmp_buf to be undefined, which is needed by gc
# CFLAGS += -std=c99

ifeq "@__INTEL_COMPILER@" "yes"
X = -diag-disable 981,869,383,2259,444
CFLAGS += $X
CXXFLAGS += $X
ifeq "@DEBUG@" "yes"
CFLAGS += -debug
CXXFLAGS += -debug
LDFLAGS += -debug
endif
else
M2_BOTH += -Wno-parentheses
M2_BOTH += -Wno-sign-compare 
endif

M2_BOTH += -fno-stack-protector

ifeq "@OPTIMIZE@" "yes"
# gcc 3.3.2 doesn't accept this:
# M2_BOTH += -Werror=uninitialized
M2_BOTH += -Wuninitialized
endif
# M2_CFLAGS   += -Werror=implicit-function-declaration -Werror=write-strings $(M2_BOTH)
ifeq "@__INTEL_COMPILER@" "no"
M2_CFLAGS   += -Wimplicit-function-declaration
endif
M2_CFLAGS   += -Wwrite-strings $(M2_BOTH)
M2_CXXFLAGS += -Wconversion $(M2_BOTH)
# -Werror-implicit-function-declaration is important, because if we include the wrong include file and a function that
# returns a 64-bit pointer is not declared as such, then only 32 bits of the return value will be used.
endif
endif
STRIPCMD = @STRIPCMD@
ifeq "$(STRIP)" "yes"
ifneq "@OS@" "Darwin"
LDFLAGS  += -s
endif
endif
MKDIR_P = @INSTALL@ -d
always:

# pari tends to display plots during its tests, and we don't want that:
export DISPLAY=

# Safe C language:
SCCFLAGS =
ifeq "@DEBUG@" "no"
SCCFLAGS += -O
endif
SCC1 = @abs_top_builddir@/Macaulay2/c/scc1

# scc1 output files

ifeq "$(NORULES)" ""

.SUFFIXES : .sig.tmp .sig .dep .d .dd -exports.h.tmp -exports.h -tmp.c -tmp.cc

%.sig: ;	test -e $*.sig && cmp -s $*.sig.tmp $*.sig || cp $*.sig.tmp $*.sig
%-exports.h: ;	test -e $*-exports.h && cmp -s $*-exports.h.tmp $*-exports.h || cp $*-exports.h.tmp $*-exports.h

%.sig.tmp %.dep: %.d
	$(SCC1) -dep $(SCCFLAGS) $<
	mv $*.dep.tmp $*.dep
	test -e $*.sig && cmp -s $*.sig.tmp $*.sig || cp $*.sig.tmp $*.sig
%.sig.tmp %.dep: %.dd
	$(SCC1) -dep $(SCCFLAGS) $<
	mv $*.dep.tmp $*.dep
	test -e $*.sig && cmp -s $*.sig.tmp $*.sig || cp $*.sig.tmp $*.sig
%-tmp.c  %-exports.h.tmp: %.d
	$(SCC1) $(SCCFLAGS) $<
	test -e $*-exports.h && cmp -s $*-exports.h.tmp $*-exports.h || cp $*-exports.h.tmp $*-exports.h
%-tmp.cc %-exports.h.tmp: %.dd
	$(SCC1) $(SCCFLAGS) $<
	test -e $*-exports.h && cmp -s $*-exports.h.tmp $*-exports.h || cp $*-exports.h.tmp $*-exports.h
%.o: %-tmp.c  %-exports.h;		$(COMPILE.c)  $(DCFLAGS) $< $(OUTPUT_OPTION)
%.o: %-tmp.cc %-exports.h;		$(COMPILE.cc) $(DCFLAGS) $< $(OUTPUT_OPTION)

# various compiler output files
.SUFFIXES : .ss .ii .s
%.ss: %.s; demangle <$< >$@
%.ii: %.cpp; $(PRE.cc)        $< $(OUTPUT_OPTION)
%.s : %.cpp; $(COMPILE.cc) -S $< $(OUTPUT_OPTION)
%.ii: %.cc; $(PRE.cc)        $< $(OUTPUT_OPTION)
%.s : %.cc; $(COMPILE.cc) -S $< $(OUTPUT_OPTION)
%.ii: %.c; $(PRE.c)        $< $(OUTPUT_OPTION)
%.s : %.c; $(COMPILE.c) -S $< $(OUTPUT_OPTION)

endif

# libgc
export GC_LARGE_ALLOC_WARN_INTERVAL=1

# Local Variables:
# compile-command: "make -C $M2BUILDDIR include/config.Makefile DEPENDS=no "
# End:
