Improve Makefile for better binary compilation

User can change the compiler and the optimization level.
Also more generalized rules are used here.
This commit is contained in:
Christoph Grabo 2014-03-04 19:46:05 +01:00
parent 6c6f92fec3
commit 50a44e0dba
1 changed files with 16 additions and 3 deletions

View File

@ -1,5 +1,18 @@
CC?=gcc
O_LVL?=3
all:
gcc -O2 -o server server.c
gcc -O2 -o client client.c
CFLAGS=-O$(O_LVL)
BINARIES= \
server \
client
all: $(BINARIES)
$(BINARIES): %: %.c
$(CC) $(CFLAGS) $@.c -o $@
clean:
rm $(BINARIES)
.PHONY: all clean