make_cdilib 3.9 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
23
24
25
if test -f config.h ; then
   CDILIBVERSION=`grep PACKAGE_VERSION config.h | cut -f3 -d" "`
fi

Uwe Schulzweida's avatar
Cleanup  
Uwe Schulzweida committed
26
27
cat > ${PROG} << EOR

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

30
/* CDILIB_VERSION=${CDILIBVERSION} */
31

Uwe Schulzweida's avatar
Cleanup  
Uwe Schulzweida committed
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#if  defined  (HAVE_CONFIG_H)
#  include "config.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 <unistd.h>
49
50
51
52
53
54
55
#ifndef _SX
#include <aio.h>
#endif
#include <stdbool.h>
#ifdef USE_MPI
#include "mpi.h"
#endif
56
#include <assert.h>
Uwe Schulzweida's avatar
Cleanup  
Uwe Schulzweida committed
57

Uwe Schulzweida's avatar
Uwe Schulzweida committed
58
59
60
61
#if  defined  (HAVE_LIBGRIB_API)
#  include <grib_api.h>
#endif

Uwe Schulzweida's avatar
Uwe Schulzweida committed
62
#if  defined  (HAVE_MMAP)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
63
64
65
66
67
68
69
70
71
72
73
#  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
74
75
#if ! defined (HAVE_CONFIG_H)
#  define  HAVE_LIBGRIB      1
Uwe Schulzweida's avatar
Uwe Schulzweida committed
76
#  define  HAVE_LIBCGRIBEX   1
Uwe Schulzweida's avatar
Cleanup  
Uwe Schulzweida committed
77
78
79
80
81
82
83
#  define  HAVE_LIBSERVICE   1
#  define  HAVE_LIBEXTRA     1
#  define  HAVE_LIBIEG       1
#endif

EOR

Uwe Schulzweida's avatar
Uwe Schulzweida committed
84
c="dmemory.c         \
Uwe Schulzweida's avatar
Cleanup  
Uwe Schulzweida committed
85
86
   dmemory.h         \
   error.c           \
Uwe Schulzweida's avatar
Uwe Schulzweida committed
87
   error.h           \
88
   stream_int.h      \
Uwe Schulzweida's avatar
Uwe Schulzweida committed
89
   taxis.c           \
90
   timebase.c        \
Uwe Schulzweida's avatar
Cleanup  
Uwe Schulzweida committed
91
92
93
94
95
   calendar.c        \
   model.c           \
   institution.c     \
   table.c           \
   util.c            \
96
   gaussgrid.c       \
Uwe Schulzweida's avatar
Cleanup  
Uwe Schulzweida committed
97
98
   varscan.c         \
   vlist.c           \
99
   vlist_att.c       \
Uwe Schulzweida's avatar
Cleanup  
Uwe Schulzweida committed
100
101
102
103
104
105
106
107
108
   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
109
   cdi_util.c        \
Uwe Schulzweida's avatar
Cleanup  
Uwe Schulzweida committed
110
111
112
   stream_int.c      \
   stream.c          \
   stream_history.c  \
Uwe Schulzweida's avatar
Uwe Schulzweida committed
113
114
   stream_cgribex.c  \
   stream_gribapi.c  \
Uwe Schulzweida's avatar
Cleanup  
Uwe Schulzweida committed
115
116
117
118
119
120
121
122
123
   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
124
   cgribexlib.c      \
Uwe Schulzweida's avatar
Uwe Schulzweida committed
125
   gribapi.c         \
Uwe Schulzweida's avatar
Cleanup  
Uwe Schulzweida committed
126
127
128
   swap.c            \
   binary.c          \
   cdf.c             \
129
130
131
132
   namespace.c       \
   resource_handle.c \
   pio_util.c        \
   pio.c             \
133
   pio_interface.c   \
134
135
136
137
138
139
   pio_dbuffer.c     \
   pio_mpinonb.c     \
   pio_posixasynch.c \
   pio_posixfpguardsendrecv.c\
   pio_posixnonb.c   \
   pio_list_set.c"
Uwe Schulzweida's avatar
Cleanup  
Uwe Schulzweida committed
140

Uwe Schulzweida's avatar
Uwe Schulzweida committed
141
h="cdi_limits.h taxis.h dtypes.h file.h cgribex.h gribapi.h service.h extra.h \
142
   ieg.h cdi.h timebase.h calendar.h basetime.h datetime.h \
Uwe Schulzweida's avatar
Uwe Schulzweida committed
143
   stream_cgribex.h  stream_gribapi.h  stream_grb.h  stream_cdf.h \
144
   tablepar.h table.h gaussgrid.h grid.h varscan.h binary.h swap.h \
Uwe Schulzweida's avatar
Cleanup  
Uwe Schulzweida committed
145
   service.h stream_srv.h stream_ext.h stream_ieg.h cdf_int.h  \
146
147
   cdf.h vlist.h vlist_var.h vlist_att.h model.h institution.h \
   namespace.h resource_handle.h pio_util.h pio.h pio_impl.h"
Uwe Schulzweida's avatar
Cleanup  
Uwe Schulzweida committed
148

149
150
#cat $h >> ${PROG}
#cat $c | grep -v '#include' | grep -v '#  include' >> ${PROG}
Uwe Schulzweida's avatar
Cleanup  
Uwe Schulzweida committed
151

152
153
154
155
156
for hfile in $h ; do
  cat $srcdir/$hfile  >> ${PROG}
done

for cfile in $c ; do
Uwe Schulzweida's avatar
Uwe Schulzweida committed
157
  cat $srcdir/$cfile | grep -v '#include "' | grep -v '#  include "' >> ${PROG}
158
159
160
161
162
done


if test -f  config.h ; then
   cpp -P -DHAVE_CONFIG_H  -I./ $srcdir/version.c >>  ${PROG}
Uwe Schulzweida's avatar
Cleanup  
Uwe Schulzweida committed
163
164
165
166
167
168
169
170
else
   echo "error: missing config.h"
fi

# Fortran interface (with -DHAVE_CF_INTERFACE)

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

exit