installed version of libt2n.
To build it seperately using a installed version of libt2n:
-autoreconf -i && ./configure && make && make distcheck
+autoreconf && ./configure && make && make distcheck
-if it does not work try something like:
+if it does not work you may have to move the example-codegen out of the libt2n directory and
+pass some options to autoreconf
+I use something like:
tar xzvf libt2n-0.1.tar.gz
mv libt2n-0.1/example-codegen .
cd example-codegen
-# get configure script created and missing autotools stuff
-aclocal && automake -a && autoreconf -i
+# get configure script created and missing autotools helper files installed
+# if you installed libt2n in some non-standard directory you might have to pass
+# -M pathtolibt2n.m4
+autoreconf -f -i
./configure && make && make distcheck
+
+tar xzvf libt2n-0.1.tar.gz && mv libt2n-0.1/example-codegen . && cd example-codegen && autoreconf -f -i -M /tmp/jens-delme/usr/share/aclocal && ./configure && dmake && dmake distcheck
- would be nice to reduce amount of changed files
(codegen output is often the same as the existing files - something similar to ccache
for codegen - but not overwriting output files if they are the same)
-- howto include the part after "# always the same:" in all makefiles using the codegenerator
+- howto include the part after "# always the same:" in all makefiles (using the codegenerator)
(we now use make's include)
- lib name should be group name + suffix/prefix
-- at the moment make dist from within a clean source will not work
- (this is related to the nodist problem / old automake version)
- the example should not get installed (but still it should show how to build a lib that gets installed :-(
(overwriting install: doesn't work)
+- at the moment make dist from within a clean source will not work
+ (this is related to the nodist problem / old automake version)
+ this is caused by BUILT_SOURCES not working for make dist(check?)
+ and the dependency generation
+
+ distcheck -> dist -> distdir -> DISTFILES
+
+ all -> all-redirect -> all-am -> Makefile -> BUILT_SOURCES => bene
+
+ => how to add dependency on BUILT_SOURCES for dist?
+ the real problem is that make dist should not depend on BUILT_SOURCES
+ unfortunately we can't fix this as long as we use a old automake version
- add (standalone) example using generated client library
(=> depends on installed example)
example consists of: the same client.cpp but provides a configure.in and Makefile.am
$(LIBT2N_CODEGEN) $* $($*_GROUP:.cpp=.xml) && touch $@
LIBT2N_CODEGEN_BUILT = $(foreach i, $(CMDGROUPS), $(foreach j, _common.hxx _common.cpp _client.hxx _client.cpp _server.hxx _server.cpp, $(i)$(j)) )
+
+# using BUILT_SOURCES is a bit problematic (see also automake manual)
BUILT_SOURCES += $(LIBT2N_CODEGEN_BUILT)
LIBT2N_STAMPS=$(CMDGROUPS:=.libt2nstamp)
# .pc files (one pc file for each command group)
%.pc : $(LIBT2N_CLIENT_PCTEMPLATE) Makefile
sed \
- -e 's,@CMDGROUP@,$*,g' \
+ -e 's,\@CMDGROUP\@,$*,g' \
-e 's,\@prefix\@,$(prefix),g' \
-e 's,\@exec_prefix\@,$(exec_prefix),g' \
-e 's,\@libdir\@,$(libdir),g' \
-e 's,\@includedir\@,$(includedir),g' \
+ -e 's,\@VERSION\@,$(VERSION),g' \
$< >$*.pc
CLEANFILES += $(LIBT2N_CODEGEN_BUILT) $(LIBT2N_STAMPS) $(pkgconfig_DATA)
# $(foreach i, $(CMDGROUPS), $(i)_server.cpp)
# we have got an old automake version (1.4-p5) which doesn't support nodist_
-# => we use the dist-hook
-dist-hook:
+# => we use this hack using the dist-hook
+dist-hook: $(LIBT2N_CODEGEN_BUILT)
rm -vf $(foreach i, $(LIBT2N_CODEGEN_BUILT), $(distdir)/$(i))
EXTRA_DIST += codegen.make
--- /dev/null
+# not a GNU package. You can remove this line, if
+# you have all needed files, that a GNU package needs
+AUTOMAKE_OPTIONS = foreign
+
+INCLUDES = @DEFAULT_CFLAGS@
+LDADD = @DEFAULT_LIBS@
+
+client_SOURCES = client.cpp
+
+bin_PROGRAMS = client
--- /dev/null
+example how to use a installed library generated using libt2n-codegen
--- /dev/null
+/***************************************************************************
+ * Copyright (C) 2004 by Intra2net AG *
+ * info@intra2net.com *
+ * *
+ ***************************************************************************/
+
+#include <socket_client.hxx>
+
+// include generated library header
+#include "default_client.hxx"
+
+int main(int argc, char** argv)
+{
+ libt2n::socket_client_connection sc("./socket");
+ cmd_group_default_client cc(sc);
+
+ bool throwok=false;
+ try
+ {
+ cc.testfunc("throw");
+ }catch(libt2n::t2n_runtime_error &e){
+ throwok=(std::string(e.what())=="throw me around");
+ }
+
+ return ( throwok
+ && ( cc.testfunc("hello") == "hello, testfunc() was here" )
+ && ( cc.testfunc_ref("hello") == "hello, testfunc() was here" )
+ && ( cc.t2(10) == 10 ) )
+ ? EXIT_SUCCESS : EXIT_FAILURE;
+}
INSTDIR="/tmp/jens-delme"
mkdir "$INSTDIR"
INSTPREFIX="/tmp/jens-delme/usr"
-MAKE="dmake -d"
+MAKE="dmake"
./configure --prefix="$INSTPREFIX"
+# todo: at the moment running make dist on clean source does not work
+$MAKE
+#$MAKE distcheck
$MAKE dist
$MAKE install
+echo "OK: library and code generator compiled and installed"
+
VERSION="0.1"
TARFILE="libt2n-$VERSION.tar.gz"
cp "$TARFILE" "$INSTDIR"
+EXAMPLE_LIBUSAGE="example-libusage"
+cp -af "$EXAMPLE_LIBUSAGE" "$INSTDIR"
# now build example-client using installed libt2n
cd "$INSTDIR"
mv "libt2n-$VERSION/example-codegen" .
cd example-codegen
autoreconf -f -i -M "$INSTDIR/usr/share/aclocal"
-./configure
+./configure --prefix="$INSTPREFIX"
# todo: at the moment running make dist on clean source does not work
$MAKE
$MAKE distcheck
+$MAKE install
+cd ..
+echo "OK: example using installed libt2n works"
+
+# now compile client using the installed default lib
+cd "$EXAMPLE_LIBUSAGE"
+autoreconf -f -i -M "$INSTDIR/usr/share/aclocal"
+./configure --prefix="$INSTPREFIX"
+$MAKE distcheck