LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Makefile add text to variable in rule (https://www.linuxquestions.org/questions/programming-9/makefile-add-text-to-variable-in-rule-4175422634/)

dolle39 08-17-2012 11:15 AM

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!

NevemTeve 08-17-2012 01:13 PM

Code:

bin_link: OBJS += test.o
bin_link: $(OBJS) $(WHATEVERLIB1) $(WHATEVERLIB2)
        echo "Linking"
        $(LD) $(LDFLIB) -o $@ $^

PS: "$(LDFLIB)" should be "$(LDFLAGS)" methinks.


All times are GMT -5. The time now is 04:03 AM.