CC = g++
CFLAGS = -Wall -g -o0
INC =
SRCS1 = client.cpp player.cpp login.cpp
OBJS1 = $(SRCS1:.c=.o)
LIBS =
TARGET1 = tbclient.exe
WXCONFIG= `wx-config --cxxflags` `wx-config --libs`
$(TARGET1): $(OBJS1)
$(CC) $(CFLAGS) $(OBJS1) -o $(TARGET1) $(LIBS) $(WXCONFIG)
SRCS2 = server.cpp player.cpp
OBJS2 = $(SRCS2:.c=.o)
TARGET2 = tbserver.exe
$(TARGET2): $(OBJS2)
$(CC) $(CFLAGS) $(OBJS2) -o $(TARGET2) $(LIBS) $(WXCONFIG)
> Below is my makefile, but it only makes the 1st target:
Add a target the depends on the other two:
> CC = g++
> CFLAGS = -Wall -g -o0
> INC =
> SRCS1 = client.cpp player.cpp login.cpp
> OBJS1 = $(SRCS1:.c=.o)
> LIBS =
> TARGET1 = tbclient.exe
> WXCONFIG= `wx-config --cxxflags` `wx-config --libs`
all: $(TARGET1) $(TARGET2)
> $(TARGET1): $(OBJS1)
> $(CC) $(CFLAGS) $(OBJS1) -o $(TARGET1) $(LIBS) $(WXCONFIG)
>
> SRCS2 = server.cpp player.cpp
> OBJS2 = $(SRCS2:.c=.o)
> TARGET2 = tbserver.exe
>
>
> $(TARGET2): $(OBJS2)
> $(CC) $(CFLAGS) $(OBJS2) -o $(TARGET2) $(LIBS) $(WXCONFIG)
Doing $(EVERYTHING) through $(VARIABLES) like this is a little $(ODD).
--
Ben.
I tried this but it didnot work even with make all. It still only
makes the 1st target.
> Doing $(EVERYTHING) through $(VARIABLES) like this is a little $(ODD).
>
I thought so, but then if aint broke don't fix it (unless you really
know what your doing that is.)
> Daniel <danw...@gmail.com> writes:
>
>> Below is my makefile, but it only makes the 1st target:
>
> Add a target the depends on the other two:
>
>> CC = g++
>> CFLAGS = -Wall -g -o0
>> INC =
>> SRCS1 = client.cpp player.cpp login.cpp
>> OBJS1 = $(SRCS1:.c=.o)
That's obviously wrong: .c vs .cpp.
>> LIBS =
>> TARGET1 = tbclient.exe
>> WXCONFIG= `wx-config --cxxflags` `wx-config --libs`
>
> all: $(TARGET1) $(TARGET2)
>
>> $(TARGET1): $(OBJS1)
>> $(CC) $(CFLAGS) $(OBJS1) -o $(TARGET1) $(LIBS) $(WXCONFIG)
>>
>> SRCS2 = server.cpp player.cpp
>> OBJS2 = $(SRCS2:.c=.o)
>> TARGET2 = tbserver.exe
>>
>>
>> $(TARGET2): $(OBJS2)
>> $(CC) $(CFLAGS) $(OBJS2) -o $(TARGET2) $(LIBS) $(WXCONFIG)
>
> Doing $(EVERYTHING) through $(VARIABLES) like this is a little $(ODD).
Nothing wrong with using variables. I'd do it like this, more or less:
$(TARGET1) $(TARGET2):
$(CC) $(CFLAGS) $^ -o $@ $(LIBS) $(WXCONFIG)
$(TARGET1): $(OBJS1)
$(TARGET2): $(OBJS2)
--
M�ns Rullg�rd
ma...@mansr.com
Here is my current makefile:
CC = g++
CFLAGS = -Wall -g -o0
SRCS1 = client.cpp player.cpp login.cpp
OBJS1 = $(SRCS1:.c=.o)
LIBS =
TARGET1 = tbclient.exe
WXCONFIG= `wx-config --cxxflags` `wx-config --libs`
SRCS2 = server.cpp player.cpp
OBJS2 = $(SRCS2:.c=.o)
TARGET2 = tbserver.exe
$(TARGET1) $(TARGET2): $(CC) $(CFLAGS) $^ -o $@ $(LIBS) $(WXCONFIG)
$(TARGET1): $(OBJS1)
$(TARGET2): $(OBJS2)
You dropped a newline and tab there:
$(TARGET1) $(TARGET2):
$(CC) $(CFLAGS) $^ -o $@ $(LIBS) $(WXCONFIG)
> $(TARGET1): $(OBJS1)
>
> $(TARGET2): $(OBJS2)
--
> You dropped a newline and tab there:
> $(TARGET1) $(TARGET2):
> $(CC) $(CFLAGS) $^ -o $@ $(LIBS) $(WXCONFIG)
You're listing both TARGET1 and TARGET2 before the colon. Can you specify
two targets like this? And if you can, what does $@ expand to?
--
John Gordon A is for Amy, who fell down the stairs
gor...@panix.com B is for Basil, assaulted by bears
-- Edward Gorey, "The Gashlycrumb Tinies"
> > all: $(TARGET1) $(TARGET2)
> >
> I tried this but it didnot work even with make all. It still only
> makes the 1st target.
Did you add it at a point in the code before TARGET2 was defined?
> In <yw1x7htn...@unicorn.mansr.com> =?iso-8859-1?Q?M=E5ns_Rullg=E5rd?= <ma...@mansr.com> writes:
>
>> You dropped a newline and tab there:
>
>> $(TARGET1) $(TARGET2):
>> $(CC) $(CFLAGS) $^ -o $@ $(LIBS) $(WXCONFIG)
>
> You're listing both TARGET1 and TARGET2 before the colon. Can you specify
> two targets like this? And if you can, what does $@ expand to?
Yes you can. $@ expands to whichever one is being built. People
really should read the manuals of tools they use.
[...]
> $(TARGET1) $(TARGET2): $(CC) $(CFLAGS) $^ -o $@ $(LIBS) $(WXCONFIG)
This claims that everything following the colon is a prequisite for
the targets. You should either have a semicolon before $(CC) or
put the 'rule' part on the next line with a htab in front of it.
The answers are 'yes' and 'the current target', cf
A rule with multiple targets is equivalent to writing many rules, each
with one target, and all identical aside from that.
(section 4.10 of the GNU make documentation)
That's right. Unless you pass a target on the command line, make only makes
the first target. Make the first target (I use the target name "all", so
that "make all" also works) dependent on the others.
> CC = g++
> CFLAGS = -Wall -g -o0
> INC =
> SRCS1 = client.cpp player.cpp login.cpp
> OBJS1 = $(SRCS1:.c=.o)
> LIBS =
> TARGET1 = tbclient.exe
> WXCONFIG= `wx-config --cxxflags` `wx-config --libs`
Add:
all: $(TARGET1) $(TARGET2)
I don't recall if variables need to be declared beforehand, or if forward
references are allowed.
> $(TARGET1): $(OBJS1)
> $(CC) $(CFLAGS) $(OBJS1) -o $(TARGET1) $(LIBS) $(WXCONFIG)
>
> SRCS2 = server.cpp player.cpp
> OBJS2 = $(SRCS2:.c=.o)
> TARGET2 = tbserver.exe
>
>
> $(TARGET2): $(OBJS2)
> $(CC) $(CFLAGS) $(OBJS2) -o $(TARGET2) $(LIBS) $(WXCONFIG)
--
Kenneth Brody