[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Target Specific Variable questions

From: John Jamulla
Subject: Target Specific Variable questions
Date: Mon, 7 Jan 2002 17:31:56 -0500

I just recently decided to try using target specific variables and I
have a couple of questions:

Here's an excerpt (most of)of my makefile before questions:
--------------------  cut here ----------------------------
LIBNAME  := timer_check.a
OBJS     := clkcntr.o
CCFLAGS  := -g -O0 -n32 -mips4 -ansi
SYSLIBS  :=  -lc

EXEC := timer_check

all: $(OBJS) $(LIBNAME) $(EXEC)

opt : override CCFLAGS := -O3 -n32 -mips4 -ansi
opt : override EXEC := opt_timer_check
opt : all

n64 : override CCFLAGS := -O3 -64 -mips4 -ansi
n64 : override EXEC := opt64_timer_check
n64 : all

clkcntr.c : clkcntr.h

clkcntr.o : clkcntr.c
        cc $(CCFLAGS) $(DEFINES) $(INCLUDES) -c $< -o $@

timer_check.o : timer_check.cpp
        CC $(CCFLAGS) $(DEFINES) $(INCLUDES) -c $< -o $@

        ar -crv $@ $?

$(EXEC): timer_check.o  $(LIBNAME)
        @echo "inside rule for exec = $(EXEC)"
        CC $(CCFLAGS) $(DEFINES) $(INCLUDES) $< -o $(EXEC) \
            -L. $(LIBNAME) $(SYSLIBS)

---------------------- cut here --------------------

1) In the $(EXEC) target, in the CC command, I could NOT use the
        variable $@ correctly as I expected. I wanted the name of the target to
be 'opt64_timer_check'
        when trying to execute "make n64". I used an echo inside the rule (as
the first command), and the
        $(EXEC) variable was set to 'opt64_timer_check', but the $@ was still
        to 'timer_check'. Is this a bug or a feature? Sounds like a bug to me.

2) I tried to use the above makefile, and had a couple rules as follows:
%.o : %.c
        cc $(CCFLAGS) $(DEFINES) $(INCLUDES) -c $< -o $@

%.o : %.cpp
        cc $(CCFLAGS) $(DEFINES) $(INCLUDES) -c $< -o $@

Question: I think the above two rules are static pattern rules, s this

Using the above two targets and the rest of the above makefile, instead
specific rules for the .c and .cpp files, the target specific CCFLAGS
did NOT get used.
Is this a bug or a feature? If it does this on purpose, how can I get
this "feature"? I'd like to use the target specific variable assignments
especially in rules such as these.

I read a few sections of the make manual, and it seems the answer might
be fairly complex,
might have something to do with the order of these rules in the
makefile, or maybe I need
to tell make NOT to search implicit rules or something.

3) I can't figure out how to set multiple variables on a single line
target, something like:

specialbuild: CCFLAGS += -show  EXEC := specialbuild_forme

Either I have the wrong syntax, or you can't do this and need multiple
lines. Can someone
let me know?

I am using GNU make 3.79.1 on SGI IRIX 6.5.13m (compiled ourselves).

John D. Jamulla - Senior Engineer
Northrop Grumman Corporation
Electronic Systems
Amherst Systems
Buffalo N.Y. 14221, (716) 631-0088
address@hidden, or address@hidden

Attachment: John D. Jamulla.vcf
Description: Binary data

reply via email to

[Prev in Thread] Current Thread [Next in Thread]