LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-02-2005, 03:53 AM   #1
deveshs
LQ Newbie
 
Registered: Mar 2005
Location: Pune India
Distribution: FC3, RH9
Posts: 12

Rep: Reputation: 0
Makefile


Hi all I am trying to write a Makefile to compile my driver code and install the devices also my scriot is as follows.....
'contents of Makefile'

install:
@echo "********* Installing the $(TARGET) Module *********"
for MINOR_NUM in 0 16 32 48 64 80 ; do \
if [ -e $(DEVICE)$(MINOR_NUM) ]; then \
echo "Device $(DEVICE)$(MINOR_NUM) already exists"; \
else \
mknod $(DEVICE)$(MINOR_NUM) c $(MAJOR_NUM) $(MINOR_NUM); \
chmod 664 $(DEVICE)$(MINOR_NUM); \
fi; \
MINOR_NUM=$( ($MINOR_NUM+16) ); \
@echo $(MINOR_NUM); \
done

But in this script value of MINOR_NUM always remains 0 and I want it to cahnge each time it gose to the starting of the loop....
Is it the correct way to do this in a makefile If not then how I can do that..??
plz help me out
 
Old 05-02-2005, 04:47 AM   #2
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
Use $(DEVICE)$$MINOR_NUM instead, and do not use the @ prefix in shell continuation lines, unless you have a shell command whose name is "@echo", which I doubt ...
 
Old 05-02-2005, 10:36 AM   #3
deveshs
LQ Newbie
 
Registered: Mar 2005
Location: Pune India
Distribution: FC3, RH9
Posts: 12

Original Poster
Rep: Reputation: 0
Hi I tried the solution whcih u told but still that is not working ..my fundamental question is.....How Can I put for loop in a makefile ? please tell me.
I my code even this is not working
install:
@echo "********* Installing the $(TARGET) Module *********"
for VAR in 0 16 32 48 64 80 ; do \
echo $(VAR); \
done
echo "Calling insmod"
The code is supposed to print 0 16 32 48 64 80 but it is printing only 0 if previously initialized with 0 otherwise prints space character instead. But loop itrates 6 times......what should I do to get proprer output?
 
Old 05-02-2005, 11:14 AM   #4
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
Hmm, read again, the solution I suggested is working.

You are confusing Makefile variables and shell variables. $(something) is referring to a make variable, but for your inserted shell script, the correct way to have make ignoring the $ is by doubling it.
Also, with the piece of code you post, it is not printing "0" but an empty string.

Try:
Code:
install:
  @echo "********* Installing the $(TARGET) Module *********"
  for VAR in 0 16 32 48 64 80 ; do \
  echo $$VAR; \
  done
 
Old 05-02-2005, 11:34 PM   #5
deveshs
LQ Newbie
 
Registered: Mar 2005
Location: Pune India
Distribution: FC3, RH9
Posts: 12

Original Poster
Rep: Reputation: 0
Cool

Thanx buddy It worked .......Can I get help from you on device driver programming? Or otherwise u may have some good buddy list who can help in this topic? Please tell me..thanx once again
bye
 
Old 05-03-2005, 01:15 AM   #6
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
Device driver programming, specially on Linux is clearly not my cup of tea, but no doubt you'll find help from someone else ...
 
  


Reply



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
How to modify makefile.in or makefile.am QiangWan Linux - Newbie 1 05-17-2005 11:07 AM
how to get (makefile -f makefile )output into the textview widget in Pygtk sailu_mvn Programming 3 02-28-2005 03:57 AM
@ in makefile m_a61 Linux - General 2 09-08-2004 07:09 AM
generate Makefile from Makefile.in without calling ./configure ? chris78 Programming 2 05-02-2004 12:23 PM
makefile pessanimahi Programming 6 09-17-2003 02:34 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:13 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration