#####
# Build HOWTO
#####

# Clone repository
# - requires mercurial
# - creates xfoce directory

hg clone https://user@bitbucket.org/klheadley/xfoce

# build xfoce repository
# - xfhome sets environment variables
# - gwconf configures build environment

cd xfoce
. src/scripts/xfhome `pwd`
. src/scripts/gwconf u

libtoolize -f
aclocal
autoconf
autoreconf
automake --add-missing
./configure
make

# build xfoce source distribution
# and send to gateway
# - creates xfoce-<version>.tar.gz
# - tar.gz file is all that is needed to 
#   build on bbone host
make dist

# build xfoce on beaglebone host
[on development host]
scp xfoce-<ver>.tar.gz ops@<host>:<build-path>/.

[on gateway host]
cd <build-path>
. src/scripts/xfhome `pwd`
. src/scripts/gwconf b
./configure
make

#####
# Adding a new source file
#####

- use templates in xfoce/doc/examples/
- fill in title, author, creation date
- for header files, create enclosing #ifdef HEADER_NAME (also closing endif comment)

- update /path/to/src/Makefile.am
bin_PROGRAMS = hello xfoce
hello_SOURCES = hello.c
xfoce_SOURCES = main.c

- If adding a new source directory
  - add new Makefile.am to new directory
  - update xfoce/configure.ac
AC_CONFIG_FILES([Makefile
                 src/gateway/core/Makefile path/to/new/Makefile])
  - add directory to xfoce/Makefile.am

- configure 
- make

include paths 
- In the new source file, include headers defined elsewhere in the tree:
#include "xfoce.h" (not #include <xfoce.h>)

- add appropriate header include paths and linkages to Makefile.am
bin_PROGRAMS = testHello
testHello_SOURCES = testHello.c
testHello_CPPFLAGS = -I$(top_builddir)/src/gateway/core
testHello_LDADD = $(top_builddir)/src/gateway/core/main.o

- autoreconf
- ./configure (?)
- make

#####
# Make debug version
#####
./configure CPPFLAGS=-DDEBUG
make clean
make