LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
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 08-17-2012, 11:15 AM   #1
dolle39
LQ Newbie
 
Registered: Jun 2012
Posts: 4

Rep: Reputation: Disabled
Makefile add text to variable in rule


Hi!

I have a problem with a makefile. This is a very special kind of makefile and I just want to make a temporary solution.

When the Makefile shall link the program I want to include an additional file to a global variable called OBJS.

The lines look as follows:

bin_link: $(OBJS) $(WHATEVERLIB1) $(WHATEVERLIB2)
@echo "Linking"
@$(LD) $(LDFLIB) $(OBJS) $(LIBS) -o $(PROGRAM)
@echo "done"

So I would like to add a filename to OBJS before linking, such as test.o like this for example:
OBJS=$(OBJS) test.o

But I dont get it to work, how should I do this?

Really thankfull for answers!
 
Old 08-17-2012, 01:13 PM   #2
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,872
Blog Entries: 1

Rep: Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871
Code:
bin_link: OBJS += test.o
bin_link: $(OBJS) $(WHATEVERLIB1) $(WHATEVERLIB2)
        echo "Linking"
        $(LD) $(LDFLIB) -o $@ $^
PS: "$(LDFLIB)" should be "$(LDFLAGS)" methinks.

Last edited by NevemTeve; 08-18-2012 at 06:05 AM.
 
  


Reply



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
Multifile Rule definition in Makefile sahil.jammu Linux - Newbie 1 08-29-2010 07:45 AM
Makefile issue - how to prevent a rule running before 'make clean' rusty_turkey Programming 3 08-31-2008 11:00 PM
Is this makefile rule possible? markelo Programming 1 01-31-2007 08:26 AM
What is wrong with this simple rule in makefile? George2 Programming 6 05-03-2006 01:53 AM
Rule.mk and make.mk for makefile evenglist2005 Programming 1 09-21-2005 03:39 AM

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

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