From 5c335fca67b6026d7feced15cde6fff08bfd65fe Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Tue, 5 Dec 2017 18:03:41 +1100 Subject: [PATCH] [client] Makefile rewrite from intial lazy version --- client/Makefile | 40 +++++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/client/Makefile b/client/Makefile index 8fd0ae48..7d14c950 100644 --- a/client/Makefile +++ b/client/Makefile @@ -1,24 +1,30 @@ -BINARY=looking-glass-client -CFLAGS=-g -O3 -std=gnu99 -march=native -Wall -Werror -I../common -DDEBUG -LDFLAGS=-lrt +BINARY = looking-glass-client +CFLAGS = -g -Og -std=gnu99 -march=native -Wall -Werror -I./ -I../common -DDEBUG +LDFLAGS = -lrt -CFLAGS+=`pkg-config --cflags sdl2` -LDFLAGS+=`pkg-config --libs sdl2` +LIBS = sdl2 SDL2_ttf gl glu libssl openssl spice-protocol +CFLAGS += $(shell pkg-config --cflags $(LIBS)) +LDFLAGS += $(shell pkg-config --libs $(LIBS)) +BUILD ?= .build +BIN ?= bin -CFLAGS+=`pkg-config --cflags SDL2_ttf` -LDFLAGS+=`pkg-config --libs SDL2_ttf` +OBJS = main.o \ + spice/spice.o \ + ivshmem/ivshmem.o -CFLAGS+=`pkg-config --cflags gl` -LDFLAGS+=`pkg-config --libs gl` +BUILD_OBJS = $(foreach obj,$(OBJS),$(BUILD)/$(obj)) -CFLAGS+=`pkg-config --cflags glu` -LDFLAGS+=`pkg-config --libs glu` +all: $(BINARY) -CFLAGS+=`pkg-config --cflags libssl openssl` -LDFLAGS+=`pkg-config --libs libssl openssl` +$(BUILD)/%.o: %.c + @mkdir -p $(dir $@) + gcc -c $(CFLAGS) -o $@ $< $(LDFLAGS) -CFLAGS+=`pkg-config --cflags spice-protocol` +$(BINARY): $(BUILD_OBJS) + @mkdir -p $(dir $(BIN)/$@) + gcc $(CFLAGS) -o $(BIN)/$(BINARY) $(BUILD_OBJS) $(LDFLAGS) -all: - mkdir -p bin - gcc ${CFLAGS} -o bin/${BINARY} main.c spice/spice.c ivshmem/ivshmem.c ${LDFLAGS} +clean: + rm -rf $(BUILD) $(BIN) + +.PHONY: clean