make_cdilib 3.89 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
10
11
12
srcdir=./
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

Uwe Schulzweida's avatar
Uwe Schulzweida committed
35
36
37
38
#ifdef _ARCH_PWR6
#pragma options nostrict
#endif

Uwe Schulzweida's avatar
Cleanup  
Uwe Schulzweida committed
39
40
41
42
#if  defined  (HAVE_CONFIG_H)
#  include "config.h"
#endif

43
44
45
46
#ifndef _XOPEN_SOURCE
#define _XOPEN_SOURCE 600
#endif

Uwe Schulzweida's avatar
Cleanup  
Uwe Schulzweida committed
47
48
49
50
51
52
53
54
55
56
57
58
59
#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 <unistd.h>
Deike Kleberg's avatar
Deike Kleberg committed
60
#ifndef _SX
Deike Kleberg's avatar
Deike Kleberg committed
61
#include <aio.h>
Deike Kleberg's avatar
Deike Kleberg committed
62
#endif
Deike Kleberg's avatar
Deike Kleberg committed
63
#include <stdbool.h>
64
#ifdef USE_MPI
Deike Kleberg's avatar
Deike Kleberg committed
65
#include "mpi.h"
66
#endif
67
#include <assert.h>
Deike Kleberg's avatar
Deike Kleberg committed
68

Uwe Schulzweida's avatar
Uwe Schulzweida committed
69
70
71
72
#if  defined  (HAVE_LIBGRIB_API)
#  include <grib_api.h>
#endif

73
#if  defined  (HAVE_MMAP)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
74
75
76
77
78
79
80
81
82
83
84
#  include <sys/mman.h> /* mmap() is defined in this header */
#endif

#if  defined  (HAVE_LIBPTHREAD)
#  include <pthread.h>
#endif

#if  defined  (HAVE_LIBSZ)
#  include <szlib.h>
#endif

Uwe Schulzweida's avatar
Cleanup  
Uwe Schulzweida committed
85
86
#if ! defined (HAVE_CONFIG_H)
#  define  HAVE_LIBGRIB      1
Uwe Schulzweida's avatar
Uwe Schulzweida committed
87
#  define  HAVE_LIBCGRIBEX   1
Uwe Schulzweida's avatar
Cleanup  
Uwe Schulzweida committed
88
89
90
91
92
93
94
#  define  HAVE_LIBSERVICE   1
#  define  HAVE_LIBEXTRA     1
#  define  HAVE_LIBIEG       1
#endif

EOR

Uwe Schulzweida's avatar
Uwe Schulzweida committed
95
c="dmemory.c         \
96
   dmemory.h         \
97
   cksum.c           \
98
   cdi_cksum.c       \
99
   taxis.c           \
100
   timebase.c        \
Uwe Schulzweida's avatar
Cleanup  
Uwe Schulzweida committed
101
102
103
104
105
   calendar.c        \
   model.c           \
   institution.c     \
   table.c           \
   util.c            \
106
   gaussgrid.c       \
Uwe Schulzweida's avatar
Cleanup  
Uwe Schulzweida committed
107
108
   varscan.c         \
   vlist.c           \
109
   vlist_att.c       \
Uwe Schulzweida's avatar
Cleanup  
Uwe Schulzweida committed
110
111
112
113
114
115
116
117
118
   vlist_var.c       \
   basetime.c        \
   servicelib.c      \
   extralib.c        \
   ieglib.c          \
   grid.c            \
   zaxis.c           \
   cdf_int.c         \
   cdi_error.c       \
Uwe Schulzweida's avatar
Uwe Schulzweida committed
119
   cdi_util.c        \
120
   cdi_int.c         \
Uwe Schulzweida's avatar
Cleanup  
Uwe Schulzweida committed
121
122
   stream.c          \
   stream_history.c  \
Uwe Schulzweida's avatar
Uwe Schulzweida committed
123
124
   stream_cgribex.c  \
   stream_gribapi.c  \
