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
|
At the present time using cmake to build fails, so the
following that worked in November 2016 fails at least as of
March 2018. Sorry.
Standard builds are done by configure/make as described below.
Cross-Compiles are described below, see CROSS COMPILES.
BUILDING IN SOURCE TREE
To just build libdwarf and dwarfdump if the source tree is
in /a/b/libdwarf-1 one might do:
cd /a/b/libdwarf-1 ./configure make
LIBRARY REQUIREMENTS
libelf and zlib have to be installed to build libdwarf and
dwarfdump. For example, in Ubuntu 16.04, install using:
sudo apt-get install zlib1g zlib1g-dev libelf1 libelf-dev
zlib is available in source from http://zlib.net
libelf is available in source from
http://www.mr511.de/software/
and
https://github.com/vtorri/libelf
BUILDING OUT OF SOURCE TREE
Or one could create a new directory, for example,
mkdir /var/tmp/dwarfex
cd /var/tmp/dwarfex
/a/b/libdwarf-1/configure (other options as required)
make
In this case the source directory is not written-to and all
objects and files created are under /var/tmp/dwarfex
NOTE: When building out of source tree the source tree must
be cleaned of any files created by a build in the source tree
(just in case you tried that) before doing the out-of-source
build.
To build all the tools (including dwarfgen and dwarfexample)
use a different configure command..
./configure --enable-dwarfgen --enable-dwarfexample make
To see all the available options to configure do
./configure --help
By default configure compiles and uses libdwarf.a.
With
./configure --enable-shared
both libdwarf.a and libdwarf.so are built. The runtimes built
will reference libdwarf.so.
With
./configure --enable-shared --disable-nonshared
libdwarf.so is built and used; libdwarf.a is not built.
BUILD FAILURE
If the 'make' step fails with the message
"WARNING: 'aclocal-1.15' is missing on your system."
then the timestamps of the source tree are not in the proper
relationships. Creating a source copy using 'cp -r' can
caus this. Much better to use 'cp -rp'. Change directory to
the top of the source tree and do
sh scripts/FIX-CONFIGURE-TIMES
to update the relevant timestamps.
Then redo the configure and the make should work.
THE USUAL ENVIRONMENT VARIABLES
The following default to sensible values
you may set environment variables as usual
with GNU configure.
CPPFLAGS
CFLAGS
LDFLAGS
The following environment variables (if set) override
values used in building helper executables (at build time)
that are run at build time to build C source
to be compiled into libdwarf and dwarfdump.
It's not likely you will have any need to
set your own values for these.
These helper executables are ignored
by 'make install'.
CFLAGS_FOR_BUILD
CPPFLAGS_FOR_BUILD
LDFLAGS_FOR_BUILD
Normally the simple defaults for these will work
and will suffice.
Having separate variables for the build-time
is necessary to support cross-building. For example
if compiling on x86_64 and building libdwarf for Arm7.
DEBUGGING MAKE
To see what compile/link commands are actually
being used by the generated Makefiles try V=1, as in
make V=1
INSTALL AND UNINSTALL
The default install is to /usr/local
To change the install location use --prefix.
For example:
mkdir /tmp/testinst
configure --prefix=/tmp/testinst
So 'make install' (sudo make install) installs into
/usr/local/bin, /usr/local/lib, /usr/local/include, and
/usr/local/share/libdwarf.
Doing 'make uninstall' (sudo make uninstall) deletes
what 'make install' added but does not delete the
/usr/local/share/libdwarf directory that the 'make install'
created.
CHECKING FOR MEMORY CORRUPTION
Recent gcc has some checks that can be done at runtime.
-fsanitize=address
-fsanitize=leak
-fsanitize=undefined
which are turned on here by '<path>/configure --enable-sanitize'.
The --enable-sanitize option unlikely to work when
cross-compiling.
CROSS-COMPILES
For those wishing to build libdwarf (and possibly dwarfdump)
for a different host machine than the build machine
it is now possible to do that.
It has been tested with host and target set to an ARM with
build on X86_64. See
https://gcc.gnu.org/onlinedocs/gccint/Configure-Terms.html
for standard GNU usage of build, host, and target. See also:
https://www.gnu.org/software/autoconf/manual/autoconf.html#Specifying-Target-Triplets
The autoconf documentation strongly suggests adding --build
to the configure commands and in the example below adding
--build=i686-pc-linux-gnu is known to work on the test machine.
The following is an example. Currently configure figures out
the build environment for itself so we don't use --build here.
On build machine:
sudo apt-get install gcc-arm-linux-gnueabihf
# Install libelf and zlib (libz) into
# the gcc cross-build tree too.
# I cheated: copied from arm machine into
# gcc-arm-linux-gnueabihf.
mkdir emptycross
cd emptycross
git clone git://git.code.sf.net/p/libdwarf/code
cd code
./configure --host=arm-linux-gnueabihf
make
# done
------------------ notes on updating ------
To update configure after hand updating a Makefile.am or
the configure.ac do the following command at the top level
(where this file is):
autoreconf -vif
You will need the autotools installed including autoconf,
automake, and libtool to run autoreconf.
If, for some reason, you wish to run the small
basic checks of individual source files, first
do
./configure
make
Then
make check
will run the special test scripts: dwarfdump/runtests.sh
libdwarf/runtests.sh (each must be run in its directory,
neither requires any arguments, just run each).
As of this writing this must be done (as shown)
in the source directory, it does not currently
work if running the configure in a build directory.
To create a release file do:
./configure --enable-dwarfexample --enable-dwarfgen
make
make dist
will generate a libdwarf-yyyymmdd.tar.gz file with the files
needed in a release
scripts/CPTARTOWEBDIR is an example of generating
fingerprints for the release file and copying the file.
See the configure.ac for the version used.
For example: 'm4_define([v_date], [20180730])])'
David Anderson. Updated August 2, 2018
|