title: Build script to generate library using automake
body: <p>I want to create a library (Ubuntu, shared or static) from C++ source code. The given source code includes a main() function in "outFile.cpp". </p>
  
  <p>I want to write my own main.cpp file that should be linked to the library like "g++ -lMyLibrary.a" lateron.</p>
  
  <p>Therefore, I want to modify the build script for the C++ source code. What in the build script below do I need to modify in order to generate a library file, excluding any main() function and that provides me all the functions/methods from the source code?</p>
  
  <p>The buildscript uses automake.</p>
  
  <p>buidScript.sh :</p>
  
  <pre><code>#!/bin/bash
  
  ./autogen.sh ;
  ./autogen.sh ;
  
  export CXXFLAGS="-O2"
  export CFLAGS="-O2"
  export CPPFLAGS="-D__STATIC_LINK -DBUILD_WITH_GPL3rdP -DBUILD_LIBSVM ...."
  
  ./configure --prefix=$INSTPREFIX --enable-static --enable-shared=no
  
  ./update_build_version.sh
  
  make clean &amp;&amp;
  make -j8 ; make install
  
  g++ $CFLAGS -static -o outFile outFile-outFile.o  -lm -pthread .libs/libMyLibrary.a
  </code></pre>
  
  <p>Makefile.am:</p>
  
  <pre><code>ACLOCAL_AMFLAGS = -I m4
  
  AUTOMAKE_OPTIONS = subdir-objects
  
  bin_PROGRAMS = outFile
  
  ...
  
  NEWMAT_SOURCES=\
  NEWMAT_CPPFLAGS = -I ../thirdparty
  
  NEWMAT_LDFLAGS = 
  
  LIB_SOURCES=\
  
  lib_LTLIBRARIES = libMyLibrary.la
    libMyLibrary_la_SOURCES = $(MyLibrary_SOURCES)
    libMyLibrary_la_CPPFLAGS = $(MyLibrary_CPPFLAGS)
    libMyLibrary_la_LIBADD = $(MyLibrary_LIBS)
    libMyLibrary_la_LDFLAGS = --no-undefined
  </code></pre>
  
  <p>Sorry for the weak description, its the first build script I write and I'm still reading about the necessary tools. Thanks. </p>