Uwe Schulzweida's avatar
Cleanup  
Uwe Schulzweida committed
125
126
127
128
129
130
131
132
133
   stream_grb.c      \
   stream_srv.c      \
   stream_ext.c      \
   stream_ieg.c      \
   stream_cdf.c      \
   stream_var.c      \
   stream_record.c   \
   tsteps.c          \
   file.c            \
Uwe Schulzweida's avatar
Uwe Schulzweida committed
134
   cgribexlib.c      \
Uwe Schulzweida's avatar
Uwe Schulzweida committed
135
   gribapi.c         \
Uwe Schulzweida's avatar
Cleanup  
Uwe Schulzweida committed
136
137
   swap.c            \
   binary.c          \
138
   cdf.c             \
Uwe Schulzweida's avatar
Uwe Schulzweida committed
139
   namespace.c       \
140
   serialize.c       \
141
   resource_handle.c"
Uwe Schulzweida's avatar
Cleanup  
Uwe Schulzweida committed
142

Uwe Schulzweida's avatar
Uwe Schulzweida committed
143
h="cdi_limits.h resource_handle.h taxis.h dtypes.h file.h service.h extra.h \
144
   ieg.h cdi.h timebase.h calendar.h basetime.h datetime.h namespace.h \
145
   cksum.h cdi_cksum.h error.c error.h cdi_int.h cgribex.h gribapi.h \
146
   stream_cgribex.h stream_gribapi.h  stream_grb.h  stream_cdf.h \
147
   tablepar.h table.h gaussgrid.h grid.h zaxis.h varscan.h binary.h swap.h \
Uwe Schulzweida's avatar
Cleanup  
Uwe Schulzweida committed
148
   service.h stream_srv.h stream_ext.h stream_ieg.h cdf_int.h  \
Uwe Schulzweida's avatar
Uwe Schulzweida committed
149
   cdf.h vlist.h vlist_var.h vlist_att.h model.h institution.h \
150
   resource_unpack.h serialize.h"
Uwe Schulzweida's avatar
Cleanup  
Uwe Schulzweida committed
151

152
153
#cat $h >> ${PROG}
#cat $c | grep -v '#include' | grep -v '#  include' >> ${PROG}
Uwe Schulzweida's avatar
Cleanup  
Uwe Schulzweida committed
154

155
156
157
158
159
for hfile in $h ; do
  cat $srcdir/$hfile  >> ${PROG}
done

for cfile in $c ; do
160
  cat $srcdir/$cfile | grep -v '#include "' | grep -v '#  include "' >> ${PROG}
161
162
163
done


164
cpp -P -DVERSION="${CDILIBVERSION}" $srcdir/version.c >>${PROG}
Uwe Schulzweida's avatar
Cleanup  
Uwe Schulzweida committed
165
166
167
168
169

# Fortran interface (with -DHAVE_CF_INTERFACE)

echo "#if defined (HAVE_CF_INTERFACE)" >>  ${PROG}
echo "#undef realloc" >>  ${PROG}
Uwe Schulzweida's avatar
Uwe Schulzweida committed
170
171
172
echo "#undef malloc"  >>  ${PROG}
echo "#undef calloc"  >>  ${PROG}
echo "#undef free"    >>  ${PROG}
Uwe Schulzweida's avatar
Cleanup  
Uwe Schulzweida committed
173
echo "#undef DOUBLE_PRECISION" >>  ${PROG}
Uwe Schulzweida's avatar
Uwe Schulzweida committed
174
cat $srcdir/cfortran.h   >>  ${PROG}
Uwe Schulzweida's avatar
Cleanup  
Uwe Schulzweida committed
175
echo "#endif" >>  ${PROG}
176
cat $srcdir/cdiFortran.c >>  ${PROG}
Uwe Schulzweida's avatar
Cleanup  
Uwe Schulzweida committed
177
178

exit