#  $Id: makefile_public 12201 2009-01-19 11:14:21Z Bill Ellis $
#-------------------------------------------------------------------------------
#  (C) Praxis High Integrity Systems 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 Sparksimp utility
# For Win, Solaris, Mac OS X (aka Darwin) or Linux.
################################################################################


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

# Name of the output program.
OUTPUTNAME:=sparksimp


################################################################################
# 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 -gnatwaY -gnat95 -gnaty3abefhiklnprt -I${COMMON}/versioning
gnatmakeopts:= ${commonopts} -O1
gccopts:=
bindopts:= -E
link_args:= new_expect.o


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

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

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

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

# Darwin (Mac OS X).
ifeq (${TARGET},Darwin)
    EXEEXTN:=
    # On Darwin, we don't have working GNAT.Traceback.Symbolic,
    # so force recompilation of local g-trasym.adb by adding -a
    gnatmakeopts:= -a ${gnatmakeopts}
    preptarget:=Darwin
endif


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

all: ${OUTPUTNAME}${EXEEXTN}


################################################################################
# BUILDS
################################################################################


${OUTPUTNAME}${EXEEXTN}: new_expect.o
	gnatmake ${gnatmakeopts} sparksimp -o ${OUTPUTNAME}${EXEEXTN} -cargs ${gccopts} -bargs ${bindopts} -largs ${link_args}

new_expect.o: new_expect.c
	gcc -c -g -O1 -D${preptarget} new_expect.c

clean:
	rm -f *.o *.ali

reallyclean: clean
	rm -f ${OUTPUTNAME}${EXEEXTN}
	rm -f b~*.ad?


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