Menu

build mcode ghdl

Anonymous Brian Drummond

Building ghdl mcode version

This is a script called build_distribution. With minor modifications (the make target) it can
be used to build either a 32 bit Linux or OS X ghdl mcode version. You can extract parts to build incrementally. By default it removes source files when done. This can be prevented by using a command line argument: build_distribution --keep-build

There may be a default issue with warnings as errors in gnat that can cause an issue with too long of lines in default_pathes.ads. This has been resolved as of 29 December 2013.

If you need an earlier revision you can deal with this by building from close to root (e.g. in /opt) or turning off the error as warning flag. This comes about from general sweeping up of style warnings in gnat, which when enabled (and they are) limit source to something that would fit on 80 column punch, presumably for use in formal verification.

The gnat version was incorrectly specified and has been updated:
http://www.macada.org/macada/Downloads_files/Gnati386-4.3-xcode3.0.dmg


  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
#!/bin/sh -v
# accepts one argument '--keep-build', otherwise strips down executable to
# quintessential content.

# The ghdl mcode version can be built on Windows, Linux and OS X.  The two
# latter are described herein.

# Prerequisites:

# The mcode ghdl version currently only builds for a 32 bit target.  The 
# easiest way to do this is to use a 32 bit build environment. Using a
# 64 bit build environment for a 32 bit target is outside the scope of
# this description.  You could note some 64 bit Linux distributions may not 
# natively support running 32 bit executables.
# 
# To obtain a 32 bit GNAT/gcc toolsuite for building ghdl_mcode on OS X you
# could use  http://www.macada.org/macada/Downloads_files/Gnati386-4.3-xcode3.0.dmg
# from http://www.macada.org/macada/Downloads.html  For OS X and this GNAT
# you want /usr/local/ada4.3/bin to appear before any other gcc in your 
# PATH.  This builds with the supplied GNAT and gcc both targeting a 32 
# result.
# 
# This is the version I use.
# 
# The easy way to build on Linux is using a 32 bit distribution, I have
# built recently with lubuntu 12.10 as a VM under VirtualBox.  You obtain
# gcc and ada for it.  ghdl_mcode by itself isn't particularly pick  as to 
# versions, the OS X GNAT tools are from 2008.

# Notes:
# This script build relative to it's invocation location, generating a sub
# directory ./ghdl.  There is a dependency between the build location and the
# VHDL library installation location that tells us to keep the build directory
# when done, and link to the executable.  ./ghdl/translate/ghdldrv/ghdl_mcode,
# typically linked to /usr/local/bin/ghdl, and ./doc/ghdl.1 typically linked to
# /usr/local/man/man1/ghdl.1.  Non adminstrative installation would probably
# link to $HOME/bin and $HOME/man/man1 (which don't normally exist).

# undefined full paths for svn, gnatlink, cd, echo and exit may be builtin

# ghdl (mcode) is relocatable.  You can link from the stripped build directory
# or mv the remains to an 'install' location.

# You can extract or comment out parts of this script to allow customization
# or debugging.

# Build:

# umask 022 so we don't have to fight over permissions
# we do this with trepidition but in the knowledge we are only 
# writing to expendable locations

echo directory $PWD
umask 022

#if the name ghdl currently exists delete it, file or directory

if [ -e ghdl ] 
then
  /bin/rm -rf ghdl
fi

# either from distribution install directory (e.g. /usr/local ) or
# build in distribution  (mkdir build; cd build; e.g. /usr/local/ghdl/build)

# Get ghdl source:

# From ghdl-updates:
hg clone http://hg.code.sf.net/p/ghdl-updates/code ghdl
# Can be specified by revision:
# hg clone -r145  http://hg.code.sf.net/p/ghdl-updates/code ghdl
# revision -r145 known to work

# From gna.org Subversion repository:
# svn -r 150 co svn://svn.gna.org/ghdl/trunk ghdl

# Example from local copy of repository instead of Subversion:
#
#/bin/cp -r /$HOME/Desktop/ghdl1/ghdl_revision_150 ghdl
# the above cp -r may generate errors for unfilled symbolic links to .o files
#  this is okay
#
# \cd ghdl/translate/ghdldrv
# echo directory $PWD
# make clean
#cd ../../..
# echo directory $PWD

# deny write access to group/other

/bin/chmod go+rx ghdl
/bin/chmod -R go+r ghdl
/usr/bin/find ghdl -type d -exec chmod go+x \{\} \;

# build

