mirror of
https://github.com/Unidata/netcdf-c.git
synced 2024-11-27 07:30:33 +08:00
4db4393e69
strlcat provides better protection against buffer overflows. Code is taken from the FreeBSD project source code. Specifically: https://github.com/freebsd/freebsd/blob/master/lib/libc/string/strlcat.c License appears to be acceptable, but needs to be checked by e.g. Debian. Step 1: 1. Add to netcdf-c/include/ncconfigure.h to use our version if not already available as determined by HAVE_STRLCAT in config.h. 2. Add the strlcat code to libdispatch/dstring.c 3. Turns out that strlcat was already defined in several places. So remove it from: ncgen3/genlib.c ncdump/dumplib.c 3. Define strlcat extern definition in ncconfigure.h. 4. Modify following directories to use strlcat: libdap2 libdap4 ncdap_test dap4_test Will do others in subsequent steps.
201 lines
4.2 KiB
Bash
201 lines
4.2 KiB
Bash
#!/bin/bash
|
|
#NB=1
|
|
DB=1
|
|
#X=-x
|
|
FAST=1
|
|
|
|
HDF5=1
|
|
DAP=1
|
|
#SZIP=1
|
|
#HDF4=1
|
|
#PNETCDF=1
|
|
#PAR4=1
|
|
|
|
if test $# != 0 ; then
|
|
cmds=$@
|
|
fi
|
|
|
|
if test "x$PNETCDF" = x1 -o "x$PAR4" = x1 ; then
|
|
MPIO=1
|
|
fi
|
|
|
|
CFLAGS=""
|
|
#CFLAGS="-Wall -Wno-unused-but-set-variable -Wno-unused-variable -Wno-unused-parameter -Wconversion ${CFLAGS}"
|
|
CFLAGS="-Wall -Wno-unused-but-set-variable -Wno-unused-variable -Wno-unused-parameter -Wno-char-subscripts -Wno-pointer-sign -Wno-format ${CFLAGS}"
|
|
#CFLAGS="-Wall ${CFLAGS}"
|
|
#CFLAGS="-Wconversion"
|
|
|
|
stddir="/usr/local"
|
|
PREFIX=/usr/local
|
|
|
|
if test "x${cmds}" = x ; then
|
|
cmds=""
|
|
else
|
|
for f in $cmds ; do
|
|
if test "x$f" = "xdistcheck" ; then
|
|
PREFIX=/tmp/$HOST
|
|
fi
|
|
done
|
|
fi
|
|
|
|
# HDF4=>HDF5
|
|
if test "x$HDF4" = x1 ; then
|
|
HDF5=1
|
|
fi
|
|
|
|
# !HDF5=>!SZIP
|
|
if test "x$HDF5" != x1 ; then
|
|
SZIP=0
|
|
fi
|
|
|
|
CC=gcc
|
|
|
|
MALLOC_CHECK=""
|
|
|
|
CPPFLAGS=""
|
|
LDFLAGS=""
|
|
|
|
CFLAGS="-g -O0 $CFLAGS -Wno-undefined"
|
|
|
|
MAKE=make
|
|
IGNORE="test 0 = 1"
|
|
|
|
if test "x$HDF5" = "x1" ; then
|
|
CPPFLAGS="-I${stddir}/include $CPPFLAGS"
|
|
LDFLAGS="-L${stddir}/lib -lhdf5_hl -lhdf5 -lz $LDFLAGS"
|
|
LD_LIBRARY_PATH="${stddir}/lib:$LD_LIBRARY_PATH"
|
|
fi
|
|
|
|
if test "x$HDF4" = "x1" ; then
|
|
LDFLAGS="$LDFLAGS -ljpeg"
|
|
fi
|
|
|
|
if test "x$SZIP" = "x1" ; then
|
|
LDFLAGS="$LDFLAGS -lsz -laec"
|
|
fi
|
|
|
|
export PKG_CONFIG_PATH=/usr/lib/pkgconfig
|
|
if test "x$DAP" = "x1" ; then
|
|
if curl-config --version >/dev/null ; then
|
|
TMP=`curl-config --cflags`
|
|
CPPFLAGS="$TMP $CPPFLAGS"
|
|
TMP=`curl-config --libs`
|
|
LDFLAGS="$TMP $LDFLAGS"
|
|
TMP=`curl-config --prefix`
|
|
LD_LIBRARY_PATH="$TMP/lib:$LD_LIBRARY_PATH"
|
|
else
|
|
LDFLAGS="${LDFLAGS} -lcurl"
|
|
fi
|
|
fi
|
|
|
|
CXXFLAGS="$CPPFLAGS $CXXFLAGS"
|
|
|
|
FLAGS="--prefix ${PREFIX}"
|
|
#FLAGS="$FLAGS --disable-f77 --disable-f90"
|
|
#FLAGS="$FLAGS --disable-cxx"
|
|
FLAGS="$FLAGS --disable-examples"
|
|
#FLAGS="$FLAGS --disable-utilities"
|
|
#FLAGS="$FLAGS --enable-cxx-4"
|
|
#FLAGS="$FLAGS --enable-dap-long-tests"
|
|
#FLAGS="$FLAGS --enable-ffio"
|
|
#FLAGS="$FLAGS --enable-benchmarks"
|
|
FLAGS="$FLAGS --enable-extreme-numbers"
|
|
FLAGS="$FLAGS --enable-extra-tests"
|
|
#FLAGS="$FLAGS --enable-large-file-tests"
|
|
#FLAGS="$FLAGS --disable-testsets"
|
|
#FLAGS="$FLAGS --disable-dap-remote-tests"
|
|
#FLAGS="$FLAGS --enable-dap-auth-tests" -- requires a new remotetest server
|
|
#FLAGS="$FLAGS --enable-doxygen --enable-internal-docs"
|
|
FLAGS="$FLAGS --enable-logging"
|
|
#FLAGS="$FLAGS --disable-diskless"
|
|
#FLAGS="$FLAGS --enable-mmap"
|
|
#FLAGS="$FLAGS --with-udunits"
|
|
#FLAGS="$FLAGS --with-libcf"
|
|
#valgrind => not shared
|
|
#FLAGS="$FLAGS --enable-valgrind-tests"
|
|
#FLAGS="$FLAGS --enable-jna"
|
|
#FLAGS="$FLAGS --disable-properties-attribute"
|
|
#FLAGS="$FLAGS --disable-silent-rules"
|
|
#FLAGS="$FLAGS --with-testservers=remotestserver.localhost:8083"
|
|
#FLAGS="$FLAGS --enable-filter-test"
|
|
|
|
if test "x$PAR4" != x1 ; then
|
|
FLAGS="$FLAGS --disable-parallel4"
|
|
fi
|
|
|
|
if test "x${DB}" = x1 ; then
|
|
FLAGS="$FLAGS --disable-shared --enable-static"
|
|
else
|
|
FLAGS="$FLAGS --enable-shared"
|
|
fi
|
|
|
|
#TMP=
|
|
#rm -f ./test_mpi.tmp
|
|
#if test -f $stddir/lib/libhdf5.a ; then
|
|
# nm $stddir/lib/libhdf5.a | grep mpich_mpi_float$ >./test_mpi.tmp
|
|
#else
|
|
# if test -f $stddir/lib/libhdf5.so ; then
|
|
# nm $stddir/lib/libhdf5.so | grep mpich_mpi_float$ >./test_mpi.tmp
|
|
# fi
|
|
#fi
|
|
#if test -s ./test_mpi.tmp ; then
|
|
# PAR=1
|
|
#fi
|
|
#rm -f ./test_mpi.tmp
|
|
|
|
if test "x${PAR}" != x ; then
|
|
FLAGS="$FLAGS --enable-parallel"
|
|
fi
|
|
|
|
if test "x$HDF5" = "x" ; then
|
|
FLAGS="$FLAGS --disable-netcdf-4"
|
|
fi
|
|
if test "x$HDF4" = x1 ; then
|
|
FLAGS="$FLAGS --enable-hdf4 --enable-hdf4-file-tests"
|
|
fi
|
|
if test "x$DAP" = "x" ; then
|
|
FLAGS="$FLAGS --disable-dap"
|
|
fi
|
|
|
|
if test "x$MPIO" = x1 ; then
|
|
MPIDIR=/usr/lib64/mpich
|
|
PATH="${PATH}:${MPIDIR}/bin"
|
|
CC="${MPIDIR}/bin/mpicc"
|
|
CPPFLAGS="-I${MPIDIR}/include"
|
|
LDFLAGS="$LDFLAGS -L${MPIDIR}"
|
|
LDLIBS="-lmpich"
|
|
FLAGS="$FLAGS --enable-pnetcdf"
|
|
FLAGS="$FLAGS --enable-parallel-tests"
|
|
fi
|
|
|
|
#FLAGS="${FLAGS} --enable-stdio"
|
|
|
|
export PATH
|
|
export CC
|
|
export CPPFLAGS
|
|
export CFLAGS
|
|
export LDFLAGS
|
|
export LD_LIBRARY_PATH
|
|
export MALLOC_CHECK
|
|
export CXXFLAGS
|
|
|
|
DISTCHECK_CONFIGURE_FLAGS="$FLAGS"
|
|
export DISTCHECK_CONFIGURE_FLAGS
|
|
|
|
if test "x$NB" != x -o "x$FAST" = x ; then
|
|
${MAKE} maintainer-clean >/dev/null 2>&1
|
|
fi
|
|
if test -z "$NB" ; then
|
|
if autoreconf -i --force ; then ok=1; else exit ; fi
|
|
fi
|
|
|
|
if test -z "$FAST" ; then
|
|
if test -f Makefile ; then ${MAKE} distclean >/dev/null 2>&1 ; fi
|
|
fi
|
|
sh $X ./configure ${FLAGS}
|
|
for c in $cmds; do
|
|
printenv LD_LIBRARY_PATH
|
|
${MAKE} ${FORCE} $c
|
|
done
|
|
exit 0
|