makefile sh script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting makefile sh script
# 1  
Old 03-04-2005
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=(http://www.nco.ncep.noaa.gov/pmb/docs/grib2/] (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
# 2  
Old 03-04-2005
...

Smilie 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?
# 3  
Old 03-04-2005
Quote:
Usage: ar [emulation options] [-]{dmpqrstx}[abcfilNoPsSuvV] [member-name] [count]
do you see an 'X' in this usage?
# 4  
Old 03-04-2005
Too fast

http://publib.boulder.ibm.com/infoce...ixcmds1/ar.htm
I apologize. I do not have an IBM server (laughs) Smilie
By editing the default makefile, I find it.
So I will try to perform without -X64
# 5  
Old 03-11-2005
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 ? Smilie

Thank for helping me...

Last edited by Akeson Chihiro; 04-21-2005 at 06:04 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Help running a Makefile from within a .sh script?

Hi there! I am a undergraduate student and recently submitted an assignment for my coursework - however there was one function I could not get to work properly before the due date. Although I don't need to complete this work anymore I would still like to in order to know what was going wrong. If... (11 Replies)
Discussion started by: cherryTango
11 Replies

2. Shell Programming and Scripting

Need help with a script to make makefile

How do we create a shell script that creates a makefile? what if we want to use the #include header files too? (2 Replies)
Discussion started by: sslokhan
2 Replies

3. Shell Programming and Scripting

using a Shell Script in a Makefile

Hello, I have a Makefile that converts wrl (vrml) files to html files... how can I use a shell script in that makefile which works on all html files after converting? The Shell Script have to find and replace a String in every createt html file. sorry I'm a Newbie, so I hope someone can... (0 Replies)
Discussion started by: Dan_78
0 Replies

4. Shell Programming and Scripting

Call makefile from shell script

I'm writing a VERY simple shell script. I need to call a makefile in a subdirectory. What's the command I need to use? ./dir/make and ./dir/makefile doesn't work. Thanks in advance (1 Reply)
Discussion started by: yamahabob
1 Replies

5. Homework & Coursework Questions

Help with Simple Multi-Level Makefile (Extremely New at Makefile)

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: Basically, the prompt is make a makefile with various sub makefiles in their respective subdirectories. All code... (1 Reply)
Discussion started by: Tatl
1 Replies

6. Shell Programming and Scripting

Multiple script lines into a Makefile

Hi All I am creating a makefile and I want to do a clean section. In the clean section I would like to check if the file exists and then delete it. I always have an error 'unexpected end of file' What's wrong in it? Thanks msntn firstCpp: first.cpp g++ -o first first.cpp clean: ... (1 Reply)
Discussion started by: manustone
1 Replies

7. UNIX for Advanced & Expert Users

Makefile problem - How to run module load in a Makefile

Hi, I'm trying to run the module load command in a Makefile and i'm getting the following error: make: module: command not found Why is this? Is there any way to run this command in a Makefile? NOTE: command - module load msjava/sunjdk/1.5.0 works fine outside of the Makefile (2 Replies)
Discussion started by: hernandinho
2 Replies

8. Shell Programming and Scripting

Shell script makefile

Is there a way to write a makefile for all the source files in a directory with a shell script? (2 Replies)
Discussion started by: zzhan
2 Replies

9. Shell Programming and Scripting

shell script in makefile

Hi, Can we execute a shell script by makefile. I mean we will write a shell script in a make file and it will be executed when we compile the C++ program using make file. (2 Replies)
Discussion started by: surjyap
2 Replies

10. Shell Programming and Scripting

embeding shell script in makefile

Hi I am new to shell scripting and makefile. I want a command's output in makefile to process further, can anyone plz suggest me a way ? I want ls -d *.dsm output in a variable and want to process it in makefile itself. It's urgent Thanks In advance (0 Replies)
Discussion started by: madhu12345
0 Replies
Login or Register to Ask a Question