user2129623
user2129623

Reputation:

Creating makefile for multiple executions

I have checked previous questions but did not find similar to mine:

I have client and server two processes

First I execute on ubuntu gcc:

g++ -o a daemon.cpp exclude_fucntion.cpp -lpthread -std=c++11 and then to run ./a

Client execution:

g++ -o b user_main.cpp client.cpp excute ./b

Can I create make file so that on execute it bot a and b can be created? Or how makefile can be useful for my case?

I am fairly new to makefile.

Upvotes: 1

Views: 179

Answers (1)

Stephan Roslen
Stephan Roslen

Reputation: 331

Make will build the first target unless targets are specified. So actually make all will be run if make is executed with the following Makefile. This requests targets a and b to be up to date, which are specified below. (Remember to replace leading blanks with a tab)

all: a b

a: daemon.cpp exclude_fucntion.cpp
        g++ -o a daemon.cpp exclude_fucntion.cpp -lpthread -std=c++11

b: user_main.cpp client.cpp
        g++ -o b user_main.cpp client.cpp

Upvotes: 2

Related Questions