summaryrefslogtreecommitdiff
path: root/configure.d/config_os_progs
blob: 6ab38f4ffb08d399f2a3545e30fbd5b2410f529a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
# -*- autoconf -*-
#########################################
##
# Checks for programs
##
#########################################

##
#   Shell checks:
##

#       Check for 'sh' overflow                         (HP-UX)
#         (taken from Perl's configure script)
#
AC_MSG_CHECKING([if I need to feed myself to ksh])
if test -f /hp-ux -a -f /bin/ksh; then
  if (PATH=.; alias -x) >/dev/null 2>&1; then
    AC_MSG_RESULT(no)
  else
    AC_MSG_RESULT(yes)
    if test "x$1" = "x"; then
      exec /bin/ksh $0
    else
      exec /bin/ksh $0 "$@"
    fi
  fi
else
  AC_MSG_RESULT(no)
fi


##
#   Standard and path program checks:
##

AC_PROG_EGREP
AC_PROG_GREP
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET
AC_PROG_SED

AC_CHECK_PROGS([FILE], [file])
if test x$ac_cv_prog_FILE = x; then
  # The file program is not included in the default Cygwin setup, although
  # this program is essential for libtool to work properly. It is nontrivial
  # to deduce from the message printed by libtool that the 'file' tool is
  # missing and libtool does not abort when the file program is not found. So
  # stop now if the file program has not been found.
  AC_MSG_ERROR([file program not found although it is needed by libtool.], [1])
fi

AC_CHECK_PROGS(FIND,   find)
AC_CHECK_PROGS(WHOAMI, whoami logname, whoami)

AC_PATH_PROG(AUTOCONF,    autoconf)
AC_PATH_PROG(AUTOHEADER,  autoheader)
AC_PATH_PROG([PERLPROG],  perl)
AC_PATH_PROG([PSPROG],    ps)
AC_PATH_PROG([PYTHONPROG],python)

AC_PATH_PROG([UNAMEPROG], uname)
AC_DEFINE_UNQUOTED(UNAMEPROG,"$UNAMEPROG", [Where is the uname command])

if test "x$ac_cv_prog_AUTOCONF" = "x"; then
	AUTOCONF=":"
	AC_SUBST(AUTOCONF)
fi
if test "x$ac_cv_prog_AUTOHEADER" = "x"; then
	AUTOHEADER=":"
	AC_SUBST(AUTOHEADER)
fi

MAKE=${MAKE-"make"}
$MAKE -v -f /dev/null 2>/dev/null | $GREP GNU >/dev/null
have_gnu_make=$?


##
#   The Perl function system() is used for running the Net-SNMP regression
#   tests. Find out whether that function invokes a POSIX shell, which is
#   necessary in order to run the regression tests. When using Windows + MSYS
#   + ActiveState Perl, Perl's system() function does invoke Windows' cmd.exe
#   which is not a POSIX shell.
##

AC_MSG_CHECKING([whether the Perl function system() invokes a POSIX shell])
if test "x$PERLPROG" != 'x' && test -x "$PERLPROG" && test "x`$PERLPROG -e 'system('"'"'echo $OSTYPE'"'"');'`" != 'x$OSTYPE'; then
    PERL_SYSTEM_INVOKES_POSIX_SHELL=yes
else
    PERL_SYSTEM_INVOKES_POSIX_SHELL=no
fi
AC_SUBST([PERL_SYSTEM_INVOKES_POSIX_SHELL])
AC_MSG_RESULT([yes])


##
#   Compilation-related program checks:
##

AC_LANG([C])
AC_PROG_CC
AC_PROG_CPP
LINKCC=${LINKCC-"$CC"}
AC_SUBST(LINKCC)

AC_AIX
AC_C_CONST
AC_C_INLINE

#       libtool stuff for shared/static libraries.
#
LT_PREREQ([2.2.6])
LT_INIT([win32-dll])
AC_SUBST(LIBTOOL_DEPS)


##
#   Build environment:
##

#   developer build 
#       (enabled by default when building from SVN checkout)
#
if test "x$developer" != "xno" -a -f $srcdir/remove-files; then
    developer="yes"
fi
AC_MSG_CHECKING([for developer gcc flags])
if test "x$developer" = "xyes" -a "x$GCC" = "xyes"; then

    #       WWWXXX - strict type checking
    #
    DEVFLAGS="-Wall -Wstrict-prototypes -Wwrite-strings -Wcast-qual"
else
    DEVFLAGS=""
fi
AC_MSG_RESULT($DEVFLAGS)
AC_SUBST(DEVFLAGS)


#   building outside source directory
#
#       a) ensure build include paths are before source
#       b) ensure GNU make uses 'vpath' instead of 'VPATH'
#
NON_GNU_VPATH="VPATH ="
GNU_vpath="#vpath"

