ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789
Rep:
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 ...
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?
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789
Rep:
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
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
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.