LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   AIX (https://www.linuxquestions.org/questions/aix-43/)
-   -   Makefile problem (https://www.linuxquestions.org/questions/aix-43/makefile-problem-4175466320/)

surja 06-17-2013 06:07 AM

Makefile problem
 
Hi all,

I am facing the problem related to different Makefile in different directory. In linux environment $MAKE -C AGRIF FC="$CFT1" CPP="$CPP1" FFLAGS="$FFLAGS1" is working, but in AIX system $MAKE -C is not recognised flag. In AGRIF directory has multiple subdirectiory with.
When I have tried with cd AGRIF; make FC="$CFT1" CPP="$CPP1" FFLAGS="$FFLAGS1" option. Then the error is as

"Makefile", line 26: make: 1254-057 Shell command needs a leading tab.
"Makefile", line 109: make: 1254-057 Shell command needs a leading tab.
make: 1254-058 Fatal errors encountered -- cannot continue.

Please help to solve this problem.
Thanks in advance.
Surja

rtmistler 06-17-2013 09:40 AM

Makefile syntax requires a real TAB in lieu of a bunch of SPACES which match the same distance on the screen. This is a very common problem. Search for a string of SPACES and see if they fall in front of a command. Example:

Code:

%.o:        %.c
        $(GCC) $(CFLAGS) $(DFLAGS) -c $<

rebuild:
        make clean
        make myapp
        make install

myapp:        $(OBJS)
        $(GCC) $(OBJS) $(LFLAGS) -o myapp

install:
        cp -f myapp $(HOME)/myapp

clean:
        rm -f $(OBJS)
        rm -f $(HOME)/myapp

Before all those indented lines are TABS.
If ANY of them are spaces, there will be build problems.
This INCLUDES the gap between "myapp:" and "$(OBJS)", that must also be a TAB or there will be complaints.
Same for between "%.o:" and "%.c", that must also be a TAB

However do note that within each command such as "make clean", "make myapp", THOSE are spaces.

surja 06-19-2013 02:09 AM

Thanks for reply,
The Makefile I have used is as follows

#- Creation des elements relatifs a AGRIF (lib, config)
#---------------------------------------------------------------------
SHELL = /bin/sh
#---------------------------------------------------------------------

DIR_OBJS = AGRIF_OBJS
DIR_FILES = AGRIF_FILES
DIR_YOURFILES = AGRIF_YOURFILES

FILENAMES = modbc modcluster modinit modinitvars modinterp modinterpbasic \
modtypes modbcfunction modutil modcurgridfunctions \
modmask modsauv modupdate modmpp \
modupdatebasic modlinktomodel modarrays modflux modvariables

OBJS=$(addsuffix .o,$(addprefix $(DIR_OBJS)/,$(FILENAMES)))
FILES=$(addsuffix .F90,$(addprefix $(DIR_FILES)/,$(FILENAMES)))

all: conv libagrif.a
@echo
@echo ===================================================
@echo AGRIF is OK
@echo ===================================================
@echo

conv:
(cd LIB; $MAKE conv)
mv -f LIB/conv .

libagrif.a : prep_lib $(OBJS)
$(AR) -r $@ $(OBJS)
ranlib $@

prep_lib:
mkdir -p $(DIR_YOURFILES)
mkdir -p $(DIR_OBJS)

$(DIR_OBJS)/%.o : $(DIR_FILES)/%.F90
$(RM) $(DIR_YOURFILES)/$(*F).f90
$(CPP) $(CPPFLAGS) $(DIR_FILES)/$(*F).F90 > $(DIR_YOURFILES)/$(*F).f90
$(FC) $(FFLAGS) -I.. -c $(DIR_YOURFILES)/$(*F).f90 -o $(DIR_OBJS)/$(*F).o

$(DIR_OBJS)/modarrays.o: $(DIR_OBJS)/modtypes.o

$(DIR_OBJS)/modbc.o: $(DIR_OBJS)/modinterp.o

$(DIR_OBJS)/modbcfunction.o: $(DIR_OBJS)/modupdate.o \
$(DIR_OBJS)/modbc.o \
$(DIR_OBJS)/modinterp.o \
$(DIR_OBJS)/modtypes.o \
$(DIR_OBJS)/modflux.o

$(DIR_OBJS)/modcluster.o: $(DIR_OBJS)/modtypes.o \
$(DIR_OBJS)/modlinktomodel.o \
$(DIR_OBJS)/modsauv.o \
$(DIR_OBJS)/modinitvars.o \
$(DIR_OBJS)/modcurgridfunctions.o

$(DIR_OBJS)/modcurgridfunctions.o: $(DIR_OBJS)/modinit.o \
$(DIR_OBJS)/modtypes.o

$(DIR_OBJS)/modinit.o: $(DIR_OBJS)/modlinktomodel.o \
$(DIR_OBJS)/modtypes.o

$(DIR_OBJS)/modinitvars.o: $(DIR_OBJS)/modlinktomodel.o \
$(DIR_OBJS)/modtypes.o

$(DIR_OBJS)/modinterpbasic.o: $(DIR_OBJS)/modtypes.o

$(DIR_OBJS)/modinterp.o: $(DIR_OBJS)/modcurgridfunctions.o \
$(DIR_OBJS)/modmask.o \
$(DIR_OBJS)/modarrays.o \
$(DIR_OBJS)/modmpp.o \
$(DIR_OBJS)/modinterpbasic.o

$(DIR_OBJS)/modlinktomodel.o: $(DIR_OBJS)/modtypes.o

$(DIR_OBJS)/modmask.o: $(DIR_OBJS)/modtypes.o

$(DIR_OBJS)/modsauv.o: $(DIR_OBJS)/modarrays.o \
$(DIR_OBJS)/modlinktomodel.o \
$(DIR_OBJS)/modtypes.o $(DIR_OBJS)/modvariables.o

$(DIR_OBJS)/modupdatebasic.o: $(DIR_OBJS)/modtypes.o

$(DIR_OBJS)/modupdate.o: $(DIR_OBJS)/modmask.o \
$(DIR_OBJS)/modcurgridfunctions.o \
$(DIR_OBJS)/modarrays.o \
$(DIR_OBJS)/modmpp.o \
$(DIR_OBJS)/modupdatebasic.o

$(DIR_OBJS)/modutil.o: $(DIR_OBJS)/modtypes.o \
$(DIR_OBJS)/modcurgridfunctions.o \
$(DIR_OBJS)/modlinktomodel.o \
$(DIR_OBJS)/modsauv.o \
$(DIR_OBJS)/modcluster.o

$(DIR_OBJS)/modmpp.o: $(DIR_OBJS)/modtypes.o \
$(DIR_OBJS)/modarrays.o

.PHONY: doc

doc:
(cd doc ; doxygen Doxyfile )

clean: clean-conv
$(RM) $(OBJS) libagrif.a *.mod $(DIR_YOURFILES)/*

clean-all: clean
( cd LIB; $MAKE clean-all)

clean-conv:
(cd LIB; $MAKE clean-all)
$(RM) conv

I have changed the red mark flag.
The error is coming as

"Makefile", line 26: make: 1254-057 Shell command needs a leading tab.
"Makefile", line 109: make: 1254-057 Shell command needs a leading tab.
"Makefile", line 112: make: 1254-057 Shell command needs a leading tab.
"Makefile", line 113: make: 1254-057 Shell command needs a leading tab.
make: 1254-058 Fatal errors encountered -- cannot continue.
mv: 0653-401 Cannot rename AGRIF/conv to ROMSFILES/./conv:
A file or directory in the path name does not exist.
make: 1254-004 The error code from the last command is 127

Please help.
Surja

jpollard 06-19-2013 03:59 AM

You need to put the Makefile in code blocks so that indentation would not be lost.

It might also help to attach the file so that individual characters within that file that could be causing problems (such as using spaces instead of tabs) could be checked.

pan64 06-19-2013 04:56 AM

please use [code]your code comes here[/code] to keep original formatting (try to edit your post)
as it was reported, shell command lines need a leading tab, probably you used spaces or maybe your editor replaced them. You must start those lines with a tab.

rtmistler 06-19-2013 08:14 AM

I see:
Quote:

"Makefile", line 26: make: 1254-057 Shell command needs a leading tab.
"Makefile", line 109: make: 1254-057 Shell command needs a leading tab.
"Makefile", line 112: make: 1254-057 Shell command needs a leading tab.
"Makefile", line 113: make: 1254-057 Shell command needs a leading tab.
make: 1254-058 Fatal errors encountered -- cannot continue.
That's pretty much definitive explanation what the problem is, especially when a bunch of people tell you what to look for. EDIT your Makefile and put in leading TAB characters, recommend you start with lines 26, 109, 112, and 113. Read my original recommendations about where TAB characters should be, and heed the notation that TAB is NOT 4, or 8 SPACES together, but an actual TAB.

Keep fixing it and running it until these particular errors are gone. If you find additional errors, then post those in code markers as jpollard and pan64 have mentioned.

surja 06-20-2013 05:38 AM

1 Attachment(s)
Thank you all,
The problem is solved using tab before starting line.
Now new problem is coming as

The Makefile is in attached file and in bellow
#- Creation des elements relatifs a AGRIF (lib, config)
#---------------------------------------------------------------------
SHELL = /bin/sh
#---------------------------------------------------------------------

DIR_OBJS = AGRIF_OBJS
DIR_FILES = AGRIF_FILES
DIR_YOURFILES = AGRIF_YOURFILES

FILENAMES = modbc modcluster modinit modinitvars modinterp modinterpbasic \
modtypes modbcfunction modutil modcurgridfunctions \
modmask modsauv modupdate modmpp \
modupdatebasic modlinktomodel modarrays modflux modvariables

OBJS=$(addsuffix .o,$(addprefix $(DIR_OBJS)/,$(FILENAMES)))
FILES=$(addsuffix .F90,$(addprefix $(DIR_FILES)/,$(FILENAMES)))

all: conv libagrif.a
@echo
@echo ===================================================
@echo AGRIF is OK
@echo ===================================================
@echo

conv:
( cd LIB; make conv)
mv -f LIB/conv .

libagrif.a : prep_lib $(OBJS)
$(AR) -r $@ $(OBJS)
ranlib $@

prep_lib:
mkdir -p $(DIR_YOURFILES)
mkdir -p $(DIR_OBJS)

$(DIR_OBJS)/%.o : $(DIR_FILES)/%.F90
$(RM) $(DIR_YOURFILES)/$(*F).f90
$(CPP) $(CPPFLAGS) $(DIR_FILES)/$(*F).F90 > $(DIR_YOURFILES)/$(*F).f90
$(FC) $(FFLAGS) -I.. -c $(DIR_YOURFILES)/$(*F).f90 -o $(DIR_OBJS)/$(*F).o

$(DIR_OBJS)/modarrays.o: $(DIR_OBJS)/modtypes.o

$(DIR_OBJS)/modbc.o: $(DIR_OBJS)/modinterp.o

$(DIR_OBJS)/modbcfunction.o: $(DIR_OBJS)/modupdate.o \
$(DIR_OBJS)/modbc.o \
$(DIR_OBJS)/modinterp.o \
$(DIR_OBJS)/modtypes.o \
$(DIR_OBJS)/modflux.o

$(DIR_OBJS)/modcluster.o: $(DIR_OBJS)/modtypes.o \
$(DIR_OBJS)/modlinktomodel.o \
$(DIR_OBJS)/modsauv.o \
$(DIR_OBJS)/modinitvars.o \
$(DIR_OBJS)/modcurgridfunctions.o

$(DIR_OBJS)/modcurgridfunctions.o: $(DIR_OBJS)/modinit.o \
$(DIR_OBJS)/modtypes.o

$(DIR_OBJS)/modinit.o: $(DIR_OBJS)/modlinktomodel.o \
$(DIR_OBJS)/modtypes.o

$(DIR_OBJS)/modinitvars.o: $(DIR_OBJS)/modlinktomodel.o \
$(DIR_OBJS)/modtypes.o

$(DIR_OBJS)/modinterpbasic.o: $(DIR_OBJS)/modtypes.o

$(DIR_OBJS)/modinterp.o: $(DIR_OBJS)/modcurgridfunctions.o \
$(DIR_OBJS)/modmask.o \
$(DIR_OBJS)/modarrays.o \
$(DIR_OBJS)/modmpp.o \
$(DIR_OBJS)/modinterpbasic.o

$(DIR_OBJS)/modlinktomodel.o: $(DIR_OBJS)/modtypes.o

$(DIR_OBJS)/modmask.o: $(DIR_OBJS)/modtypes.o

$(DIR_OBJS)/modsauv.o: $(DIR_OBJS)/modarrays.o \
$(DIR_OBJS)/modlinktomodel.o \
$(DIR_OBJS)/modtypes.o $(DIR_OBJS)/modvariables.o

$(DIR_OBJS)/modupdatebasic.o: $(DIR_OBJS)/modtypes.o

$(DIR_OBJS)/modupdate.o: $(DIR_OBJS)/modmask.o \
$(DIR_OBJS)/modcurgridfunctions.o \
$(DIR_OBJS)/modarrays.o \
$(DIR_OBJS)/modmpp.o \
$(DIR_OBJS)/modupdatebasic.o

$(DIR_OBJS)/modutil.o: $(DIR_OBJS)/modtypes.o \
$(DIR_OBJS)/modcurgridfunctions.o \
$(DIR_OBJS)/modlinktomodel.o \
$(DIR_OBJS)/modsauv.o \
$(DIR_OBJS)/modcluster.o

$(DIR_OBJS)/modmpp.o: $(DIR_OBJS)/modtypes.o \
$(DIR_OBJS)/modarrays.o

.PHONY: doc

doc:
(cd doc ; doxygen Doxyfile )

clean: clean-conv
$(RM) $(OBJS) libagrif.a *.mod $(DIR_YOURFILES)/*

clean-all: clean
( cd LIB ; make clean-all)

clean-conv:
( cd LIB ; make clean-all)
$(RM) conv


in AGRIF directory has the following subdirectory
AGRIF_FILES/ LIB/ Makefile* doc/

the Makefile is in attached file.
in AGRIF_FILES/ has following scripts.

modarrays.F90* modflux.F90* modlinktomodel.F90* modupdate.F90*
modbc.F90* modinit.F90* modmask.F90* modupdatebasic.F90*
modbcfunction.F90* modinitvars.F90* modmpp.F90* modutil.F90*
modcluster.F90* modinterp.F90* modsauv.F90* modvariables.F90*
modcurgridfunctions.F90* modinterpbasic.F90* modtypes.F90*

LIB derictory has following 'C' program scripts

DiversListe.c* WorkWithAllocatelist.c* WriteInFile.c*
Makefile* WorkWithParameterlist.c* Writedeclarations.c*
SubLoopCreation.c* WorkWithglobliste.c* decl.h*
UtilAgrif.c* WorkWithlistdatavariable.c* dependfile.c*
UtilCharacter.c* WorkWithlistmoduleinfile.c* fortran.c*
UtilFile.c* WorkWithlistofcoupled.c* main.c*
UtilFortran.c* WorkWithlistofmodulebysubroutine.c* run*
UtilListe.c* WorkWithlistvarindoloop.c* toamr.c*
UtilNotGridDep.c* WorkWithvarofsubroutineliste.c*

I think the red coloured line part is not working. After working LIB directory it leaving Makefile.
The detail error is as
( cd LIB; make conv)
cc -O -c main.c
cc -O -c WriteInFile.c
cc -O -c toamr.c
cc -O -c fortran.c
1500-030: (I) INFORMATION: fortran_lex: Additional optimization may be attained by recompiling and specifying MAXMEM option with a value greater than 8192.
cc -O -c dependfile.c
cc -O -c SubLoopCreation.c
cc -O -c WorkWithlistvarindoloop.c
cc -O -c WorkWithvarofsubroutineliste.c
cc -O -c WorkWithParameterlist.c
cc -O -c Writedeclarations.c
cc -O -c WorkWithglobliste.c
cc -O -c UtilFortran.c
cc -O -c UtilNotGridDep.c
cc -O -c WorkWithlistdatavariable.c
cc -O -c DiversListe.c
cc -O -c UtilAgrif.c
cc -O -c WorkWithAllocatelist.c
cc -O -c UtilCharacter.c
cc -O -c UtilListe.c
cc -O -c UtilFile.c
cc -O -c WorkWithlistofmodulebysubroutine.c
cc -O -c WorkWithlistmoduleinfile.c
cc -O -c WorkWithlistofcoupled.c
cc -O main.o WriteInFile.o toamr.o fortran.o dependfile.o SubLoopCreation.o WorkWithlistvarindoloop.o WorkWithvarofsubroutineliste.o WorkWithParameterlist.o Writedeclarations.o WorkWithglobliste.o UtilFortran.o UtilNotGridDep.o WorkWithlistdatavariable.o DiversListe.o UtilAgrif.o WorkWithAllocatelist.o UtilCharacter.o UtilListe.o UtilFile.o WorkWithlistofmodulebysubroutine.o "Lime"]WorkWithlistmoduleinfile.o WorkWithlistofcoupled.o -o conv
mv -f LIB/conv .
mkdir -p AGRIF_YOURFILES
mkdir -p AGRIF_OBJS
ar -r libagrif.a
ar: Creating an archive file libagrif.a.
ranlib libagrif.a

===================================================
AGRIF is OK
==================================================
= LEAVING Makefile
/lib/cpp -P -I/usr/local/include -IROMSFILES/AGRIF_INC main.F | ./mpc > ROMSFILES/main.F
(cd ROMSFILES ; ./conv amr.scrum -rm -comdirin ./ -comdirout AGRIF_MODELFILES/. -convfile main.F)
syntax error line 115, file .//main.F motclef = |86400.,| curbuf = ||
/lib/cpp -P -I/usr/local/include -IROMSFILES/AGRIF_INC -IROMSFILES/AGRIF_INC ROMSFILES/AGRIF_MODELFILES/main.F > main_.f

Please help.
Thanks again.
Surja

pan64 06-20-2013 06:03 AM

please use code tags to keep formatting
have you checked the error message:
syntax error line 115, file .//main.F motclef

surja 06-20-2013 07:21 AM

Thank you for reply,
You are suggesting me in main.F 1n 115 line has syntax error, but I have checked the code there is no error. I think it is not compiling *.F90 file. So the problem is coming.

NevemTeve 06-20-2013 08:29 AM

You might be smarter than the compiler, but it is more stubborn than you... Perhaps you should quote the line in question.
PS: the problem has nothing to do with Makefile
PS2: Please use [code] and [/code] tags, can't you?

surja 06-22-2013 04:31 AM

Hi NevemTeve,
I don't understand your answer.
Can you tell in-detail, or give reference.
Thanks for reply.
I am waiting for reply.
Surja.

NevemTeve 06-22-2013 09:29 AM

1. quote the line in question (main.F line 115)
2. the problem has nothing to do with Makefile
3. Please use [code] and [/code] tags
Which of these three sentences is problematic?

surja 06-23-2013 02:31 AM

The 115 no line in main.F is
do tile=0,NSUB_X*NSUB_E-1
I have used Makefile in [code].

NevemTeve 06-23-2013 03:27 AM

Are NSUB_X and NSUB_E defined at this point?
What command did you use to compile?
(You don't have to use [code] tag in your Makefile; you have to use in this forum, when you quote source code. See #2 in this topic.)

jpollard 06-23-2013 06:05 AM

You also need to specify which fortran compiler you are using.


All times are GMT -5. The time now is 02:54 PM.