Newer
Older
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
# REQUIRES GMAKE!!!!
#
# makefile for wgrib2
#
# compiles every #@?! library needed by wgrib2
# then tries to compile wgrib2
#
# mod 1/07 M. Schwarb (libgrib2c name change)
#
# this version uses netcdf libraries -- compile C only version
# get from UCAR if compile doesn't work
#
#
# on NCEP AIX
# export CC=/usr/vacpp/bin/xlC_r
# export CPP=/usr/bin/cpp
# netcdf: write netcdf files
# regex: regular expression package used by (match,not), POSIX-2
# tigge: enable -tigge option for tigge names
# mysql: write to mysql files
USE_NETCDF=0
USE_REGEX=1
USE_TIGGE=1
USE_MYSQL=0
# wCPPFLAGS has the directory of the includes
# wLDFLAGS has the directory/name of the library
# DEFS = -D.... (definitions for C compiler)
DEFS=
wCPPFLAGS=-O2
wLDFLAGS=
ifeq ($(USE_REGEX),1)
DEFS+=-DUSE_REGEX
endif
ifeq ($(USE_TIGGE),1)
DEFS+=-DUSE_TIGGE
endif
# grib2c library
g=g2clib-1.1.7
glib=$g/libgrib2c.a
wLDFLAGS+=-L../$g -lgrib2c
wCPPFLAGS+=-I../$g
ifeq ($(USE_NETCDF),1)
n=netcdf-3.6.2
nlib=$n/libsrc/.libs/libnetcdf.a
wLDFLAGS+=-L../$n/libsrc/.libs -lnetcdf
wCPPFLAGS+=-I../$n/libsrc
DEFS+=-DUSE_NETDEF
endif
ifeq ($(USE_MYSQL),1)
DEFS+=-DUSE_MYSQL
# wCPPFLAGS+=-I/export/wesley/wd51we/download/mysql-5.0.51a-linux-i686-glibc23/include
# wLDFLAGS+=/export/wesley/wd51we/download/mysql-5.0.51a-linux-i686-glibc23/lib/libmysqlclient.a
# wLDFLAGS+=-L/export/wesley/wd51we/download/mysql-5.0.51a-linux-i686-glibc23/lib -lmysqlclient
wCPPFLAGS+=`mysql_config --cflags`
wLDFLAGS=`mysql_config --libs`
endif
# Jasper
j=jasper-1.900.1
jlib=$j/src/libjasper/.libs/libjasper.a
wLDFLAGS+=-L../$j/src/libjasper/.libs -ljasper
wCPPFLAGS+=-I../$j/src/libjasper/include
# png
p=libpng-1.2.23
plib=$p/.libs/libpng.a
wLDFLAGS+=-L../$p/.libs -lpng
wCPPFLAGS+=-I../$p
# z
z=zlib-1.2.3
zlib=$z/libz.a
wLDFLAGS+=-L../$z -lz
wCPPFLAGS+=-I../$z
wLDFLAGS+=-lm
wCPPFLAGS+=-I/usr/include ${CPPFLAGS}
# -----------------------------------------------------
w=wgrib2
prog=$w/wgrib2
# check if make is GNU make else use gmake
make_is_gnu:=$(word 1,$(shell make -v))
ifeq ($(make_is_gnu),GNU)
MAKE:=make
else
MAKE:=gmake
endif
all: ${jlib} ${plib} ${zlib} ${glib} ${nlib} ${prog}
${jlib}:
cp $j.tar.gz tmpj.tar.gz
gunzip -n tmpj.tar.gz
tar -xvf tmpj.tar
rm tmpj.tar
cd $j && ./configure --disable-libjpeg --disable-opengl && ${MAKE}
${plib}: ${zlib}
cp $p.tar.gz tmpp.tar.gz
gunzip -n tmpp.tar.gz
tar -xvf tmpp.tar
rm tmpp.tar
cd $p && export CPPFLAGS="${wCPPFLAGS}" && ./configure --disable-shared && ${MAKE}
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
${zlib}:
cp $z.tar.gz tmpz.tar.gz
gunzip -n tmpz.tar.gz
tar -xvf tmpz.tar
rm tmpz.tar
cd $z && ./configure && ${MAKE}
${glib}: ${jlib} ${plib} ${zlib}
cd $g && export CPPFLAGS="${wCPPFLAGS}" && ${MAKE} -f makefile_all_libs_new
${nlib}:
cp netcdf.tar.gz tmpn.tar.gz
gunzip -n tmpn.tar.gz
tar -xvf tmpn.tar
rm tmpn.tar
cd $n && ./configure --enable-c-only && ${MAKE} check
${prog}: $w/wgrib2.c $w/*.c $w/*.h ${glib} ${jlib} ${nlib} ${zlib} ${plib}
cd $w && export LDFLAGS="${wLDFLAGS}" && export CPPFLAGS="${wCPPFLAGS}" && export DEFS="${DEFS}" && ${MAKE} -f makefile_all_libs_new
clean:
cd $w && ${MAKE} clean
cd $g && touch junk.a junk.o && rm *.o *.a
rm -rf $n
rm -rf $j
rm -rf $p
rm -rf $z