LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > General
User Name
Password
General This forum is for non-technical general discussion which can include both Linux and non-Linux topics. Have fun!

Notices


Reply
  Search this Thread
Old 07-27-2007, 05:22 PM   #1
imperialbeachdude
LQ Newbie
 
Registered: Jul 2007
Posts: 25

Rep: Reputation: 0
Problem with a makefile


I'm a newbie to Linux, but I have been programming for way too many years.

Anyway, question about makefiles. I'm running cygwin, trying to compile some source from another project. The makefile has a line it like this:

include $(MAKERULES)

I have an environment variable that looks like this:

MAKERULES = /home/foo/bar/rules

When I run make - I get an error message like this "/home/foo/bar/rules: No such file or directory"

however, if I do this:

cat $MAKERULES

I see the contents of the file. So what am I missing? Seems like make expanded the filename ok, so why does it say it does not exist? hmmm......
 
Old 07-28-2007, 04:07 AM   #2
gurl4sh25
Member
 
Registered: Apr 2006
Distribution: SuSE, RedHat, Fedora, CentOS, BSD
Posts: 115

Rep: Reputation: 15
Have you tried

include $MAKERULES

instead of

include $(MAKERULES)
 
Old 07-28-2007, 05:03 AM   #3
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Ubuntu 12.04, Antix19.3
Posts: 3,794

Rep: Reputation: 282Reputation: 282Reputation: 282
There is a dedicated programming forum on LinuxQuestions.

Just to remember for other questions.
 
Old 07-28-2007, 11:29 AM   #4
bgoodr
Member
 
Registered: Dec 2006
Location: Oregon
Distribution: RHEL[567] x86_64, Ubuntu 17.10 x86_64
Posts: 221

Rep: Reputation: 36
Quote:
Originally Posted by gurl4sh25
Have you tried

include $MAKERULES

instead of

include $(MAKERULES)
The syntax that includes the MAKERULES variable in open and close parentheses is correct syntax. imperialbeachdude said Cygwin: can you confirm which platform you are executing on, Windows or Linux?
 
Old 07-29-2007, 12:21 AM   #5
imperialbeachdude
LQ Newbie
 
Registered: Jul 2007
Posts: 25

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by bgoodr
The syntax that includes the MAKERULES variable in open and close parentheses is correct syntax. imperialbeachdude said Cygwin: can you confirm which platform you are executing on, Windows or Linux?
Running on Windows - thanks! Perhaps I have a permissions problem?
 
Old 07-29-2007, 12:54 AM   #6
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
There are two small things that I didn't see in your orginal post, but can be implied, so I thought I'd ask anyway.

When you assign a variable, don't have spaces around the "=" character.
MAKERULES=/home/foo/bar/rules

Also, did you export the MAKERULES variable?

export MAKERULES

Also double check that the /home/foo/bar/rules file does exist and that you can access it.

Last edited by jschiwal; 07-29-2007 at 12:56 AM.
 
Old 07-29-2007, 09:43 AM   #7
bgoodr
Member
 
Registered: Dec 2006
Location: Oregon
Distribution: RHEL[567] x86_64, Ubuntu 17.10 x86_64
Posts: 221

Rep: Reputation: 36
Hmmmm, one of the first things I would look for is in the original source for the project you are compiling. Does it have any file that defines MAKERULES already? Why would that project require you to have variables like that defined outside of its build environment? I would have expected that variable to be defined by some configuration script (such as one AutoConf would generate).

I agree with what ischiwal stated, but as for the spaces around the "=" character, it depends upon which language (Bourne shell or GNU Make) the variable is being defined in. The spaces would be significant to the Bourne shell syntax, but not to the GNU Make syntax which strips leading and trailing whitespace around both the equal sign and the value.

What is the command you typed to run make? And, into what window did you type it? In a DOS command window or in a Cygwin "terminal" window? This matters on Windows since you are also using Cygwin. On Windows you have a DOS command prompt window which parses command lines differently from the UNIX-like shell running inside the Cygwin terminal window.

As for accessing the /home/foo/bar/rules file, I can guess something about that path by inspection. The "/home" part of that path does not contain a Windows drive component such as "C:/", and so I am guessing that only the Cygwin shells will be able to parse that and know that it gets silently maps to some real Windows path. Therefore, I would expect you to need to use the Cygwin terminal if you are running the command manually. But then again, see above comment about why you would even need to do that.

