##########################################################################
#                            arm-run & arm-tracer                        #
#                                                                        #
#   Pankaj More, IIT Kanpur & INRIA Paris-Rocquencourt                   #
#   Francesco Zappa Nardelli, INRIA Paris-Rocquencourt                   #
#                                                                        #
#  The arm-run and arm-tracer tools are copyright 2012, 2013 Institut    #
#  National de Recherche en Informatique et en Automatique (INRIA).      #
#                                                                        #
#  Redistribution and use in source and binary forms, with or without    #
#  modification, are permitted provided that the following conditions    #
#  are met:                                                              #
#  1. Redistributions of source code must retain the above copyright     #
#  notice, this list of conditions and the following disclaimer.         #
#  2. Redistributions in binary form must reproduce the above copyright  #
#  notice, this list of conditions and the following disclaimer in the   #
#  documentation and/or other materials provided with the distribution.  #
#  3. The names of the authors may not be used to endorse or promote     #
#  products derived from this software without specific prior written    #
#  permission.                                                           #
#                                                                        #
#  THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS    #
#  OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED     #
#  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE    #
#  ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY       #
#  DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL    #
#  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE     #
#  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS         #
#  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER  #
#  IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR       #
#  OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN   #
#  IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.                         #
#                                                                        #
#  *******************************************************************   #
#                                                                        #
#  *******************************************************************   #
#                                                                        #
#                               arm-run                                  #
#                                                                        #
#  The arm-run tool is copyright 2010 - 2013 Anthony Fox, Magnus Myreen  #
#  and Mike Gordon, Computer Laboratory, University of Cambridge.        #
#                                                                        #
#  Redistribution and use in source and binary forms, with or without    #
#  modification, are permitted provided that the following conditions    #
#  are met:                                                              #
#  1. Redistributions of source code must retain the above copyright     #
#  notice, this list of conditions and the following disclaimer.         #
#  2. Redistributions in binary form must reproduce the above copyright  #
#  notice, this list of conditions and the following disclaimer in the   #
#  documentation and/or other materials provided with the distribution.  #
#  3. The names of the authors may not be used to endorse or promote     #
#  products derived from this software without specific prior written    #
#  permission.                                                           #
#                                                                        #
#  THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS    #
#  OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED     #
#  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE    #
#  ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY       #
#  DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL    #
#  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE     #
#  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS         #
#  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER  #
#  IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR       #
#  OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN   #
#  IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.                         #
#                                                                        #
##########################################################################

# Uncomment the path to polyml lib but don't forget to comment it if commit changes to the Makefile

POLYLIB = /Users/zappa/sources/polyml.5.5.bin/lib
#POLYLIB = /usr/lib

UNAME := $(shell uname)
ifeq ($(UNAME), Linux)
# do something Linux-y
default: run arm_tracer
endif
ifeq ($(UNAME), Darwin)
default: run-mac arm_tracer
endif


clean:
	rm -f HOLarm.o
	rm -f arm_run
	rm -f arm_tracer

HOLarm.o: *.sml *.sig
	poly < emit_eval.sml

run-mac: HOLarm.o
	gcc -o arm_run HOLarm.o -L${POLYLIB} -lpolymain -lpolyml -segprot POLY rwx rwx

run: HOLarm.o
	gcc -o arm_run HOLarm.o -L${POLYLIB} -lpolymain -lpolyml

arm_tracer: arm_tracer.ml
	ocamlopt -dtypes str.cmxa unix.cmxa arm_tracer.ml -o arm_tracer
