aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2014-11-05 20:47:13 +0100
committerTristan Gingold <tgingold@free.fr>2014-11-05 20:47:13 +0100
commit81cd0858f805c9339cce3a85c620ec7d44c6d5a7 (patch)
treef576ba348f5eaf3237b44a874125603a466111b5
parent8b90118c3e035f191670cfa978ab1d81a93b54df (diff)
downloadghdl-81cd0858f805c9339cce3a85c620ec7d44c6d5a7.tar.gz
ghdl-81cd0858f805c9339cce3a85c620ec7d44c6d5a7.tar.bz2
ghdl-81cd0858f805c9339cce3a85c620ec7d44c6d5a7.zip
Add configure and Makefile.in for mcode.
-rw-r--r--Makefile.in192
-rw-r--r--configure130
2 files changed, 322 insertions, 0 deletions
diff --git a/Makefile.in b/Makefile.in
new file mode 100644
index 000000000..c8b73908a
--- /dev/null
+++ b/Makefile.in
@@ -0,0 +1,192 @@
+# Top level -*- Makefile -*- for GHDL.
+# Copyright (C) 2002 - 2014 Tristan Gingold
+#
+# GHDL is free software; you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free
+# Software Foundation; either version 2, or (at your option) any later
+# version.
+#
+# GHDL 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
+# along with GCC; see the file COPYING. If not, write to the Free
+# Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+CC=@CC@
+build=@build@
+srcdir=@srcdir@
+GNATMAKE=@GNATMAKE@
+
+GNATFLAGS=-gnaty3befhkmr -gnata -gnatwael -aI../.. -aI.. -aI../../psl -aI../grt -aO.. -g -gnatf -gnat05
+GRT_FLAGS=-g
+LIB_CFLAGS=-g -O2
+
+# Optimize, do not forget to use MODE=--genfast for iirs.adb.
+#GNATFLAGS+=-O -gnatn
+#GRT_FLAGS+=-O
+
+# Profiling.
+#GNATFLAGS+=-pg -gnatn -O
+#GRT_FLAGS+=-pg -O
+
+# Coverage
+#GNATFLAGS+=-fprofile-arcs -ftest-coverage
+
+GNAT_BARGS=-bargs -E
+
+LLVM_CONFIG=llvm-config
+
+all: Makefile ghdl_mcode
+
+Makefile: $(srcdir)/Makefile.in
+ ./config.status
+
+target=$(build)
+#target=i686-pc-linux-gnu
+#target=x86_64-pc-linux-gnu
+#target=i686-apple-darwin
+#target=x86_64-apple-darwin
+#target=i386-pc-mingw32
+
+GRTSRCDIR=$(srcdir)/src/grt
+include $(GRTSRCDIR)/Makefile.inc
+
+ifeq ($(filter-out i%86 linux,$(arch) $(osys)),)
+ ORTHO_X86_FLAGS=Flags_Linux
+endif
+ifeq ($(filter-out i%86 darwin%,$(arch) $(osys)),)
+ ORTHO_X86_FLAGS=Flags_Macosx
+endif
+ifeq ($(filter-out i%86 mingw32%,$(arch) $(osys)),)
+ ORTHO_X86_FLAGS=Flags_Windows
+endif
+ifdef ORTHO_X86_FLAGS
+ ORTHO_DEPS=ortho_code-x86-flags.ads
+endif
+
+ortho_code-x86-flags.ads:
+ echo "with Ortho_Code.X86.$(ORTHO_X86_FLAGS);" > $@
+ echo "package Ortho_Code.X86.Flags renames Ortho_Code.X86.$(ORTHO_X86_FLAGS);" >> $@
+
+ghdl_mcode: GRT_FLAGS+=-DWITH_GNAT_RUN_TIME
+ghdl_mcode: default_pathes.ads $(GRT_ADD_OBJS) $(ORTHO_DEPS) memsegs_c.o chkstk.o force
+ $(GNATMAKE) -o $@ -aI$(srcdir)/src -aI$(srcdir)/src/vhdl -aI$(srcdir)/src/psl -aI$(srcdir)/src/ghdldrv -aI$(srcdir)/src/grt -aI$(srcdir)/src/vhdl/translate -aI$(srcdir)/src/ortho/mcode -aI$(srcdir)/src/ortho $(GNATFLAGS) ghdl_jit.adb $(GNAT_BARGS) -largs memsegs_c.o chkstk.o $(GNAT_LARGS) $(GRT_ADD_OBJS) $(subst @,$(GRTSRCDIR),$(GRT_EXTRA_LIB))
+
+memsegs_c.o: $(srcdir)/src/ortho/mcode/memsegs_c.c
+ $(CC) -c -g -o $@ $<
+
+ghdl_llvm_jit: GRT_FLAGS+=-DWITH_GNAT_RUN_TIME
+ghdl_llvm_jit: default_pathes.ads $(GRT_ADD_OBJS) $(ORTHO_DEPS) llvm-cbindings.o force
+ $(GNATMAKE) -o $@ -aI../../ortho/llvm -aI../../ortho $(GNATFLAGS) ghdl_jit.adb $(GNAT_BARGS) -largs llvm-cbindings.o $(GNAT_LARGS) $(GRT_ADD_OBJS) $(subst @,$(GRTSRCDIR),$(GRT_EXTRA_LIB)) `$(LLVM_CONFIG) --ldflags --libs --system-libs` -lc++
+
+llvm-cbindings.o: ../../ortho/llvm/llvm-cbindings.cpp
+ $(CXX) -c -m64 `$(LLVM_CONFIG) --includedir --cxxflags` -g -o $@ $<
+
+ghdl_simul: default_pathes.ads $(GRT_ADD_OBJS) force
+ $(GNATMAKE) -aI../../simulate $(GNATFLAGS) ghdl_simul $(GNAT_BARGS) -largs $(GNAT_LARGS) $(GRT_ADD_OBJS) $(subst @,$(GRTSRCDIR),$(GRT_EXTRA_LIB))
+
+ghdl_gcc: default_pathes.ads force
+ $(GNATMAKE) $(GNATFLAGS) ghdl_gcc $(GNAT_BARGS) -largs $(GNAT_LARGS)
+
+ghdl_llvm: default_pathes.ads force
+ $(GNATMAKE) $(GNATFLAGS) ghdl_llvm $(GNAT_BARGS) -largs $(GNAT_LARGS)
+
+default_pathes.ads: $(srcdir)/src/ghdldrv/default_pathes.ads.in Makefile
+ curdir=`pwd`; \
+ sed -e "s%@COMPILER_GCC@%ghdl1-gcc%" \
+ -e "s%@COMPILER_DEBUG@%ghdl1-debug%" \
+ -e "s%@COMPILER_MCODE@%ghdl1-mcode%" \
+ -e "s%@COMPILER_LLVM@%ghdl1-llvm%" \
+ -e "s%@POST_PROCESSOR@%oread-gcc%" \
+ -e "s%@INSTALL_PREFIX@%%" \
+ -e "s%@LIB_PREFIX@%$$curdir/lib/%" < $< > $@
+
+LIB87_DIR:=lib/v87
+LIB93_DIR:=lib/v93
+LIB08_DIR:=lib/v08
+
+LIBSRC_DIR:=libraries
+REL_DIR:=../../..
+GHDL=ghdl
+ANALYZE:=../../../$(GHDL) -a $(LIB_CFLAGS)
+LN=ln -s
+CP=cp
+
+$(LIB87_DIR) $(LIB93_DIR) $(LIB08_DIR):
+ [ -d lib ] || mkdir lib
+ [ -d $@ ] || mkdir $@
+
+include $(srcdir)/libraries/Makefile.inc
+
+GHDL1=./ghdl1-gcc
+$(LIB93_DIR)/std/std_standard.o: $(GHDL1)
+ifeq ($(GHDL),ghdl_llvm)
+ $(GHDL1) --std=93 -quiet $(LIB_CFLAGS) -c -o $@ --compile-standard
+else
+ $(GHDL1) --std=93 -quiet $(LIB_CFLAGS) -o std_standard.s \
+ --compile-standard
+ $(CC) -c -o $@ std_standard.s
+ $(RM) std_standard.s
+endif
+
+$(LIB87_DIR)/std/std_standard.o: $(GHDL1)
+ifeq ($(GHDL),ghdl_llvm)
+ $(GHDL1) --std=87 -quiet $(LIB_CFLAGS) -c -o $@ --compile-standard
+else
+ $(GHDL1) --std=87 -quiet $(LIB_CFLAGS) -o std_standard.s \
+ --compile-standard
+ $(CC) -c -o $@ std_standard.s
+ $(RM) std_standard.s
+endif
+
+$(LIB08_DIR)/std/std_standard.o: $(GHDL1)
+ifeq ($(GHDL),ghdl_llvm)
+ $(GHDL1) --std=08 -quiet $(LIB_CFLAGS) -c -o $@ --compile-standard
+else
+ $(GHDL1) --std=08 -quiet $(LIB_CFLAGS) -o std_standard.s \
+ --compile-standard
+ $(CC) -c -o $@ std_standard.s
+ $(RM) std_standard.s
+endif
+
+install.v93: std.v93 ieee.v93 synopsys.v93 mentor.v93
+install.v87: std.v87 ieee.v87 synopsys.v87
+install.v08: std.v08 ieee.v08
+
+install.standard: $(LIB93_DIR)/std/std_standard.o \
+ $(LIB87_DIR)/std/std_standard.o \
+ $(LIB08_DIR)/std/std_standard.o
+
+grt.links:
+ cd ../lib; ln -sf $(GRTSRCDIR)/grt.lst .; ln -sf $(GRTSRCDIR)/libgrt.a .; ln -sf $(GRTSRCDIR)/grt.ver .
+
+install.all: install.v87 install.v93 install.v08
+
+install.gcc:
+ $(MAKE) GHDL=ghdl_gcc install.all
+ $(MAKE) GHDL1=./ghdl1-gcc install.standard
+
+install.mcode:
+ $(MAKE) GHDL=ghdl_mcode install.all
+
+install.simul:
+ $(MAKE) GHDL=ghdl_simul install.all
+
+install.llvm:
+ $(MAKE) GHDL=ghdl_llvm install.all
+ $(MAKE) GHDL1=./ghdl1-llvm install.standard
+
+clean: force
+ $(RM) -f *.o *.ali b~*.ad? ghdl_gcc ghdl_mcode ghdl_llvm ghdl_llvm_jit
+ $(RM) -f *~ default_pathes.ads ghdl_simul ortho_code-x86-flags.ads
+ $(RM) -rf lib
+
+clean-c: force
+ $(RM) -f memsegs_c.o chkstk.o linux.o times.o grt-cbinding.o grt-cvpi.o
+
+force:
+
+.PHONY: force clean
diff --git a/configure b/configure
new file mode 100644
index 000000000..6aea32d84
--- /dev/null
+++ b/configure
@@ -0,0 +1,130 @@
+#!/bin/sh
+#
+# configure script for ghdl (c) 2014 Tristan Gingold
+#
+
+backend=mcode
+CC=${CC:-gcc}
+CFLAGS=${CFLAGS:--g}
+GNATMAKE=${GNATMAKE:-gnatmake}
+prefix=/usr/local
+build=
+
+show_help=no
+progname=$0
+
+subst_vars="CC GNATMAKE CFLAGS build srcdir"
+
+# Find srcdir
+srcdir=`dirname $progname`
+if test x$srcdir = x; then
+ srcdir=.
+fi
+
+# Check echo -n / echo \c
+if test x`echo -n` = x"-n" ; then
+ echon=""
+ echoc="\c"
+else
+ echon="-n"
+ echoc=""
+fi
+
+# Decode options
+for opt do
+ optarg=`expr x$opt : 'x[^=]*=\(.*\)'`
+ case "$opt" in
+ CC=*|CFLAGS=*|GNATMAKE=*)
+ optvar=`expr x$opt : 'x\([^=]*\)=.*'`
+ eval $optvar="$optarg"
+ ;;
+ --prefix=*) prefix="$optarg";;
+ --srcdir=*) srcdir="$optarg";;
+ -h|-help|--help) show_help=yes;;
+ *) echo "$0: unknown option $opt; try $0 --help"
+ exit 1
+ ;;
+ esac
+done
+
+if test $show_help != no; then
+cat <<EOF
+Usage: configure [options]
+
+Options [defaults in brackets]:
+ --prefix=PREFIX install in PREFIX [$prefix]
+ --srcdir=SRCDIR source code path [$srcdir]
+EOF
+exit 0
+fi
+
+# Sanity checks
+# Check that gnatmake exists
+if ! $GNATMAKE 2> /dev/null; then
+ echo "Sorry, you need GNAT to build GHDL. See the README"
+ echo "(gnatmake is $GNATMAKE)"
+ exit 1
+fi
+
+# Check that compiler exists
+if ! $CC -v 2> /dev/null; then
+ echo "Sorry, you need a C compiler to build GHDL. See the README"
+ exit 1
+fi
+
+# For mcode, check that gcc emits i386
+if test $backend = mcode; then
+ if ! $CC $CFLAGS -dumpmachine | grep -q "[3-6]86"; then
+ echo "WARNING: GHDL for mcode is supported only on x86 (32 bits)"
+ echo "continuing, but build failure expected (See the README)"
+ fi
+fi
+
+# Compute build machine
+if test x$build = x; then
+ build=`$CC $CFLAGS -dumpmachine`
+fi
+echo "Build machine is: $build"
+
+# Generate config.status
+rm -f config.status
+{
+echo "#! /bin/sh"
+echo "# Generated by configure."
+echo "# Run this file to recreate the current configuration."
+echo
+echo "# Generated by:"
+echo $echon "# $progname" $echoc
+for opt do
+ echo $echon " " $opt $echoc
+done
+echo
+echo
+echo subst_vars=\"$subst_vars\"
+for v in $subst_vars; do
+ eval vval=\$$v
+ echo $v="$vval"
+done
+echo
+echo 'sed_opts=""'
+echo 'for v in $subst_vars; do'
+echo ' eval vval=\$$v'
+echo ' sed_opts="$sed_opts -e s/@${v}@/$vval/g"'
+echo 'done'
+echo
+echo 'echo "Creating Makefile"'
+echo 'sed $sed_opts < $srcdir/Makefile.in > Makefile'
+} > config.status || \
+{
+ echo "$progname: cannot create config.status"
+ exit 1
+}
+
+chmod +x ./config.status
+
+if ! sh ./config.status; then
+ echo "$progname: cannot execute config.status"
+ exit 1
+fi
+
+exit 0