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
|
#!/bin/sh
#
# combine source code into one module
# easier to compile -- no make file needed
#
# pretty generic script -- just echos, cats and greps.
#
#
srcdir=.
if [ ! -z $1 ] ; then
srcdir=$1
fi
PROG=cdilib.c
echo "combining source code into one module"
echo "output is ${PROG}"
#set -x
rm -f ${PROG}
DATE=`date +%F`
config_file="${srcdir}/../configure.ac"
if test -f "$config_file" ; then
CDILIBVERSION=\"`sed -n '/^AC_INIT(/s/AC_INIT *( *[^,]*,[[ ]*\([^],]*\).*/\1/ p' "$config_file"`\"
else
echo "error: cannot find configure.ac" >&2
exit 1
fi
cat > ${PROG} << EOR
/* Automatically generated by $USER at $DATE, do not edit */
/* CDILIB_VERSION=${CDILIBVERSION} */
#if defined(_WIN32) || defined(_WIN64)
#define restrict
#define ssize_t long
#elif ! defined HAVE_CONFIG_H
#define HAVE_UNISTD_H
#endif
#ifdef _ARCH_PWR6
#pragma options nostrict
#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#ifndef _XOPEN_SOURCE
#define _XOPEN_SOURCE 600
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <ctype.h>
#include <limits.h>
#include <float.h>
#include <math.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdbool.h>
#include <assert.h>
#ifdef HAVE_LIBGRIB_API
#include <grib_api.h>
#endif
#ifdef HAVE_MMAP
#include <sys/mman.h> /* mmap() is defined in this header */
#endif
#ifdef HAVE_LIBPTHREAD
#include <pthread.h>
#endif
#ifdef HAVE_LIBSZ
#include <szlib.h>
#endif
#ifndef HAVE_CONFIG_H
#define HAVE_LIBGRIB 1
#define HAVE_LIBCGRIBEX 1
#define HAVE_LIBSERVICE 1
#define HAVE_LIBEXTRA 1
#define HAVE_LIBIEG 1
#define CDI -1
#endif
EOR
files="async_worker.c \
basetime.c \
binary.c \
calendar.c \
cdf.c \
cdf_int.c \
cdf_util.c \
cdf_lazy_grid.c \
cdi_cksum.c \
cdi_error.c \
cdi_datetime.c \
cdi_int.c \
cdi_query.c \
cdi_util.c \
cgribexlib.c \
cksum.c \
dmemory.c \
error.c \
extralib.c \
file.c \
gaussian_latitudes.c \
get_num_missvals.c \
gribapi.c \
gribapi_utilities.c \
grid.c \
ieglib.c \
input_file.c \
institution.c \
iterator.c \
iterator_fallback.c \
iterator_grib.c \
julian_date.c \
model.c \
namespace.c \
referenceCounting.c \
resource_handle.c \
serialize.c \
servicelib.c \
stream_scan.c \
stream.c \
stream_write.c \
stream_read.c \
stream_cdf_i.c \
stream_cdf_o.c \
stream_cdf_time.c \
stream_cgribex.c \
stream_ext.c \
stream_grb.c \
stream_gribapi.c \
stream_ieg.c \
stream_record.c \
stream_srv.c \
stream_var.c \
grb_write.c \
grb_read.c \
cdf_write.c \
cdf_read.c \
subtype.c \
swap.c \
table.c \
taxis.c \
tsteps.c \
util.c \
varscan.c \
vlist.c \
cdi_key.c \
cdi_att.c \
vlist_var.c \
vlist_var_pack.c \
vlist_var_key.c \
zaxis.c"
car () {
echo "$1"
}
cdr () {
shift
echo "$@"
}
listIncludes () {
grep '^ *# *include *"' "$1" | sed 's/^ *# *include *"\(.*\)".*$/\1/'
}
scanlist="$files"
fileList=
until test "foo$scanlist" = "foo" ; do
curFile="$(car $scanlist)"
scanlist="$(cdr $scanlist)"
case $curFile in
(\<*\>)
fileList="$fileList $(echo "$curFile" | sed 's/<\(.*\)>/\1/')"
;;
(*)
if echo "$fileList" | grep -q '\<'"$curFile"'\>' ; then
true #Nothing to do, we have already scanned this header.
else
curFilePath="$srcdir/$curFile"
if [ "$curFile" = "config.h" ] ; then curFilePath="$curFile" ; fi
#Prepend the includes of the current header to the scanlist so that we will scan them in the order that the preprocessor would.
scanlist="$(listIncludes "$curFilePath") <$curFile> $scanlist"
fi
;;
esac
done
echo file list:
echo $fileList
for file in $fileList ; do
if [ "$file" = "config.h" ] ; then
echo "skipped file: $file"
else
cat $srcdir/$file | grep -v '^ *# *include *"' >> ${PROG}
fi
done
${CPP-cpp} -P -DVERSION="${CDILIBVERSION}" -DCDI_H_ \
$srcdir/version.c >>${PROG}
# Fortran interface (with -DHAVE_CF_INTERFACE)
echo "#if defined (HAVE_CF_INTERFACE)" >> ${PROG}
echo "#undef realloc" >> ${PROG}
echo "#undef malloc" >> ${PROG}
echo "#undef calloc" >> ${PROG}
echo "#undef free" >> ${PROG}
echo "#undef DOUBLE_PRECISION" >> ${PROG}
cat `if test -f cfortran.h; then echo cfortran.h; else echo $srcdir/cfortran.h; fi;` >> ${PROG}
echo "#endif" >> ${PROG}
cat `if test -f cdiFortran.c; then echo cdiFortran.c; else echo $srcdir/cdiFortran.c; fi;` >> ${PROG}
exit
|