From 8cb320351cfd95acbca06a4f59e79adc70ed52bf Mon Sep 17 00:00:00 2001 From: Oskari Timperi Date: Fri, 16 May 2014 00:03:12 +0300 Subject: Makefile: allow building test/repl at the same time (use different object files) --- Makefile | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index c37b196..b520b1b 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,6 @@ SOURCES = parse.c list.c atom.c eval.c tokens.c env.c OBJECTS = $(SOURCES:.c=.o) +TEST_OBJECTS = $(foreach obj,$(OBJECTS),test_$(obj)) CFLAGS = -Wall -g LDFLAGS = @@ -7,19 +8,18 @@ LDFLAGS = CC = gcc LD = gcc -# ifneq ($(BUILD_TEST),) +all: test repl + +test_%.o: %.c + $(CC) $(CFLAGS) -c -o $@ $^ test: CFLAGS := $(CFLAGS) -DBUILD_TEST -test: $(OBJECTS) tst_main.o +test: $(TEST_OBJECTS) tst_main.o $(LD) $(LDFLAGS) -o $@ $^ -# else - repl: $(OBJECTS) repl.o linenoise.o $(LD) $(LDFLAGS) -o $@ $^ -# endif - .PHONY: clean clean: rm -f *.o -- cgit v1.2.3