# Edison Design Group C++ Front End.
# Top-level Makefile.
#
# make             Build the front end, runtime, and utility programs using
#                    an ANSI/ISO C compiler, putting the results in the lib
#                    and bin directories.  To change the name of the compiler
#                    to be used, change the definition of CXX.
# make clean       Clean all directories, keeping executables.
# make clobber     Clean all directories, deleting executables (but keeping
#                    the copies of those in the lib and bin directories).
#
# If you don't provide a src/defines.h file of your own, one will be fabricated
# by concatenating the src/defines.h.proto file and the output of running
# the misc/dettarg program.  This will do the absolute minimum configuration;
# you will probably want to do more at some point.  See the configuration
# section of the internal documentation.
#
# For a few environments, we've provided a preconfigured defines.h
# that you may prefer to the one generated by default:
#
# For Windows:       src/defines.h.win32
# For Linux:         src/defines.h.linux
# For MacOS X:       src/defines.h.macosx
# For Solaris:       src/defines.h.solaris
#
# You should copy the file of your choice to src/defines.h.

# On Windows, if you have the front end configured to allow C++/CLI
# (see CPPCLI_ENABLING_POSSIBLE), you will need the alink.h header, which
# Microsoft makes available at http://code.msdn.microsoft.com/alink,
# and you will need to add a compilation of src/ms_metadata.cpp, as
# a C++ file.  You will also need to link with mscoree.lib and
# oleaut32.lib (see LLIBS below).  There's more information in
# the src/msinfo.txt file.

# CXX can be set to the C++14 compiler to be used
CXX = g++

# Options to be passed to the linker
LDFLAGS=-std=c++14

# Options for C compilations
# Note that if you set your own value for CXXFLAGS you're not required to
# set IL_SHOULD_BE_WRITTEN_TO_FILE.  If you don't, the IL display program
# is built anyway, but you won't be able to use it because you won't be
# able to make the front end write out an IL file.
CXXFLAGS = $(LDFLAGS) -x c++ -DIL_SHOULD_BE_WRITTEN_TO_FILE

# Link library options for src directory linking
# Some systems may require -lm for the math library to get the
# IEEE floating-point testing routines, e.g. "finite".
LLIBS=

default:
	@(cd misc; $(MAKE) "CXX=$(CXX)" "CXXFLAGS=$(CXXFLAGS)" \
	                    "LDFLAGS=$(LDFLAGS)" config)
	@(cd src; $(MAKE) "CXX=$(CXX)" "CXXFLAGS=$(CXXFLAGS)" \
	                  "LDFLAGS=$(LDFLAGS)" "LLIBS=$(LLIBS)" install)
	@(cd util; $(MAKE) "CXX=$(CXX)" "CXXFLAGS=$(CXXFLAGS)" \
	                   "LDFLAGS=$(LDFLAGS)" install)
	@(cd lib_src; $(MAKE) install)

clean:
	@(cd misc; $(MAKE) clean)
	@(cd src; $(MAKE) clean)
	@(cd util; $(MAKE) clean)
	@(cd lib_src; $(MAKE) clean)

clobber:
	@(cd misc; $(MAKE) clobber)
	@(cd src; $(MAKE) clobber)
	@(cd util; $(MAKE) clobber)
	@(cd lib_src; $(MAKE) clobber)