cd ghdl/translate/ghdldrv
echo directory $PWD

/bin/rm -f ortho_code-x86-flags.ads

# if the link is there:
/bin/rm -f ghdl

# Insure ADA and gcc versions are compatible and exist
# There is no checking.  I'd suggest keeping the build environment
# if you aren't clear on this

# Mac OS X
# /usr/bin/make target=i686-darwin GNAT_LARGS=-Wl,-no_compact_unwind

# Linux (default)  (i386)

/usr/bin/make target=i686-pc-linux-gnu

# for Mac OS backward compatibility (out of date):
# relink ghdl_mcode as a Mac OS X 10.5 SDK target if built on Mac OS X 10.6:
#
#export MACOSX_DEPLOYMENT_TARGET=10.5
# (the above variable may not be needed to build a 10.5 SDK target)
#
# gnatlink ghdl_mcode.ali -g memsegs_c.o chkstk.o i386.o linux.o times.o grt-cbinding.o grt-cvpi.o -lm -isysroot /Developer/SDKs/MacOSX10.5.sdk -mmacosx-version-min=10.5 --no_compact_linkedit
#
# This requires the older SDK which is used to span OS X 10.5 - 10.9 use.

# link ghdl_mcode to ghdl to allow make target install.mcode

/bin/ln -s ghdl_mcode ghdl

/usr/bin/make target=i686-darwin install.mcode

\cd ../..
echo directory $PWD

# if we don't intend to keep the build environment
# it's thrown away by default

if [ -z $1 ]  
then

    # ghdl top level

    # remove  Ada source files

    /bin/rm  -f *.adb *.ads *.in

    # remove unneeded directories

    /bin/rm -rf ortho
    /bin/rm -rf psl
    /bin/rm -rf xtools
    /bin/rm -rf translate/gcc
    /bin/rm -rf translate/grt
    /bin/rm -rf translate/mcode

    # remove all source and object files

    /usr/bin/find translate -name \*.adb -delete
    /usr/bin/find translate -name \*.ads -delete
    /usr/bin/find translate -name \*.ali -delete
    /usr/bin/find translate -name \*.o   -delete

    # remove build files

    /bin/rm -f translate/ghdldrv/Makefile
    /bin/rm -f libraries/Makefile.inc
    /bin/rm -f translate/Makefile
    /bin/rm -f translate/ghdldrv/default_pathes.ads.in

    # remove the link needed to build install.mcode target

    /bin/rm -rf translate/ghdldrv/ghdl

    # remove hg directories with extreme prejudice
    /usr/bin/find . -iname \.hg -exec /bin/rm -rf \{\} \;
    # .hginore is well, ignored.

    # remove svn directories with extreme prejudice
    # /usr/bin/find . -iname \.svn -exec /bin/rm -rf \{\} \;

# the above find command may erroneouslyreport "No such file or directory"
# upon examination the .svn subdirectories have been removed.  This appears to
# be an implementation error with either Apple's find or rm.

    # strip executable

    #/usr/bin/strip translate/ghdldrv/ghdl_mcode

    # rm debug file if exists

    /bin/rm -f .gdbinit

elif [ $1 != "--keep-build" ]
then
    echo "ERROR:  $0 only accepts one option -> --keep-build"
    exit -1
fi

# give everyone read and where appropriate execution access to ghdl

/bin/chmod ugo+rx . 
/bin/chmod ugo+rx doc 
/bin/chmod ugo+rx translate
/bin/chmod ugo+r *
/bin/chmod ugo+rx translate/ghdldrv
/bin/chmod ugo+rx translate/ghdldrv/ghdl_mcode
/bin/chmod go+r doc/*
/bin/chmod ugo+rx translate/lib
/bin/chmod -R go+r translate/lib
/bin/chmod ugo+rx libraries
/bin/chmod -R go+r libraries

#Install (example, may want to provide own install location)

#install ghdl

# if [ -h /usr/local/bin/ghdl ]
#   then
#   /bin/rm -f /usr/local/bin/ghdl
# fi

# /bin/ln -s $PWD/translate/ghdldrv/ghdl_mcode /usr/local/bin/ghdl

# if [ -h /usr/local/man/man1/ghdl.1 ]
#   then
#   /bin/rm -f /usr/local/man/man1/ghdl.1
# fi

#/bin/ln -s $PWD/doc/ghdl.1 /usr/local/man/man1/ghdl.1

Related

Wiki: GHDL Developer Page

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.