meta data for this page
  •  

Makefiles

Here is a small example of a makefile for your programs.

COMPILER=gcc
CFLAGS=-Wall -std=gnu99
#List sources in separate makefile variables (separate sourcefiles with spaces)
#For client 
SOURCES1=csource.c common.c
#For server
SOURCES2=ssource.c common.c
 
#Client
OUTPUT1=client
#Server
OUTPUT2=server
 
#Multiple lines can be added into one makefile rule
#with 'make build' both server and client would be compile.
#Use one compilation per line in these exercises.
build:
	$(COMPILER) $(CFLAGS) $(SOURCES1) -o $(OUTPUT1)
	$(COMPILER) $(CFLAGS) $(SOURCES2) -o $(OUTPUT2)

Calling make build would result in:

gcc -Wall -std=gnu99 csource.c common.c -o client
gcc -Wall -std=gnu99 ssource.c common.c -o server

CT30A5002 - Games and Networking