#       define include paths relative to top_srcdir
#       tweak includes if we're building outside of the source dir
#
if test "x$srcdir" = "x."; then
    TOP_INCLUDES=SRC_TOP_INCLUDES
    SNMPLIB_INCLUDES=SRC_SNMPLIB_INCLUDES
    AGENT_INCLUDES=SRC_AGENT_INCLUDES
    HELPER_INCLUDES=SRC_HELPER_INCLUDES
    MIBGROUP_INCLUDES=SRC_MIBGROUP_INCLUDES
else
    TOP_INCLUDES=BLD_TOP_INCLUDES
    SNMPLIB_INCLUDES=BLD_SNMPLIB_INCLUDES
    AGENT_INCLUDES=BLD_AGENT_INCLUDES
    HELPER_INCLUDES=BLD_HELPER_INCLUDES
    MIBGROUP_INCLUDES=BLD_MIBGROUP_INCLUDES
    if test $have_gnu_make -eq 0 ; then
        NON_GNU_VPATH="#VPATH ="
        GNU_vpath="vpath"
    fi
fi
AC_SUBST(TOP_INCLUDES)
AC_SUBST(SNMPLIB_INCLUDES)
AC_SUBST(AGENT_INCLUDES)
AC_SUBST(HELPER_INCLUDES)
AC_SUBST(MIBGROUP_INCLUDES)
AC_SUBST(GNU_vpath)
AC_SUBST(NON_GNU_VPATH)


##
#   System-related compilation checks:
##

#       What system are we building for
#
AC_CANONICAL_TARGET
changequote(, )
PARTIALTARGETOS=`echo $target_os | sed 's/[-._].*//'`
changequote([, ])
AC_MSG_CACHE_ADD(Building for:               $PARTIALTARGETOS)


#
#    Whether or not Cygwin's ld recognizes the flag -no-undefined. 
#

case x$target_os in
xcygwin*)
  saved_LDFLAGS=$LDFLAGS

  AC_MSG_CHECKING([whether the linker supports -no-undefined])
  LDFLAGS="$saved_LDFLAGS -Wl,-no-undefined"
  AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])],
                 [AC_MSG_RESULT([yes]); dnl
                  LD_NO_UNDEFINED=-no-undefined],
                 [AC_MSG_RESULT([no])])
  
  LDFLAGS="$saved_LDFLAGS"
  ;;
esac

AC_SUBST(LD_NO_UNDEFINED)


#
#   Socket library: either 'default' (non-MinGW) or 'winsock2' (MinGW).
#
case x$target_os in
  xmingw*)
    with_socklib=winsock2
    if test "x$enable_ipv6" = "xyes"; then
      CFLAGS="-D_WIN32_WINNT=0x0501 $CFLAGS"
    fi
    ;;
  *)
    with_socklib=default;;
esac


#   Check system define behaviour
#       Does "-Ux -Dx=x" work as expected?
#
AC_MSG_CHECKING([whether to un-define target system token (before redefining)])
OLD_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="-U$PARTIALTARGETOS -D$PARTIALTARGETOS=$PARTIALTARGETOS"

AC_EGREP_CPP(yes,
    [[
#ifdef $PARTIALTARGETOS
yes
#endif
    ]],
    [  PARTIALTARGETFLAGS="-U$PARTIALTARGETOS -D$PARTIALTARGETOS=$PARTIALTARGETOS"
       AC_MSG_RESULT([yes])],
    [  PARTIALTARGETFLAGS="-D$PARTIALTARGETOS=$PARTIALTARGETOS"
       AC_MSG_RESULT([no])])
CFLAGS="$CFLAGS $PARTIALTARGETFLAGS"
CPPFLAGS="$OLD_CPPFLAGS"


#       Determine appropriate <net-snmp/system/{os}.h> include
#
AC_MSG_CHECKING([for system include file])
changequote(, )
filebase=$target_os
# ignore binary format indication
filebase=`echo $filebase | $SED 's/elf//'`
filebase=`echo $filebase | $SED 's/aout//'`
filebase=`echo $filebase | $SED 's/ecoff//'`
filebase=`echo $filebase | $SED 's/coff//'`
while test "x$filebase" != "x$last" -a ! -f $srcdir/include/net-snmp/system/$filebase.h
do
    last=$filebase
    filebase=`echo $filebase | $SED 's/[-._][^-._]*$//'`
    if test "x$filebase" = "x$last"; then
	filebase=`echo $filebase | $SED 's/[0-9]*$//'`
    fi
done

if test "x$filebase" = "x$last"; then
    filebase="generic"
fi
ac_cv_NETSNMP_SYSTEM_INCLUDE_FILE="net-snmp/system/$filebase.h"
changequote([, ])
AC_MSG_RESULT($ac_cv_NETSNMP_SYSTEM_INCLUDE_FILE)
AC_DEFINE_UNQUOTED(NETSNMP_SYSTEM_INCLUDE_FILE, "$ac_cv_NETSNMP_SYSTEM_INCLUDE_FILE")


#       Determine appropriate <net-snmp/machine/{cpu}.h> include
#
AC_MSG_CHECKING([for machine-type include file])
changequote(, )
filebase=$target_cpu
while test "x$filebase" != "x$last" -a ! -f $srcdir/include/net-snmp/machine/$filebase.h
do
    last=$filebase
    filebase=`echo $filebase | $SED 's/[-._][^-._]*$//'`
