blob: f94bebd02e36deb9b8a87ffb657bf7fe3e6d40aa [file] [log] [blame]
#!/bin/sh
# build the C test file ...
scriptname="$0"
if [ "${scriptname#/}" = "${scriptname}" ]; then
scriptname="${PWD}/${scriptname}"
fi
scriptdir="$(dirname ${scriptname})"
srcdir="$(dirname $(dirname $(dirname $scriptdir)))"
rm -f "$2.c"
cat >>"$2.c" <<EOF
/* net-snmp standard headers */
#include <net-snmp/net-snmp-config.h>
#include <net-snmp/net-snmp-includes.h>
#include <net-snmp/library/large_fd_set.h>
/* testing specific header */
#include <net-snmp/library/testing.h>
/* standard headers */
#include <errno.h>
#include <stdio.h>
#include <sys/types.h>
#ifdef HAVE_LIMITS_H
#include <limits.h>
#endif
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#if HAVE_STRING_H
#include <string.h>
#else
#include <strings.h>
#endif
#ifdef HAVE_NETDB_H
#include <netdb.h>
#endif
#ifdef HAVE_ARPA_INET_H
#include <arpa/inet.h>
#endif
#ifdef HAVE_NETINET_IP6_H
#include <netinet/ip6.h>
#endif
#ifndef HAVE_INET_PTON
#include "snmplib/inet_pton.h"
#endif
#ifndef HAVE_INET_NTOP
#include "snmplib/inet_ntop.h"
#endif
#define ABS_SRCDIR "${srcdir}"
int
main(int argc, char *argv[]) {
EOF
echo >>"$2.c" "#line 1 \"$1\""
cat >>"$2.c" "$1"
cat >>"$2.c" <<EOF
if (__did_plan == 0) {
PLAN(__test_counter);
}
return(0);
}
EOF
# ... and compile it.
${builddir}/libtool --mode=link `${builddir}/net-snmp-config --build-command` -I$builddir/include -I$srcdir -I$srcdir/include -o $2 $2.c ${builddir}/snmplib/libnetsnmp.la `${builddir}/net-snmp-config --external-libs`
echo $2