LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-12-2009, 04:55 PM   #1
NightHorse
Member
 
Registered: Jun 2009
Location: Egypt
Distribution: Ubuntu 10.04
Posts: 117

Rep: Reputation: 16
[Makefile] passing parameters to gcc


Hi all,

I need to pass some parameters to gcc typically --march=i486. Is it possible if i compile some program using configure/make to pass that parameter??

I have been searching and found CFLAGS but what if the makefile doesn't make use of that variable??
 
Old 06-12-2009, 05:21 PM   #2
nuwen52
Member
 
Registered: Feb 2009
Distribution: Debian, CentOS 5, Gentoo, FreeBSD, Fedora, Mint, Slackware64
Posts: 208

Rep: Reputation: 46
I think you can just add the CFLAGS variable into the Makefile, like this:

Code:
CFLAGS+= -O2

file:
    ${CC} ${CFLAGS} file.c -o file
Then, if you assign cflags in the environment, it will append the -O2 (for example) to whatever the environment defines. I've done it with some pretty simple makefiles. CFLAGS is just an environment variable, so just add it into the compile line(s).

Last edited by nuwen52; 06-12-2009 at 05:22 PM.
 
Old 06-13-2009, 02:58 AM   #3
NightHorse
Member
 
Registered: Jun 2009
Location: Egypt
Distribution: Ubuntu 10.04
Posts: 117

Original Poster
Rep: Reputation: 16
The problem is that I don't just need to add flags to simple makefile. I have a makefile generated by configure for ready made driver. And it's so complicated for me. I can't figure out who goes where. but i only need to pass that argument for every compilation line. Which I don't even find. :s
 
Old 06-15-2009, 09:14 AM   #4
nuwen52
Member
 
Registered: Feb 2009
Distribution: Debian, CentOS 5, Gentoo, FreeBSD, Fedora, Mint, Slackware64
Posts: 208

Rep: Reputation: 46
I haven't tried that myself, but there should be a Makefile.in which configure uses as a template for the Makefile. In that file, there should be a line which starts with "COMPILE = $(CC)". I've checked 2 makefiles on separate programs and they both have it. You should be able to add $(CFLAGS) to the end of that line. There is a "proper" way, but this might work.
 
Old 06-16-2009, 06:08 AM   #5
NightHorse
Member
 
Registered: Jun 2009
Location: Egypt
Distribution: Ubuntu 10.04
Posts: 117

Original Poster
Rep: Reputation: 16
Well. I have searched for Makefile.in but didn't find any :'(

I think it depends on the one implementing the Makefile. They use whatever they like. For famous open source software they would be more standardized.
 
Old 06-16-2009, 06:30 AM   #6
jamescondron
Member
 
Registered: Jul 2007
Location: Scunthorpe, UK
Distribution: Ubuntu 8.10; Gentoo; Debian Lenny
Posts: 961

Rep: Reputation: 69
Makefiles are stamdardised, else the interpretter wouldn't be able to read them. grep your Makefile for CFLAGS. If it doesn't show a single response, then you're stuck, if it does, ass
Code:
CFLAGS += --march=i486
etc.
 
Old 06-16-2009, 07:22 AM   #7
NightHorse
Member
 
Registered: Jun 2009
Location: Egypt
Distribution: Ubuntu 10.04
Posts: 117

Original Poster
Rep: Reputation: 16
Well. I have done that. and seems it's working. But I still have a problem. I am trying to compile kernel module for i486sx processor with kernel 2.6.24

The development system is Ubuntu 8.04 with 2.6.16 kernel

After throwing the compiled module on the target I am getting this error:
Quote:
insmod: cannot insert '/vntwusb.ko': invalid module format
That's the output of dmesg
Quote:
vntwusb: version magic '2.6.24-16-generic SMP mod_unload 586 ' should be '2.6.24 mod_unload 486
So is it only a kernel version problem or does the 586 and 486 also means different architectures??

And if it's a kernel version problem. Is there a way to link to that specific kernel version??

Thanks all in advance. I will keep searching. And I will update here if i found anything. I am really stucked on this one cause we purchased the wifi module for the pc/104 and I need to get it working...
 
Old 06-16-2009, 07:23 AM   #8
NightHorse
Member
 
Registered: Jun 2009
Location: Egypt
Distribution: Ubuntu 10.04
Posts: 117

Original Poster
Rep: Reputation: 16
ahhh btw they weren't using the CFLAGS but found them using a different variable called EXTRA_CFLAGS and that's the one I have appended the -march=i486 to.

Just for later reference.
 
  


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
Passing parameters to a makefile. kerenLinuxForum Linux - Software 3 09-01-2008 09:24 AM
passing parameters in string in C shifter Programming 8 04-11-2008 10:01 AM
Passing module parameters to kernel scoban Slackware 3 12-26-2007 09:21 AM
need help passing parameters in C++ hedpe Programming 1 10-21-2007 11:58 AM
Passing parameters to PERL script paddyjoy Programming 3 03-07-2006 12:04 PM


All times are GMT -5. The time now is 02:35 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration