From 3e50983768309268baf7014c446291d498077a41 Mon Sep 17 00:00:00 2001 From: Elronnd Date: Wed, 3 Jul 2019 23:31:22 -0700 Subject: [PATCH 1/2] Clean up Makefile: - Remove manual version munging and include path computation; just use pkg-config. It's more portable and easier to read - Don't force to be cc; this way the user can override it with make CC=tcc (or whatever) - Do compilation separately from linking. This means that when more files are added, compilation can be sped up because they can all be compiled at once - Add a 'clean' target, to remove all build artifacts --- .gitignore | 3 ++- Makefile | 25 ++++++++++--------------- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/.gitignore b/.gitignore index 71830c5..949fd62 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -Xlambda \ No newline at end of file +Xlambda +*.o diff --git a/Makefile b/Makefile index a890c9b..dd66279 100644 --- a/Makefile +++ b/Makefile @@ -1,18 +1,13 @@ -CC = cc -LD = $(CC) -OS = $(shell uname) -GUILE_VERSION ?= 2.2 -GUILE_INCLUDE = $(OS) -GUILE_INCLUDE := $(GUILE_INCLUDE:Linux=/usr/include/guile/$(GUILE_VERSION)) -GUILE_INCLUDE := $(GUILE_INCLUDE:$(OS)=/usr/local/include/guile/$(GUILE_VERSION)) +CC ?= cc +CCLD ?= $(CC) -CFLAGS = -fPIC -Os -CFLAGS += -Wall -Wno-unused-function -CFLAGS += -I$(GUILE_INCLUDE) -I/usr/local/include -pthread -LDFLAGS = -L/usr/local/lib -pthread -lguile-$(GUILE_VERSION) -lgc -CFLAGS += -I/usr/X11R6/include -LDFLAGS += -L/usr/X11R6/lib -lxcb +CFLAGS += -fPIC -g -Os -Wall -Wno-unused-function $(shell pkg-config --cflags guile-2.2 xcb) +LDFLAGS += $(shell pkg-config --libs guile-2.2 xcb) +OBJ := Xlambda.o -all: - $(CC) $(CFLAGS) $(LDFLAGS) Xlambda.c -o Xlambda +all: $(OBJ) + $(CCLD) $(LDFLAGS) -o Xlambda $(OBJ) + +clean: + rm -f Xlambda $(OBJ) From 79b6412e215eb13f378c894665671d9723a3a39c Mon Sep 17 00:00:00 2001 From: Elronnd Date: Thu, 4 Jul 2019 18:13:27 -0700 Subject: [PATCH 2/2] Fix makefile to work with bsd make --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index dd66279..a6eb9ef 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,8 @@ CC ?= cc CCLD ?= $(CC) -CFLAGS += -fPIC -g -Os -Wall -Wno-unused-function $(shell pkg-config --cflags guile-2.2 xcb) -LDFLAGS += $(shell pkg-config --libs guile-2.2 xcb) +CFLAGS += -fPIC -g -Os -Wall -Wno-unused-function `pkg-config --cflags guile-2.2 xcb` +LDFLAGS += `pkg-config --libs guile-2.2 xcb` OBJ := Xlambda.o