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.
This seems to work when using older version of make but doesn't seem to work for newer versions. Eg make version 3.81-3 is fine with the above but 3.81-7 is not fine with the above.
The problem appears to be the "if" statement. It doesn't get executed by the shell. If I remove the if statement then it works (i.e. HELLO is printed)
Does anybody know why newer make doesn't work with the above.
Please note, this worked before. It is not a question of if I have a tab in the right spot, it is a question of why newer make does not pass the 'if' statement on to the shell.
Just a stupid question: are you using the same shell as before? As you probably know, the if-syntax is very shell specific, though. What kind of error message do you get?
Quote:
Originally Posted by endfx
This seems to work when using older version of make but doesn't seem to work for newer versions. Eg make version 3.81-3 is fine with the above but 3.81-7 is not fine with the above.
Here's what I would probably do: after checking the shell, I would test the version 3.81-4, 3.81-5 and 3.81-6 and check if you discovered a regression in the code. Then I would possibly post the question on the GNU make mailing list (or check the bug report system of GNU make).
But posting your error message here could already help us to give you more hints ...
Just a stupid question: are you using the same shell as before? As you probably know, the if-syntax is very shell specific, though. What kind of error message do you get?
I'm not using the same shell version. Bash 3.2-0 is the old working one and 4.1-2 is the new non working version.
When I copy and paste the "if ..." code from the makefile directly into a shell, it works. So I assumed the problem was not with the shell, though I could still be wrong about this.
Quote:
Originally Posted by ForzaItalia2006
Here's what I would probably do: after checking the shell, I would test the version 3.81-4, 3.81-5 and 3.81-6 and check if you discovered a regression in the code. Then I would possibly post the question on the GNU make mailing list (or check the bug report system of GNU make).
But posting your error message here could already help us to give you more hints ...
I hope that helps,
Andi
I'm not getting an error, it's just printing out the command:
Code:
make all
if [ condition ]; then echo "HELLO"; fi
and continues on.
Good idea about trying the different versions. I tried the older (working) make on my newer system and it doesn't work, so it looks like it's something other than make. Frustrating ...
My default shell when running under Ubuntu is bash; however that is not the shell that is used when executing a Makefile. I believe dash is used. To force a particular shell to be used within the Makefile, indicate your preference using the SHELL variable.
For example:
Code:
SHELL = /bin/bash
all:
@ echo $(SHELL)
Try this Makefile with and without the SHELL environment variable.
Thanks dwhitney67! That was it.
It was using dash. When I switched it to bash the makefile started working.
I forgot ubuntu points /bin/sh at dash. I change /bin/sh to point to bash on my systems because dash screws up a lot of shell scripts. Heh, I still remember the controversy when Ubuntu made this switch.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.