LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 03-03-2006, 03:33 AM   #1
jennifer29
LQ Newbie
 
Registered: Mar 2006
Posts: 3

Rep: Reputation: 0
ifdef not working in GNU make version 3.80


Code :-

all:
ifdef MYDIR
echo "defined"
endif

MYDIR is a variable tht is exported

output of make -f try :
ifdef MYDIR
make: ifdef: Command not found
make: *** [all] Error 127
Kindly suggest me the error
 
Old 03-03-2006, 03:42 AM   #2
Jaqui
Member
 
Registered: Jan 2006
Location: Vancouver BC
Distribution: LFS, SLak, Gentoo, Debian
Posts: 291

Rep: Reputation: 36
ifdef is not a make command, it is used as a macro in the compiler itself and is only used in the actual source code.
 
Old 03-03-2006, 03:46 AM   #3
jennifer29
LQ Newbie
 
Registered: Mar 2006
Posts: 3

Original Poster
Rep: Reputation: 0
but then how do i check whether a variable is set in a makefile??

but then how do i check whether a variable is set in a makefile??
 
Old 03-03-2006, 05:54 AM   #4
Jaqui
Member
 
Registered: Jan 2006
Location: Vancouver BC
Distribution: LFS, SLak, Gentoo, Debian
Posts: 291

Rep: Reputation: 36
make will parse command line options automatically.

variables in configuring the application during the compile are set in the configure script, like install-dir=$mydir

it sounds like you are trying to combine variable setting of configure with the compiler use of make.


the common install from source sequence is:

./configure [options]
make
su
make install
 
Old 12-06-2011, 01:18 PM   #5
AviManor
LQ Newbie
 
Registered: Dec 2011
Posts: 1

Rep: Reputation: Disabled
Smile Solution for jennifer29

The makefile needs to be in Unix format.
Run it through dos2unix
 
Old 12-19-2011, 05:40 PM   #6
perfect_circle
Senior Member
 
Registered: Oct 2004
Location: Athens, Greece
Distribution: Slackware, arch
Posts: 1,783

Rep: Reputation: 53
I don't know what exactly you are trying to do. Gnu make does support conditionals: http://www.gnu.org/s/hello/manual/ma...ditionals.html
but you don't put them in the target statement (`all' is a target). This is perfectly legal:
Code:
skalkoto@darkstar:~$ cat Makefile 
ifdef MYDIR
MSG="defined"
else
MSG="not defined"
endif

all:
        @echo $(MSG)
skalkoto@darkstar:~$ make 
not defined
skalkoto@darkstar:~$ make MYDIR=aaa
defined
skalkoto@darkstar:~$
 
  


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
Which GNU Make???? munichtexan Linux - Newbie 22 11-20-2005 10:37 AM
Need help installing gnu make 3.80.0 AljoshaNL Linux - Software 0 08-19-2005 05:16 AM
diff between GNU,GMT and WAUST time version izza_azhar Programming 2 01-24-2005 07:37 AM
How to do a make? GNU Krell steve65 Linux - Software 6 10-22-2002 11:42 AM
GNU make problems MacDaddy Linux - General 9 08-26-2001 03:09 PM

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

All times are GMT -5. The time now is 09:19 PM.

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