LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices

Reply
 
Search this Thread
Old 09-25-2006, 02:51 PM   #1
rem1986
LQ Newbie
 
Registered: Apr 2004
Location: Cuba
Distribution: Debian Sarge 3.1
Posts: 23

Rep: Reputation: 15
compiling error: unexpected token `fi'


Hi, I tried compiling my rtlinux kernel after I patched my 2.6.9 linux kernel and I got the following error:

<code>
rm -f .depend
make .depend
make[1]: Entering directory `/usr/src/rtlinux-3.2-rc1'
Kernel version 2.6.9rtlfree.rtl
/bin/sh: -c: line 3: syntax error near unexpected token `fi'
/bin/sh: -c: line 3: `fi'
make[1]: *** [.depend] Error 2
make[1]: Leaving directory `/usr/src/rtlinux-3.2-rc1'
make: *** [dep] Error 2
</code>

I've been researching and it says that this error is due to a missing ";" before a "then" clause, but I've no idea where to look for the mistake, or even if that's the problem causing it,

please advice !!!

thsnks
 
Old 09-26-2006, 12:19 PM   #2
weibullguy
ReliaFree Maintainer
 
Registered: Aug 2004
Location: Kalamazoo, Michigan
Distribution: Slackware-current, Cross Linux from Scratch, Gentoo
Posts: 2,745
Blog Entries: 1

Rep: Reputation: 224Reputation: 224Reputation: 224
I'm no expert, but I'll give it a go. In scripts, the if-then test construct is like one of these
Code:
if [test]; then
    do some stuff
fi

if [test]
then
    do some stuff
fi
The ";" is a command separator and sorta says "command #1 stops here and command #2 starts here". When make enters directory /usr/src/rtlinux-3.2-rc1 it finds a Makefile. In that Makefile is a function called .depend. Line 3 of that function is where make sees the error, but it is before that. Make is seeing the 'fi' statement that is supposed to be ending the if-then construct as command of its own which it is not.

Here's a snippet from a Makefile:
Code:
install-binaries: binaries
	@for i in $(LIB_INSTALL_DIR) $(BIN_INSTALL_DIR) ; \
	    do \
	    if [ ! -d $$i ] ; then \
		echo "Making directory $$i"; \
		mkdir -p $$i; \
		chmod 755 $$i; \
		else true; \
		fi; \
	    done;
When I take the red ';' out and run make install this is the error I get
Code:
/bin/sh -c: line 6: syntax error near unexpected token 'else'
/bin/sh -c: line 6: '   else true; \'
make: *** [install.binaries] Error 2
Look familiar? Configure (re)creates the makefile, so you could try configure again and see if that fixes the problem.
 
Old 09-26-2006, 06:49 PM   #3
rem1986
LQ Newbie
 
Registered: Apr 2004
Location: Cuba
Distribution: Debian Sarge 3.1
Posts: 23

Original Poster
Rep: Reputation: 15
still struggling !!

Thanks for your reply, I now understand a little more about the subject. I checked the .Makefile and found in the 3rd line an if then statement, I checked to make sure the ";" was there, and it was, so still I don't know what the problem might be. Here's the function .depend

Code:
.depend: scripts/mkdep
# dummy symlinks .config scripts/mkdep
        @echo Kernel version $(KERNELRELEASE)
        @if [ ! -f $(RTLINUX)/.config -o ! -f $(RTLINUX)/include/linux/version.h ]; then\
        echo You must do a make config and make dep in $(RTLINUX); \
        exit 1; \
        fi
        @mkdir -p modules
        for x in `find . -name Makefile`; do \
                F=`echo $$x|sed 's/Makefile$$//g'`; \
                (cd $$F; $$RTL/scripts/mkdep *.c *.h *.S > .depend 2>/dev/null); \
        done
        @rm -f .hdepend
        @find $(subst -I,,$(DEPINCLUDE)) -name SCCS -prune -or -follow -name \*.h ! -name modversions.h -print |xargs scripts/mkdep >> .hdepend
thanks again !
 
Old 09-26-2006, 07:15 PM   #4
weibullguy
ReliaFree Maintainer
 
Registered: Aug 2004
Location: Kalamazoo, Michigan
Distribution: Slackware-current, Cross Linux from Scratch, Gentoo
Posts: 2,745
Blog Entries: 1

Rep: Reputation: 224Reputation: 224Reputation: 224
This
Code:
@if
might be the problem. There's no opening if for the fi on line 3.
 
Old 09-26-2006, 08:49 PM   #5
rem1986
LQ Newbie
 
Registered: Apr 2004
Location: Cuba
Distribution: Debian Sarge 3.1
Posts: 23

Original Poster
Rep: Reputation: 15
still...

I think the "@" just hides the code from the shell, I tried it without the "@" and it just throws the code on to the screen, still the same error

[HTML]Kernel version 2.6.9rtlfree.rtl
if [ ! -f /usr/src/linux/.config -o ! -f /usr/src/linux/include/linux/version.h ]; then\
echo You must do a make config and make dep in /usr/src/linux; \
exit 1; \
fi
/bin/sh: -c: line 3: syntax error near unexpected token `fi'
/bin/sh: -c: line 3: `fi'
make[1]: *** [.depend] Error 2
make[1]: Leaving directory `/usr/src/rtlinux-3.2-rc1'
make: *** [dep] Error 2
[/HTML]

Last edited by rem1986; 09-26-2006 at 08:50 PM.
 
Old 09-27-2006, 08:56 AM   #6
weibullguy
ReliaFree Maintainer
 
Registered: Aug 2004
Location: Kalamazoo, Michigan
Distribution: Slackware-current, Cross Linux from Scratch, Gentoo
Posts: 2,745
Blog Entries: 1

Rep: Reputation: 224Reputation: 224Reputation: 224
I wouldn't have expected the if-then statement to be echoed to the screen without the @. Sorry, I think you've tapped the limits of my Makefile knowledge.
 
Old 02-08-2007, 09:23 AM   #7
koodoo
Member
 
Registered: Aug 2004
Location: a small village faraway in the mountains
Distribution: Fedora Core 1, Slackware 10.0 | 2.4.26 | custom 2.6.14.2, Slackware 10.2 | 11.0, Slackware64-13
Posts: 345

Rep: Reputation: 32
Hi Rem1986, Arow

I am experiencing the exact same error while compiling my rtlinux kernel after I patched my 2.6.9 linux kernel. Were you finally able to resolve that error?
I'd be highly grateful if you could help me...
Thanks in anticipation.

regards,
koodoo
 
Old 12-10-2007, 01:11 PM   #8
xprometeus
Member
 
Registered: Jul 2003
Distribution: Turbo Linux 10D
Posts: 39

Rep: Reputation: 15
/include/linux/version.h ]; then\ should be then \ (with space).
But after this rtlinux is still not possible to compile
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
syntax error near unexpected token `fi' Warmduvet Programming 21 10-08-2013 10:28 AM
error: unexpected token `newline' CarlosV Programming 4 05-17-2011 03:47 AM
syntax error for unexpected token `(' Steve Spurr Linux - Newbie 6 09-22-2006 08:19 AM
syntax error near unexpected token `else' josedias Programming 3 09-11-2006 07:09 PM
Trouble with Bash -- syntax error near unexpected token `fi' anamericanjoe Programming 5 05-19-2006 02:59 PM


All times are GMT -5. The time now is 11:07 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration