Debian Codegraph @

testing/fulltests/support/clib_build

raw
1 #!/bin/sh
2
3 # build the C test file ...
4
5 scriptname="$0"
6 if [ "${scriptname#/}" = "${scriptname}" ]; then
7 scriptname="${PWD}/${scriptname}"
8 fi
9 scriptdir="$(dirname ${scriptname})"
10 srcdir="$(dirname $(dirname $(dirname $scriptdir)))"
11
12 rm -f "$2.c"
13 cat >>"$2.c" <<EOF
14 /* net-snmp standard headers */
15 #include <net-snmp/net-snmp-config.h>
16 #include <net-snmp/net-snmp-includes.h>
17 #include <net-snmp/library/large_fd_set.h>
18 #include "snmplib/transports/snmpIPBaseDomain.h"
19 #include <utilities/execute.h>
20
21 /* testing specific header */
22 #include <net-snmp/library/testing.h>
23
24 /* standard headers */
25 #include <errno.h>
26 #ifdef HAVE_INTTYPES_H
27 #include <inttypes.h>
28 #endif
29 #include <stdio.h>
30 #if HAVE_UNISTD_H
31 #include <unistd.h>
32 #endif
33 #include <sys/types.h>
34 #ifdef HAVE_LIMITS_H
35 #include <limits.h>
36 #endif
37 #ifdef HAVE_STDLIB_H
38 #include <stdlib.h>
39 #endif
40 #if HAVE_STRING_H
41 #include <string.h>
42 #else
43 #include <strings.h>
44 #endif
45 #ifdef HAVE_NETDB_H
46 #include <netdb.h>
47 #endif
48 #ifdef HAVE_ARPA_INET_H
49 #include <arpa/inet.h>
50 #endif
51 #ifdef HAVE_NETINET_IP6_H
52 #include <netinet/ip6.h>
53 #endif
54 #ifndef HAVE_INET_PTON
55 #include "snmplib/inet_pton.h"
56 #endif
57 #ifndef HAVE_INET_NTOP
58 #include "snmplib/inet_ntop.h"
59 #endif
60
61 #define ABS_SRCDIR "${srcdir}"
62
63 int
64 main(int argc, char *argv[]) {
65
66 EOF
67 echo >>"$2.c" "#line 1 \"$1\""
68 cat >>"$2.c" "$1"
69 cat >>"$2.c" <<EOF
70
71 if (__did_plan == 0) {
72 PLAN(__test_counter);
73 }
74
75 return(0);
76 }
77
78 EOF
79
80 # ... and compile it.
81 ${builddir}/libtool --mode=link `${builddir}/net-snmp-config --build-command` -I$builddir/include -I$srcdir -I$srcdir/include -I$srcdir/agent/mibgroup -o $2 $2.c ${builddir}/snmplib/libnetsnmp.la ${builddir}/agent/libnetsnmpmibs.la `${builddir}/net-snmp-config --external-libs`
82 echo $2