From 987d889c19e41f3f7f382e6c8e5daf26d271a47d Mon Sep 17 00:00:00 2001 From: Ian Piumarta Date: Wed, 2 Sep 2020 18:16:25 +0900 Subject: [PATCH] Use implicit rules to build binary; add compiler/linker search locations for Darwin MacPorts --- Makefile | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index e1e87c3..5efffcc 100644 --- a/Makefile +++ b/Makefile @@ -1,15 +1,20 @@ LEG = leg CC = cc -CFLAGS = -Wall -g -LDLIBS = -L/usr/local/lib -lgc +CFLAGS = -I/usr/local/include -I/opt/local/include -Wall -Wno-unused-label -g +LDLIBS = -L/usr/local/lib -L/opt/local/lib -lgc + +all : parse # moved LDLIBS to end because ld scans files from left to right and collects only required symbols -parse: parse.c object.c - $(CC) $(CFLAGS) -o parse parse.c $(LDLIBS) +%: %.c object.c + $(CC) $(CFLAGS) -o $@ $< $(LDLIBS) -parse.c: parse.leg - $(LEG) -o parse.c parse.leg +%.c: %.leg + $(LEG) -o $@ $< clean: - rm parse parse.c + rm -f parse parse.c + +opt: + $(MAKE) CFLAGS="-DNDEBUG -O3 -fomit-frame-pointer"