makefile sh script

Hello World ! ! !

I need libraries to use grib files. I only know the C language at the moment and I am working at the University under Red Hat 9.0. I downloaded the g2clib library [url=\(GRIB2 use at NCEP] (the best that I found) but I did not success to run the makefile. Here is the original file. I modified some options and paths.

=======

SHELL=/bin/sh

# If you want to enable support for PNG or JPEG2000 encoding/decoding,
# you must specify -DUSE_PNG and/or -DUSE_JPEG2000 in the DEFS variable
# for the C pre-processor
# -DUSE_PNG requires libpng.a and libz.a
# ( and png.h pngconf.h zconf.h zlib.h include files).
# -DUSE_JPEG2000 requires libjasper.a
# ( and all the jasper/*.h include files).
#
# In addition, INC must include all directories where the above
# mentioned include files can be found.
DEFS=
INC=/home/lavigne/waves/g2lib/g2clib-1.0.2

#
# This "C" source code contains many uses of the C++
# comment style "//". Please make sure you include the
# appropriate compiler flag to allow the use of "//" comment indicators.
#
#CFLAGS=-q64 -O3 -qarch=auto -qcpluscmt $(INC) $(DEFS)
CFLAGS= $(INC)

CC=cc
LIB=libgrib2c.a
ARFLAGS=-X64

all: $(LIB)

$(LIB)(gridtemplates.o): gridtemplates.h

$(LIB)(pdstemplates.o): pdstemplates.h

$(LIB)(drstemplates.o): drstemplates.h

$(LIB): $(LIB)(gridtemplates.o) \
$(LIB)(drstemplates.o) \
$(LIB)(pdstemplates.o) \
$(LIB)(gbits.o) \
$(LIB)(g2_unpack1.o) \
$(LIB)(g2_unpack2.o) \
$(LIB)(g2_unpack3.o) \
$(LIB)(g2_unpack4.o) \
$(LIB)(g2_unpack5.o) \
$(LIB)(g2_unpack6.o) \
$(LIB)(g2_unpack7.o) \
$(LIB)(g2_free.o) \
$(LIB)(g2_info.o) \
$(LIB)(g2_getfld.o) \
$(LIB)(simunpack.o) \
$(LIB)(comunpack.o) \
$(LIB)(pack_gp.o) \
$(LIB)(reduce.o) \
$(LIB)(specpack.o) \
$(LIB)(specunpack.o) \
$(LIB)(rdieee.o) \
$(LIB)(mkieee.o) \
$(LIB)(int_power.o) \
$(LIB)(simpack.o) \
$(LIB)(compack.o) \
$(LIB)(cmplxpack.o) \
$(LIB)(misspack.o) \
$(LIB)(jpcpack.o) \
$(LIB)(jpcunpack.o) \
$(LIB)(pngpack.o) \
$(LIB)(pngunpack.o) \
$(LIB)(dec_jpeg2000.o) \
$(LIB)(enc_jpeg2000.o) \
$(LIB)(dec_png.o) \
$(LIB)(enc_png.o) \
$(LIB)(g2_create.o) \
$(LIB)(g2_addlocal.o) \
$(LIB)(g2_addgrid.o) \
$(LIB)(g2_addfield.o) \
$(LIB)(g2_gribend.o) \
$(LIB)(getdim.o) \
$(LIB)(g2_miss.o) \
$(LIB)(getpoly.o) \
$(LIB)(seekgb.o)
# $(LIB)(getfield.o) \
# $(LIB)(gettemplates.o) \
# $(LIB)(getlocal.o) \
# $(LIB)(gribinfo.o) \
# $(LIB)(ixgb2.o) \
# $(LIB)(getg2i.o) \
# $(LIB)(getg2ir.o) \
# $(LIB)(getgb2s.o) \
# $(LIB)(getgb2r.o) \
# $(LIB)(getgb2l.o) \
# $(LIB)(getgb2.o) \
# $(LIB)(putgb2.o) \
# $(LIB)(params.o)

.c.a:
$(CC) -c $(CFLAGS) $<
ar $(ARFLAGS) -ruv $@ $.o
rm -f $
.o

Error :
./modified_makefile2: line 1: INC: command not found
./modified_makefile2: line 1: LIB: command not found
./modified_makefile2: line 28: all:: command not found
./modified_makefile2: line 30: syntax error near unexpected token `gridtemplates.o'
./modified_makefile2: line 30: `$(LIB)(gridtemplates.o): gridtemplates.h'

=======

So I tried to modify it with my little Shell Script knowledge :

#!/bin/csh

set INC=/home/lavigne/waves/g2lib/g2clib-1.0.2
set CFLAGS=$(INC)
set CC=cc
set LIBRARY=libgrib2c.a
set ARFLAGS=-X64

all: $(LIBRARY)

$(LIBRARY)(gridtemplates.o): gridtemplates.h

$(LIBRARY)(pdstemplates.o): pdstemplates.h

$(LIBRARY)(drstemplates.o): drstemplates.h

$(LIBRARY): $(LIBRARY)(gridtemplates.o) \
$(LIBRARY)(drstemplates.o) \
$(LIBRARY)(pdstemplates.o) \
$(LIBRARY)(gbits.o) \
$(LIBRARY)(g2_unpack1.o) \
$(LIBRARY)(g2_unpack2.o) \
$(LIBRARY)(g2_unpack3.o) \
$(LIBRARY)(g2_unpack4.o) \
$(LIBRARY)(g2_unpack5.o) \
$(LIBRARY)(g2_unpack6.o) \
$(LIBRARY)(g2_unpack7.o) \
$(LIBRARY)(g2_free.o) \
$(LIBRARY)(g2_info.o) \
$(LIBRARY)(g2_getfld.o) \
$(LIBRARY)(simunpack.o) \
$(LIBRARY)(comunpack.o) \
$(LIBRARY)(pack_gp.o) \
$(LIBRARY)(reduce.o) \
$(LIBRARY)(specpack.o) \
$(LIBRARY)(specunpack.o) \
$(LIBRARY)(rdieee.o) \
$(LIBRARY)(mkieee.o) \
$(LIBRARY)(int_power.o) \
$(LIBRARY)(simpack.o) \
$(LIBRARY)(compack.o) \
$(LIBRARY)(cmplxpack.o) \
$(LIBRARY)(misspack.o) \
$(LIBRARY)(jpcpack.o) \
$(LIBRARY)(jpcunpack.o) \
$(LIBRARY)(pngpack.o) \
$(LIBRARY)(pngunpack.o) \
$(LIBRARY)(dec_jpeg2000.o) \
$(LIBRARY)(enc_jpeg2000.o) \
$(LIBRARY)(dec_png.o) \
$(LIBRARY)(enc_png.o) \
$(LIBRARY)(g2_create.o) \
$(LIBRARY)(g2_addlocal.o) \
$(LIBRARY)(g2_addgrid.o) \
$(LIBRARY)(g2_addfield.o) \
$(LIBRARY)(g2_gribend.o) \
$(LIBRARY)(getdim.o) \
$(LIBRARY)(g2_miss.o) \
$(LIBRARY)(getpoly.o) \
$(LIBRARY)(seekgb.o)
# $(LIBRARY)(getfield.o) \
# $(LIBRARY)(gettemplates.o) \
# $(LIBRARY)(getlocal.o) \
# $(LIBRARY)(gribinfo.o) \
# $(LIBRARY)(ixgb2.o) \
# $(LIBRARY)(getg2i.o) \
# $(LIBRARY)(getg2ir.o) \
# $(LIBRARY)(getgb2s.o) \
# $(LIBRARY)(getgb2r.o) \
# $(LIBRARY)(getgb2l.o) \
# $(LIBRARY)(getgb2.o) \
# $(LIBRARY)(putgb2.o) \
# $(LIBRARY)(params.o)

.c.a:
$(CC) -c $(CFLAGS) $<
ar $(ARFLAGS) -ruv $@ $.o
rm -f $
.o

Error :
./modified_makefile
Illegal variable name.

=======

Is anyone can advise me for debugging this?
Thanks

===========================================
// Akeson Chihiro Conspiracy
// Some exist through what they do...
// We exist through what we are

:mad: I was told to tape make in the correct directory to execute the makefile. I use Shell Script so often that I forget my little knowledges. I debug the script except the following error :

================================
Answer by the terminal after the prompt :

cc -c /home/lavigne/waves/g2lib/g2clib-1.0.2/gridtemplates.c
ar -X64 -ruv libgrib2c.a gridtemplates.o
ar: illegal option -- X
Usage: ar [emulation options] [-]{dmpqrstx}[abcfilNoPsSuvV] [member-name] [count] archive-file file...
ar -M [<mri-script]
commands:
d - delete file(s) from the archive
m[ab] - move file(s) in the archive
p - print file(s) found in the archive
q[f] - quick append file(s) to the archive
r[ab][f] [u]- replace existing or insert new file(s) into the archive
t - display contents of archive
x[o] - extract file(s) from the archive
command specific modifiers:
[a] - put file(s) after [member-name]
[b]- put file(s) before [member-name] (same as [i])
[N] - use instance [count] of name
[f] - truncate inserted file names
[P] - use full path names when matching
[o] - preserve original dates
[u]- only replace files that are newer than current archive contents generic modifiers:
[c] - do not warn if the library had to be created
[s]- create an archive index (cf. ranlib)
[S]- do not build a symbol table
[v] - be verbose
[V] - display the version number
emulation options:
No emulation specific options
ar: supported targets: elf32-i386 a.out-i386-linux efi-app-ia32 elf32-little elf32-big srec symbolsrec tekhex binary ihex trad-core
make: *** [libgrib2c.a(gridtemplates.o)] Error 1

=======================

So what is going on? I do not understand. Default the ar command accepts the -X option, does not it?

do you see an 'X' in this usage?

I apologize. I do not have an IBM server (laughs) :stuck_out_tongue:
By editing the default makefile, I find it.
So I will try to perform without -X64

I success by deleting the -X64 option. Otherwise man ar yields :
NAME
ar - create, modify, and extract from archives

SYNOPSIS
ar [-X32_64] [-]p[mod [relpos] [count]] archive [member...]

Does anyone know a good faq or informations about the libgrib2c.a ? :frowning:

Thank for helping me...