meta data for this page
  •  

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

courses:ct30a5002:makefiles [2013/09/19 14:37]
julaakko created
courses:ct30a5002:makefiles [2013/09/23 18:50] (current)
julaakko
Line 1: Line 1:
 +===== Makefiles =====
  
 +Here is a small example of a makefile for your programs.
 +
 +<code bash>
 +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)
 +</​code>​
 +
 +Calling ''​make build''​ would result in:
 +<code bash>
 +gcc -Wall -std=gnu99 csource.c common.c -o client
 +gcc -Wall -std=gnu99 ssource.c common.c -o server
 +</​code>​
 +
 +
 +----
 +[[courses:​ct30a5002:​start#​code_snippets|CT30A5002 - Games and Networking]]