c - GNU Makefile parallel execution of two files -
i using makefile first time , want execute 2 files @ same time. server , client file, every file has it's own main, , 2 files communicate each other. till have written following makefile:
all: server client server: server.c gcc server.c -o server ./server client: client.c gcc client.c -o client ./client
so want start server first client can connect afterwards. , problem: if execute makefile server starts. possible start client directly after server instead of 1 file @ time?
it's unusual try both build , run programs makefile (except running automated regression tests, example.)
normally, run make, run code. personally, i'd start sever in terminal window run client in first one.
but if want makefile, try following:
all: server client run server: server.c gcc server.c -o server client: client.c gcc client.c -o client run: ./server & ./client killall server
the last line kills off server after client has finished. may not necessary if server has other means of shutting down if doesn't, you'll end lot of copies of server processes.
you might find easier write separate shell script run tests.
Comments
Post a Comment