#  $Id: makefile_public 15546 2010-01-11 14:35:16Z Robin Messer $
#-------------------------------------------------------------------------------
#  (C) Altran Praxis Limited
#-------------------------------------------------------------------------------
# 
#  The SPARK toolset is free software; you can redistribute it and/or modify it
#  under terms of the GNU General Public License as published by the Free
#  Software Foundation; either version 3, or (at your option) any later
#  version. The SPARK toolset 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 distributed with the SPARK toolset; see file
#  COPYING3. If not, go to http://www.gnu.org/licenses for a complete copy of
#  the license.
# 
#===============================================================================


################################################################################
# PURPOSE
#-------------------------------------------------------------------------------
# Makefile for the Sparkmake utility
# For Win, Solaris, Mac OS X (aka Darwin) or Linux.
################################################################################


################################################################################
# BUILD CONFIGURATION
################################################################################

# Name of the output program.
OUTPUTNAME:=sparkmake

################################################################################
# DETERMINE HOST INFORMATION
################################################################################

# Determine which platform this makefile is being run on.
TARGET:=$(shell uname -s)

# Canonicalize the target string.
ifeq ($(findstring CYGWIN_NT,${TARGET}),CYGWIN_NT)
    TARGET:=Windows
endif


################################################################################
# PLATFORM INDEPENDENT CONFIGURATION
################################################################################

ROOT:=..
COMMON:=${ROOT}/common
commonopts:= -g -gnatwa -gnat05 -gnaty3abefhiklnprt -I${ROOT}/examiner -I${COMMON}/versioning
gnatmakeopts:= ${commonopts} -O1
gccopts:=
bindopts:= -E
link_args:=


################################################################################
# PLATFORM SPECIFIC CONFIGURATION
################################################################################

# Windows.
ifeq (${TARGET},Windows)
    EXEEXTN:=.exe
endif

# Solaris.
ifeq (${TARGET},SunOS)
    EXEEXTN:=
endif

# Linux.
ifeq (${TARGET},Linux)
    EXEEXTN:=
endif

# Darwin (Mac OS X 10.5 or 10.6, 64-bit).
ifeq (${TARGET},Darwin)
    # Force local compilation of GNAT.Traceback.Symbolic in
    # ../examiner/g-trasym.adb
    gnatmakeopts:= -a ${gnatmakeopts}
    EXEEXTN:=
endif


################################################################################
# TARGETS
################################################################################

all: ${OUTPUTNAME}${EXEEXTN}

examine: preamble prep parser
	spark @sparkmake.smf

examineplain: preamble prep parser
	spark -plain @sparkmake.smf

${OUTPUTNAME}${EXEEXTN}: preamble prep parser
	gnatmake ${gnatmakeopts} sparkmake -o ${OUTPUTNAME}${EXEEXTN} -cargs ${gccopts} -bargs ${bindopts} -largs ${link_args}

preamble:
	make -C ${ROOT}/examiner clean

prep:
	make -C ${ROOT}/examiner prep

parser:
	make -C ${ROOT}/examiner parser

clean:
	rm -f *.o *.ali

reallyclean: clean
	rm -f ${OUTPUTNAME}${EXEEXTN}
	rm -f *.lsb *.lss *.sli spark.rep
	rm -f b~*.ad?


################################################################################
# END-OF-FILE