Also, AFAIK, Cygwin provides (or did at one time provide) a utility command called cygpath. It converts paths from UNIX-like paths such as /home/bla/bla/bla into DOS syntax such as c:\cygwin\home\bla\bla, or a mixed mode (but unexceptable to anything other than Cygwin) syntax with forward slashes such as c:/cygwin/home/bla/bla. That might come in handy to debug how paths get mapped from UNIX-like paths to DOS drive-mounted paths.

Also verify that your HOME environment variable is set to in the Windows Control Panel as you expect it to be (or that Cygwin might expect it to be), and verify that the directory indicated contains files that Cygwin expects, such as .profile or .bashrc. IIRC, when I had upgrade from Cygwin a while back, it had problems with using the pre-existing HOME directory, and I had to use a HOME environment variable in the control panel.

This is a Linux forum, so you might want to track down any Cygwin-related forums on the web too.

bgoodr
 
Old 07-30-2007, 02:29 AM   #8
reddazz
LQ Guru
 
Registered: Nov 2003
Location: N. E. England
Distribution: Fedora, CentOS, Debian
Posts: 16,298

Rep: Reputation: 77
Moved: This thread is more suitable in the General forum and has been moved accordingly to help your thread/question get the exposure it deserves.
 
Old 07-30-2007, 11:52 AM   #9
imperialbeachdude
LQ Newbie
 
Registered: Jul 2007
Posts: 25

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by jschiwal
There are two small things that I didn't see in your orginal post, but can be implied, so I thought I'd ask anyway.

When you assign a variable, don't have spaces around the "=" character.
MAKERULES=/home/foo/bar/rules

Also, did you export the MAKERULES variable?

export MAKERULES

Also double check that the /home/foo/bar/rules file does exist and that you can access it.
Thanks for the ideas - I don't have spaces around the variable, and I did export it, and the file does exist. I know these are true because I can do "cat $MAKERULES" and I see the contents of the file.

Also - I'm running "make" within the cygwin terminal window, and the error message from make is "/home/foo/bar/rules:file not found", so I know make has correctly expanded the variable. I'm going to try adding the drive letter to see if that helps. That would tell me that "make" is less tolerant of paths than "cat" which works fine.

Thanks again!
 
Old 07-30-2007, 12:12 PM   #10
imperialbeachdude
LQ Newbie
 
Registered: Jul 2007
Posts: 25

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by bgoodr
As for accessing the /home/foo/bar/rules file, I can guess something about that path by inspection. The "/home" part of that path does not contain a Windows drive component such as "C:/", and so I am guessing that only the Cygwin shells will be able to parse that and know that it gets silently maps to some real Windows path. Therefore, I would expect you to need to use the Cygwin terminal if you are running the command manually. But then again, see above comment about why you would even need to do that.

Also, AFAIK, Cygwin provides (or did at one time provide) a utility command called cygpath. It converts paths from UNIX-like paths such as /home/bla/bla/bla into DOS syntax such as c:\cygwin\home\bla\bla, or a mixed mode (but unexceptable to anything other than Cygwin) syntax with forward slashes such as c:/cygwin/home/bla/bla. That might come in handy to debug how paths get mapped from UNIX-like paths to DOS drive-mounted paths.

Also verify that your HOME environment variable is set to in the Windows Control Panel as you expect it to be (or that Cygwin might expect it to be), and verify that the directory indicated contains files that Cygwin expects, such as .profile or .bashrc. IIRC, when I had upgrade from Cygwin a while back, it had problems with using the pre-existing HOME directory, and I had to use a HOME environment variable in the control panel.

This is a Linux forum, so you might want to track down any Cygwin-related forums on the web too.

bgoodr
Thanks for the info - it does look like the drive letter in cygwin is the problem. When I add the drive letter, I get further along in the make. I will look into the "home" path, and the cygpath, I think that's the right direction.

Thanks!
 
  


Reply

Tags
makefile, programming



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
makefile problem sancho1980 Linux - General 9 08-06-2007 08:22 AM
Makefile problem LuvMyKelly Linux - Newbie 2 12-09-2005 12:13 AM
how to get (makefile -f makefile )output into the textview widget in Pygtk sailu_mvn Programming 3 02-28-2005 03:57 AM
Another problem with Makefile lucs Slackware 3 02-14-2005 05:06 PM
generate Makefile from Makefile.in without calling ./configure ? chris78 Programming 2 05-02-2004 12:23 PM

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

All times are GMT -5. The time now is 11:20 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