user3273345
user3273345

Reputation: 127

possible error in make file(UBuntu)

TARGETS = client server

CL_OBJ = clientMain.o Controller.o UI.o List.o Movie.o Server.o Serializer.o
SV_OBJ = serverMain.o ServerControl.o Storage.o List.o Movie.o Serializer.o

server: $(SV_OBJ) Connection.o
    g++ -o server $(SV_OBJ) Connection.o

client: $(CL_OBJ) Connection.o
    g++ -o client $(CL_OBJ) Connection.o

clientMain.o:   clientMain.cc
    g++ -c clientMain.cc

serverMain.o:   serverMain.cc
    g++ -c serverMain.cc

Controller.o:   Controller.cc Controller.h 
    g++ -c Controller.cc

UI.o:   UI.cc UI.h 
    g++ -c UI.cc

List.o: List.cc List.h
    g++ -c List.cc

Movie.o:    Movie.cc Movie.h Data.h
    g++ -c Movie.cc

Server.o:   Server.cc Server.h Movie.h Data.h
    g++ -c Server.cc

Storage.o:  Storage.cc Storage.h Movie.h Data.h
    g++ -c Storage.cc

ServerControl.o:    ServerControl.cc ServerControl.h Data.h
    g++ -c ServerControl.cc

Serializer.o:   Serializer.cc Serializer.h
    g++ -c Serializer.cc

clean:
    rm -f $(CL_OBJ) $(SV_OBJ) client server

this makefile only produces server executable not client one. It's probably at the top part before client target because it produces client file if it switches the place with server target. I'm not sure what could be the culprit and appreciate much for your help.

Upvotes: 0

Views: 32

Answers (2)

Paul R
Paul R

Reputation: 213200

You just need to add a dummy target at the beginning:

all: $(TARGETS)

This will then make all the default target when you type make on its own (i.e. without specifying a target) and this will then result in both client and server being built.

Upvotes: 1

MadScientist
MadScientist

Reputation: 101131

Make always builds the first target in the makefile by default, and only that target. If you run make client it will build client.

Or you can introduce a new target as the first one, that depends on the ones you normally want to build; before your server target add:

.PHONY: all
all: server client

Upvotes: 1

Related Questions