
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. Not sure what changed that broke cmake.
  mkdir /tmp/builddir
  cd /tmp/builddir
  # Assuming the source tree in /a/b/code
  cmake /a/b/code
  make

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 dd
    #You may need to be root to do the following copy commands
    cp dwarfdump/dwarfdump      /usr/local/bin
    cp dwarfdump/dwarfdump.conf /usr/local/lib
    #The following is optional, not needed to run dwarfdump
    #when doing the default build.
    cp libdwarf/libdwarf.a      /usr/local/lib

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

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
    make dd
In this case the source directory is not touched 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. This is due to the way GNU Make
VPATH works.

For a simple build of libdwarf, and dwarfdump
and the other tools:
    ./configure
    make
    #Optionally: cp libdwarf/libdwarf.a <somewhere>

To build all the tools (including dwarfgen and 
dwarfexample) use 'make all'. There are known 
small compile-time issues with building dwarfgen on 
MaxOSX and most don't need to build dwarfgen.
    ./configure
    make all

By default configure compiles and uses libdwarf.a.

With 
    ./configure --enabled-shared
both libdwarf.a and libdwarf.so
are built. The runtimes built will reference libdwarf.so.

With 
    ./configure --enabled-shared --disable-nonshared
libdwarf.so is built and used; libdwarf.a is not built.

When ready to create a new source distribution do
    ./CPTOPUBLIC
    ./BLDLIBDWARF yyyymmdd
where that could be
    ./BLDLIBDWARF 20140131
as an example.

Sanity checking:
Recent gcc has some checks that can be done at runtime.
  -fsanitize=address
  -fsanitize=leak
  -fsanitize=undefined
which are turned on here by --enable-sanitize at build time.

CROSS-COMPILES:
For those wishing to build libdwarf (and possibly dwarfdump)
for a different 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.



mkdir emptycross
cd emptycross
git clone git://git.code.sf.net/p/libdwarf/code
cd code
cd libdwarf 
./configure --host=arm-linux-gnueabihf
make
cd ../dwarfdump 
./configure --host=arm-linux-gnueabihf
make
# done

David Anderson.  Updated March 30, 2018
