make_cdilib 4.21 KB
Newer Older
Uwe Schulzweida's avatar
Cleanup  
Uwe Schulzweida committed
1
2
3
4
5
6
7
8
#!/bin/sh
#
# combine source code into one module
# easier to compile -- no make file needed
#
# pretty generic script -- just echos, cats and greps.
#
#
9
srcdir=.
10
11
12
if [ ! -z $1 ] ; then
srcdir=$1
fi
Uwe Schulzweida's avatar
Cleanup  
Uwe Schulzweida committed
13
14
15
16
17
18
19
PROG=cdilib.c
echo "combining source code into one module"
echo "output is ${PROG}"
#set -x

rm -f ${PROG}

20
DATE=`date +%F`
Uwe Schulzweida's avatar
Cleanup  
Uwe Schulzweida committed
21

22
if test -f ../configure.ac ; then
23
   CDILIBVERSION=\"`sed -n '/^AC_INIT(/s/AC_INIT *( *[^,]*,[[ ]*\([^],]*\).*/\1/ p' ../configure.ac`\"
24
else
25
   echo "error: cannot find configure.ac" >&2
26
   exit 1
27
28
fi

Uwe Schulzweida's avatar
Cleanup  
Uwe Schulzweida committed
29
30
cat > ${PROG} << EOR

31
/* Automatically generated by $USER at $DATE, do not edit */
Uwe Schulzweida's avatar
Cleanup  
Uwe Schulzweida committed
32

33
/* CDILIB_VERSION=${CDILIBVERSION} */
34

35
36
37
38
39
40
41
#if defined(_WIN32) || defined(_WIN64)
#define restrict
#define ssize_t long
#else
#define HAVE_UNISTD_H
#endif

Uwe Schulzweida's avatar
Uwe Schulzweida committed
42
43
44
45
#ifdef _ARCH_PWR6
#pragma options nostrict
#endif

46
47
#ifdef HAVE_CONFIG_H
#include "config.h"
Uwe Schulzweida's avatar
Cleanup  
Uwe Schulzweida committed
48
49
#endif

50
51
52
53
#ifndef _XOPEN_SOURCE
#define _XOPEN_SOURCE 600
#endif

54
55
56
57
#ifdef  HAVE_UNISTD_H
#include <unistd.h>
#endif

Uwe Schulzweida's avatar
Cleanup  
Uwe Schulzweida committed
58
59
60
61
62
63
64
65
66
67
68
69
#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>
Deike Kleberg's avatar
Deike Kleberg committed
70
#include <stdbool.h>
71
#include <assert.h>
Deike Kleberg's avatar
Deike Kleberg committed
72

73
74
#ifdef HAVE_LIBGRIB_API
#include <grib_api.h>
Uwe Schulzweida's avatar
Uwe Schulzweida committed
75
76
#endif

77
78
#ifdef HAVE_MMAP
#include <sys/mman.h> /* mmap() is defined in this header */
Uwe Schulzweida's avatar
Uwe Schulzweida committed
79
80
#endif

81
82
#ifdef HAVE_LIBPTHREAD
#include <pthread.h>
Uwe Schulzweida's avatar
Uwe Schulzweida committed
83
84
#endif

85
86
#ifdef HAVE_LIBSZ
#include <szlib.h>
Uwe Schulzweida's avatar
Uwe Schulzweida committed
87
88
#endif

89
90
91
92
93
94
#ifndef HAVE_CONFIG_H
#define  HAVE_LIBGRIB      1
#define  HAVE_LIBCGRIBEX   1
#define  HAVE_LIBSERVICE   1
#define  HAVE_LIBEXTRA     1
#define  HAVE_LIBIEG       1
Uwe Schulzweida's avatar
Cleanup  
Uwe Schulzweida committed
95
96
97
98
#endif

EOR

99
100
files="async_worker.c \
   basetime.c \
101
102
103
104
   binary.c \
   calendar.c \
   cdf.c \
   cdf_int.c \
105
   cdf_util.c \
106
   cdf_lazy_grid.c \
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
   cdi_cksum.c \
   cdi_error.c \
   cdi_int.c \
   cdi_util.c \
   cgribexlib.c \
   cksum.c \
   dmemory.c \
   error.c \
   extralib.c \
   file.c \
   gaussgrid.c \
   gribapi.c \
   gribapi_utilities.c \
   grid.c \
   ieglib.c \
   input_file.c \
   institution.c \
   iterator.c \
   iterator_fallback.c \
   iterator_grib.c \
   model.c \
   namespace.c \
   referenceCounting.c \
130
   resource_handle.c \
131
132
   serialize.c \
   servicelib.c \
Uwe Schulzweida's avatar
Uwe Schulzweida committed
133
   stream_scan.c \
134
   stream.c \
135
   stream_write.c \
136
   stream_read.c \
137
138
   stream_cdf_i.c \
   stream_cdf_o.c \
139
   stream_cdf_time.c \
140
141
142
143
144
145
146
147
   stream_cgribex.c \
   stream_ext.c \
   stream_grb.c \
   stream_gribapi.c \
   stream_ieg.c \
   stream_record.c \
   stream_srv.c \
   stream_var.c \
148
149
   grb_write.c \
   grb_read.c \
150
   cdf_write.c \
151
   cdf_read.c \
152
   subtype.c \
153
154
155
156
157
158
159
160
   swap.c \
   table.c \
   taxis.c \
   timebase.c \
   tsteps.c \
   util.c \
   varscan.c \
   vlist.c \
161
   cdi_key.c \
162
   cdi_att.c \
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
   vlist_var.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
                #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 "$curFile") <$curFile> $scanlist"
            fi
            ;;
    esac
195
196
done

197
198
199
200
echo file list:
echo $fileList

for file in $fileList ; do
201
202
203
204
205
  if [ "$file" = "config.h" ] ; then
    echo "skipped file: $file"
  else
    cat $srcdir/$file | grep -v '^ *# *include  *"'  >> ${PROG}
  fi
206
207
208
done


Thomas Jahns's avatar
Thomas Jahns committed
209
210
cpp -P -DVERSION="${CDILIBVERSION}" -DCDI_H_ \
  $srcdir/version.c >>${PROG}
Uwe Schulzweida's avatar
Cleanup  
Uwe Schulzweida committed
211
212
213
214
215

# Fortran interface (with -DHAVE_CF_INTERFACE)

echo "#if defined (HAVE_CF_INTERFACE)" >>  ${PROG}
echo "#undef realloc" >>  ${PROG}
Uwe Schulzweida's avatar
Uwe Schulzweida committed
216
217
218
echo "#undef malloc"  >>  ${PROG}
echo "#undef calloc"  >>  ${PROG}
echo "#undef free"    >>  ${PROG}
Uwe Schulzweida's avatar
Cleanup  
Uwe Schulzweida committed
219
echo "#undef DOUBLE_PRECISION" >>  ${PROG}
Uwe Schulzweida's avatar
Uwe Schulzweida committed
220
cat $srcdir/cfortran.h   >>  ${PROG}
Uwe Schulzweida's avatar
Cleanup  
Uwe Schulzweida committed
221
echo "#endif" >>  ${PROG}
222
cat $srcdir/cdiFortran.c >>  ${PROG}
Uwe Schulzweida's avatar
Cleanup  
Uwe Schulzweida committed
223
224

exit