done

if test "x$filebase" = "x$last"; then
    filebase="generic"
fi
ac_cv_NETSNMP_MACHINE_INCLUDE_FILE="net-snmp/machine/$filebase.h"
changequote([, ])
AC_MSG_RESULT([$ac_cv_NETSNMP_MACHINE_INCLUDE_FILE])
AC_DEFINE_UNQUOTED(NETSNMP_MACHINE_INCLUDE_FILE, "$ac_cv_NETSNMP_MACHINE_INCLUDE_FILE")


##
#   Platform-specific compilation checks:
##

#   Preprocessor checks:
#

#       More sensible system identifier                 (MinGW)
#
if test "x$PARTIALTARGETOS" = "xmingw32msvc"; then
	CFLAGS="$CFLAGS -Dmingw32"
fi

#       Handle .in file extension                       (GCC)
#
AC_MSG_CHECKING([for additional cpp flags])
if test "x$GCC" = "xyes" -a "x$CPP" = "x$CC -E"; then
    EXTRACPPFLAGS="-x c"
else
    EXTRACPPFLAGS=""
fi

#       Solaris extra CPP flags                         (Solaris)
#
if test "x$GCC" != "xyes"; then
    case $target_os in
        solaris*) EXTRACPPFLAGS="$EXTRACPPFLAGS -Xs" ;;
    esac
fi

AC_SUBST(EXTRACPPFLAGS)
AC_MSG_RESULT($EXTRACPPFLAGS)


#   Compiler checks:
#

AC_PATH_PROG([CCPATH],$CC)
case $target_os in
    bsdi*)
        #   Check for bundled compiler                  (BSDi)
        #
	if test "x$CCPATH" = "x/usr/ucb/cc" -o "x$CCPATH" = "x/usr/bin/cc"; then
	    AC_MSG_ERROR([

*** The BSDI /usr/ucb/cc compiler does not work with this package.  
*** Please run configure with --with-cc=gcc
])
	fi
    ;;
    solaris*)
        #   Check for bundled compiler                  (Solaris)
        #
	if test "x$CCPATH" = "x/usr/ucb/cc"; then
	    AC_MSG_ERROR([

*** The solaris /usr/ucb/cc compiler does not work with this package.  
*** Please put a different compiler in your path first or run
*** configure with --with-cc=XX, where XX is the compiler you want to use.
])
	fi
    ;;
esac


#   Compiler flags:
#

# The Net-SNMP source code is not strict-aliasing safe, so add
# -fno-strict-aliasing to $CFLAGS if the compiler supports it.
AC_MSG_CHECKING([whether the compiler supports -fno-strict-aliasing])
netsnmp_save_CFLAGS="$CFLAGS"
CFLAGS="-fno-strict-aliasing $CFLAGS"
AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])], [AC_MSG_RESULT([yes])], [
  AC_MSG_RESULT([no])
  CFLAGS="$netsnmp_save_CFLAGS"
])


#   Linker checks:
#
    
case $target_os in
    aix4.2*|aix4.3*|aix5*|aix6*|aix7*)
        #   Runtime linking flags                       (AIX)
        #
        AC_MSG_CHECKING([what linker flags to add to enable runtime linking on AIX])
        for ld_flag in $LDFLAGS; do
            if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
                netsnmp_aix_runtimelinking_flags_ok=yes
                break
            fi
        done
        if test "X$netsnmp_aix_runtimelinking_flags_ok" != "Xyes"; then
	    if test "x$GCC" = "xyes"; then
	        netsnmp_aix_ldflags="-Wl,-brtl"
	    else
                netsnmp_aix_ldflags="-brtl"
	    fi
            LDFLAGS="$netsnmp_aix_ldflags $LDFLAGS"
	    AC_MSG_RESULT($netsnmp_aix_ldflags)
	else
	    AC_MSG_RESULT([none])
	fi
	;;

    darwin8*|darwin9*|darwin10*)
        #   Flat Namespace linking                      (Mac OS/X)
        #
        AC_MSG_CHECKING([whether darwin ld might need -flat_namespace])
	if test -z "$MACOSX_DEPLOYMENT_TARGET"; then
		LDFLAGS="-flat_namespace $LDFLAGS"
		AC_MSG_RESULT([yes])
	else
		AC_MSG_RESULT([no])
	fi
	;;

    *)
        ;;
esac


#       dpkg package (swintst_apt)
#	    used in agent only
#
AC_PATH_PROG([DPKG_QUERY_PATH], dpkg-query)
if test x$DPKG_QUERY_PATH != x; then
    AC_DEFINE(HAVE_DPKG_QUERY, 1, [Set if the dpkg-query command is available])
fi


##
#   Non-program/compilation checks:
##

#       Substitute version number.
#
AC_SUBST(VERSION, $PACKAGE_VERSION)
AC_MSG_CACHE_ADD(Net-SNMP Version:           $PACKAGE_VERSION)