diff options
-rw-r--r-- | Makefile.in | 79 | ||||
-rw-r--r-- | README | 21 | ||||
-rwxr-xr-x | configure | 32 |
3 files changed, 116 insertions, 16 deletions
diff --git a/Makefile.in b/Makefile.in index 64353db82..753fb792b 100644 --- a/Makefile.in +++ b/Makefile.in @@ -23,16 +23,22 @@ prefix=@prefix@ backend=@backend@ libdirsuffix=@libdirsuffix@ libdirreverse=@libdirreverse@ +gcc_src_dir=@gcc_src_dir@ INSTALL_PROGRAM=install -m 755 INSTALL_DATA=install -m 644 DESTDIR= bindir=$(prefix)/bin MKDIR=mkdir +LN=ln -s +CP=cp +SED=sed +GRT_RANLIB=ranlib VHDL_LIB_DIR=$(prefix)/$(libdirsuffix) +ADAC=$(CC) -GNATFLAGS=-gnaty3befhkmr -gnata -gnatwael -aO. -g -gnatf -gnat05 +GNATFLAGS=-gnaty3befhkmr -gnatwael -aO. -g -gnatf -gnat05 GRT_FLAGS=-g LIB_CFLAGS=-g -O2 @@ -64,9 +70,13 @@ install: install.$(backend) check: check.$(backend) +copy-sources: copy-sources.$(backend) + Makefile: $(srcdir)/Makefile.in ./config.status +#################### For mcode backend ############################## + all.mcode: ghdl.mcode libs.vhdl.mcode GRTSRCDIR=$(srcdir)/src/grt @@ -83,6 +93,58 @@ ghdl.mcode: $(GRT_ADD_OBJS) $(ORTHO_DEPS) memsegs_c.o chkstk.o force memsegs_c.o: $(srcdir)/src/ortho/mcode/memsegs_c.c $(CC) -c -g -o $@ $< +#################### For gcc backend ############################## + +gcc_vhdl_dir=$(gcc_src_dir)/gcc/vhdl + +all.gcc: + echo "For installing sources in gcc, do: make copy-sources" + echo "Then configure gcc" + +copy-sources.gcc: + $(RM) -rf $(gcc_vhdl_dir) + $(MKDIR) $(gcc_vhdl_dir) + $(CP) -p $(srcdir)/src/*.ad? $(gcc_vhdl_dir) + $(CP) -p $(srcdir)/src/vhdl/*.ad? $(gcc_vhdl_dir) + $(CP) -p $(srcdir)/src/vhdl/translate/*.ad? $(gcc_vhdl_dir) + $(CP) -p $(srcdir)/src/psl/*.ad? $(gcc_vhdl_dir) + $(CP) -p $(srcdir)/src/ortho/*.ad? $(gcc_vhdl_dir) + $(CP) -p $(srcdir)/src/ortho/gcc/*.ad? $(gcc_vhdl_dir) + $(CP) -p $(srcdir)/src/ortho/gcc/*.c $(gcc_vhdl_dir) + $(CP) -p $(srcdir)/src/ortho/gcc/*.opt $(gcc_vhdl_dir) + $(CP) -p $(srcdir)/doc/ghdl.texi $(srcdir)/doc/ghdl.1 $(gcc_vhdl_dir) + $(MKDIR) $(gcc_vhdl_dir)/grt + $(CP) -pR $(srcdir)/src/grt/* $(gcc_vhdl_dir)/grt + $(MKDIR) $(gcc_vhdl_dir)/libraries + $(CP) -pR $(srcdir)/libraries/* $(gcc_vhdl_dir)/libraries + $(MKDIR) $(gcc_vhdl_dir)/ghdldrv + $(CP) -pR $(srcdir)/src/ghdldrv/*.ad? $(gcc_vhdl_dir)/ghdldrv + $(CP) -p $(srcdir)/dist/gcc/Make-lang.in $(gcc_vhdl_dir) + $(SED) \ + -e "/^####libraries Makefile.inc/r $(srcdir)/libraries/Makefile.inc" \ + -e "/^####grt Makefile.inc/r $(srcdir)/src/grt/Makefile.inc" \ + < $(srcdir)/dist/gcc/Makefile.in > $(gcc_vhdl_dir)/Makefile.in + $(CP) -p $(srcdir)/dist/gcc/Makefile.in $(gcc_vhdl_dir) + $(CP) -p $(srcdir)/dist/gcc/config-lang.in $(gcc_vhdl_dir) + $(CP) -p $(srcdir)/dist/gcc/lang-options.h $(gcc_vhdl_dir) + $(CP) -p $(srcdir)/dist/gcc/lang-specs.h $(gcc_vhdl_dir) + +GHDL_GCC_INCFLAGS=-aI$(srcdir)/src -aI$(srcdir)/src/vhdl -aI$(srcdir)/src/psl -aI$(srcdir)/src/vhdl/translate + +ghdl1-gcc: force + $(MAKE) -f $(srcdir)/src/ortho/gcc/Makefile \ + ortho_srcdir=$(srcdir)/src/ortho ortho_exec=$@ \ + GNAT_FLAGS="$(GHDL_GCC_INCFLAGS) $(GNATFLAGS)" all + +ghdl_gcc: force + $(GNATMAKE) $(GHDL_GCC_INCFLAGS) -aI$(srcdir)/src/ghdldrv \ + $(GNATFLAGS) ghdl_gcc $(GNAT_BARGS) -largs $(GNAT_LARGS) + +grt.links: + cd $(libdirsuffix); ln -sf $(libdirreverse)/grt.lst .; ln -sf $(libdirreverse)/libgrt.a .; ln -sf $(libdirreverse)/grt.ver . + +#################### For llvm backend ############################## + ghdl_llvm_jit: GRT_FLAGS+=-DWITH_GNAT_RUN_TIME ghdl_llvm_jit: $(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++ @@ -93,12 +155,11 @@ llvm-cbindings.o: ../../ortho/llvm/llvm-cbindings.cpp ghdl_simul: $(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: force - $(GNATMAKE) $(GNATFLAGS) ghdl_gcc $(GNAT_BARGS) -largs $(GNAT_LARGS) - ghdl_llvm: force $(GNATMAKE) $(GNATFLAGS) ghdl_llvm $(GNAT_BARGS) -largs $(GNAT_LARGS) +################ Libraries ############################################### + LIB87_DIR:=$(libdirsuffix)/v87 LIB93_DIR:=$(libdirsuffix)/v93 LIB08_DIR:=$(libdirsuffix)/v08 @@ -107,8 +168,6 @@ LIBSRC_DIR:=$(srcdir)/libraries REL_DIR:=$(libdirreverse)/../.. GHDL=ghdl ANALYZE:=$(REL_DIR)/$(GHDL) -a $(LIB_CFLAGS) -LN=ln -s -CP=cp $(LIB87_DIR) $(LIB93_DIR) $(LIB08_DIR): [ -d $(libdirsuffix) ] || mkdir -p $(libdirsuffix) @@ -156,9 +215,6 @@ libs.vhdl.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 . - libs.vhdl.gcc: $(MAKE) GHDL=ghdl_gcc libs.vhdl.all $(MAKE) GHDL1=./ghdl1-gcc libs.vhdl.standard @@ -217,7 +273,7 @@ install.vhdl.mcode: install.dirs #libs.vhdl.mcode $(INSTALL_DATA) -p \ $(libdirsuffix)/$$d/* $(DESTDIR)$(VHDL_LIB_DIR)/$$d; \ for c in $(libdirsuffix)/$$d/*.cf; do \ - sed -e '/file/s@".*/libraries@"../../src@g' \ + $(SED) -e '/file/s@".*/libraries@"../../src@g' \ < $$c > $(DESTDIR)$(prefix)/$$c; \ done; \ done @@ -227,9 +283,12 @@ install.program: install.dirs ghdl.mcode install.mcode: install.program install.vhdl.srcs install.vhdl.mcode +####################### clean ############################################ + clean: force $(RM) -f *.o *.ali b~*.ad? *~ *.d b__*.ad? *.a *.deps *.bexch $(RM) -f ghdl_gcc ghdl_mcode ghdl_llvm ghdl_llvm_jit ghdl_simul + $(RM) -f ghdl1-gcc run-bind.ad? grt.lst grt-files grt-files.in $(RM) -rf lib distclean: clean @@ -68,8 +68,27 @@ $ make install To install within PREFIX * Building with the gcc backend -TODO +You need to download and untar the sources of +gcc version 4.9.2 [do not modify this line as this is read by scripts]. + +First configure ghdl and specify gcc source dir: +$ ./configure --with-gcc=/path/to/gcc/source/dir + +The configure gcc following the gcc instructions and also enable vhdl +languages (you can use --enable-languages=c,vhdl --disable-bootstrap) * Building with the llvm backend TODO +Notes for developpers +********************* + +Developping with the gcc backend: +Once gcc (with ghdl) has been built once, it is possible to work on ghdl +sources tree without copying them in gcc tree. Commands are: +$ make ghdl1-gcc # To build the compiler +$ make ghdl_gcc # To build the driver +$ make libs.vhdl.gcc # To compile the vhdl libraries +$ make grt-all # To build the ghdl runtime +$ make grt.links # To locally install the ghdl runtime +TODO: gcc object dir @@ -10,12 +10,14 @@ GNATMAKE=${GNATMAKE:-gnatmake} prefix=/usr/local libdirsuffix=lib/ghdl libdirreverse=../.. +gcc_src_dir= +gcc_version=unknown build= show_help=no progname=$0 -subst_vars="CC GNATMAKE CFLAGS build srcdir prefix backend libdirsuffix libdirreverse" +subst_vars="CC GNATMAKE CFLAGS build srcdir prefix backend libdirsuffix libdirreverse gcc_src_dir" # Find srcdir srcdir=`dirname $progname` @@ -25,13 +27,17 @@ fi # Check echo -n / echo \c if test x`echo -n` = x"-n" ; then - echon="" + echon= echoc="\c" else echon="-n" - echoc="" + echoc= fi +# Read gcc version from README file +gcc_version=`grep '^gcc version' $srcdir/README | + sed -e 's/gcc version \([0-9.]*\) \[.*\]\.$/\1/'` + # Decode options for opt do optarg=`expr x$opt : 'x[^=]*=\(.*\)'` @@ -42,6 +48,7 @@ for opt do ;; --prefix=*) prefix="$optarg";; --srcdir=*) srcdir="$optarg";; + --with-gcc=*) gcc_src_dir="$optarg"; backend=gcc;; -h|-help|--help) show_help=yes;; *) echo "$0: unknown option $opt; try $0 --help" exit 1 @@ -57,6 +64,7 @@ Usage: configure [options] Options [defaults in brackets]: --prefix=PREFIX install in PREFIX [$prefix] --srcdir=SRCDIR source code path [$srcdir] + --with-gcc=DIR use gcc backend from DIR (needs gcc $gcc_version) EOF exit 0 fi @@ -83,6 +91,20 @@ if test $backend = mcode; then fi fi +# For gcc backend, check version +if test $backend = gcc; then + if ! test -f $gcc_src_dir/gcc/BASE-VER; then + echo "cannot found gcc/BASE-VER in $gcc_src_dir" + exit 1 + fi + base_ver=`cat $gcc_src_dir/gcc/BASE-VER` + if test x$base_ver != x$gcc_version; then + echo "Mismatch gcc version from $gcc_src_dir" + echo "Need gcc version $gcc_version" + exit 1 + fi +fi + # Compute build machine if test x$build = x; then build=`$CC $CFLAGS -dumpmachine` @@ -97,9 +119,9 @@ echo "# Generated by configure." echo "# Run this file to recreate the current configuration." echo echo "# Generated by:" -echo $echon "# $progname" $echoc +echo $echon "# $progname"$echoc for opt do - echo $echon " " $opt $echoc + echo $echon " $opt"$echoc done echo echo |