CEXAMPLES:=ws_getversion ws_jobstat ws_joblog ws_lb4agu_GetActivityStatus ws_lb4agu_GetActivityInfo
 #TODO ws_query_ex 
+TESTS:=sizeof_soap_test
 
 default all: ${CEXAMPLES}
 
 default_flavour=_${nothrflavour}
 endif
 
-VPATH=${top_srcdir}/examples
+VPATH=${top_srcdir}/examples:${top_srcdir}/tests
 CC=gcc
 DEBUG:=-g -O0 -Wall
 CFLAGS:=${CFLAGS} -I${gsoap_prefix}/include -I${gsoap_prefix}/ \
 ${CEXAMPLES}: %: %.o ${WS_CLIENT_OBJS}
        ${LINK} -o $@ $@.o ${WS_CLIENT_OBJS} ${WS_CLIENT_LIBS}
 
+sizeof_soap_test: sizeof_soap_test.o
+       ${LINK} -o $@ $<
+
 %.o %.lo: %.c soap_version.h ${SOAP_FILES}
        ${COMPILE} -c $<
 
-check:
-       @echo "No test"
+check: ${TESTS}
+       ./sizeof_soap_test
 
 install:
        mkdir -p ${DESTDIR}${PREFIX}${prefix}/${libdir}/glite-lb/examples/
        done
 
 clean:
-       rm -rvf .libs LB.xh *.xml ${GSOAP_FILES_PREFIX}* *.o *.lo *.nsmap soap_version.h ${CEXAMPLES}
+       rm -rvf .libs LB.xh *.xml ${GSOAP_FILES_PREFIX}* *.o *.lo *.nsmap soap_version.h ${CEXAMPLES} ${TESTS}
        rm -rvf log.xml project/ rpmbuild/ RPMS/ tgz/ debian/
 
 LB.xh: ws_typemap.dat ${stagedir}${prefix}/interface/LB.wsdl
 
--- /dev/null
+/*
+Copyright (c) Members of the EGEE Collaboration. 2004-2010.
+See http://www.eu-egee.org/partners for details on the copyright holders.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+#include <stdio.h>
+#include <stdsoap2.h>
+
+#include "soap_version.h"
+#include <glite/security/glite_gscompat.h>
+
+int main() {
+       printf("sizeof(struct soap) = %lu, original size = %lu\n",
+               sizeof(struct soap), GSOAP_SIZEOF_STRUCT_SOAP);
+
+       return !(sizeof(struct soap) == GSOAP_SIZEOF_STRUCT_SOAP);
+}
 
 langsuffix:=.${lang}
 endif
 
-VPATH=${top_srcdir}/src:${top_srcdir}/test:${top_srcdir}/examples
+VPATH=${top_srcdir}/src:${top_srcdir}/test:${top_srcdir}/examples:${top_srcdir}/interface
 
 default: all
 
 EX_NOTHRLIBS:=-L${stagedir}${prefix}/${libdir} -lglite_security_gss_${nothrflavour}
 EX_THRLIBS:=-L${stagedir}${prefix}/${libdir} -lglite_security_gss_${thrflavour}
 EX_LIBS:=-L${stagedir}${prefix}/${libdir} -lglite_security_gss
-HDRS:=glite_gsplugin.h glite_gscompat.h glite_gsplugin-int.h
+HDRS:=glite_gsplugin.h glite_gsplugin-int.h
 EXAMPLES:=wscalc_clt_ex wscalc_srv_ex wscalc_srv_ex2
 TESTS:=test_cxx
 
 
 all compile: \
        ${lib_LTLIBRARIES} \
-       all-libs-with-soap examples
+       all-libs-with-soap examples glite_gscompat.h
 
 check: check.cxx
 
 wscalc_clt_ex.o: wscalc_clt_ex.c
        ${CC} -c ${CFLAGS} -o $@ $<
 
+sizeof_soap.o: sizeof_soap.c stdsoap2.h
+       ${COMPILE} -c $< -o $@
+
+sizeof_soap: sizeof_soap.o
+       ${LINK} $< -o $@
+
+glite_gscompat.h: glite_gscompat.h.in sizeof_soap
+       size=${shell ./sizeof_soap}; \
+       sed "s/@sizeof_struct_soap@/$$size/" ${top_srcdir}/interface/glite_gscompat.h.in > $@
+
 doc:
 
 stage:
        -mkdir -p ${DESTDIR}${PREFIX}${prefix}/include/glite/security/
        ${INSTALL} -m 644 ${top_srcdir}/LICENSE ${DESTDIR}${PREFIX}${prefix}/share/doc/${package}-${version}
        cd ${top_srcdir}/interface && ${INSTALL} -m 644 ${HDRS} ${DESTDIR}${PREFIX}${prefix}/include/glite/security/
+       ${INSTALL} -m 644 glite_gscompat.h ${DESTDIR}${PREFIX}${prefix}/include/glite/security/
        for v in ${gsoap_versions_noflavours}; do \
                ${MAKE} -C `echo $$v | tr -d .` -f ../Makefile install-soaplib gsoap_version=$$v lang= PREFIX=${PREFIX} top_srcdir=${top_srcdir}/.. || exit $?; \
        done
        rm -rvf ${LTLIB_TEST_S}
        rm -rvf *.c *.h *.xml *.nsmap *.o *.lo .libs ${EXAMPLES} ${TESTS}
        rm -rvf CalcService.wsdl wscalc.xsd
+       rm -rvf glite_gscompat.h
        rm -rvf log.xml project/ rpmbuild/ RPMS/ tgz/ debian/
        for v in ${gsoap_versions_noflavours} ${gsoap_versions_flavours}; do \
                rm -rvf `echo $$v | tr -d .`; \
 
 
 #ident "$Header: "
 
+/*
+ * for basic sanity check
+ *
+ * size of the soap structure can differs with compilation flags
+ * or with C/C++ compilers
+ */
+#define GSOAP_SIZEOF_STRUCT_SOAP @sizeof_struct_soap@
+
 #ifndef GSOAP_VERSION
   #error GSOAP_VERSION required
 #endif