From b9899c6cbe2f694c9db36e9d4e15c532d10b546f Mon Sep 17 00:00:00 2001 From: Alexander Pickering Date: Thu, 25 Oct 2018 12:08:54 -0400 Subject: Started refactoring code Added a src/ and build/ directory Added a include/ directory Included file is smaller --- Makefile | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 6f46156..d6580b2 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -CFLAGS = -I. -L. -std=c99 -pedantic +CFLAGS = -Isrc/ -L. -std=c99 -pedantic CC?=gcc LIBNAME = libctemplates.a BIN_POSTFIX = .exe @@ -9,26 +9,21 @@ else CFLAGS += -O3 endif -TEST_1_NAME = t/test_1$(BIN_POSTFIX) - -$(LIBNAME): ctemplates.o fbuf.o kmp.o hashmap.o - ar rc $(LIBNAME) ctemplates.o fbuf.o kmp.o hashmap.o - ranlib $(LIBNAME) +objs = ctemplates fbuf hashmap kmp +objfiles = $(objs:%=build/%.o) -fbuf.o : fbuf.c fbuf.h - $(CC) $(CFLAGS) -c -o fbuf.o fbuf.c -kmp.o : kmp.c kmp.h - $(CC) $(CFLAGS) -c -o kmp.o kmp.c +TEST_1_NAME = t/test_1$(BIN_POSTFIX) -ctemplates.o: ctemplates.c ctemplates.h - $(CC) $(CFLAGS) -c -o ctemplates.o ctemplates.c +$(LIBNAME): $(objfiles) + ar rc $@ $^ + ranlib $@ -hashmap.o: hashmap.c hashmap.h - $(CC) $(CFLAGS) -c -o hashmap.o hashmap.c +$(objfiles) : build/%.o : src/%.c src/%.h + $(CC) $(CFLAGS) -c -o $@ $< clean: - rm -f *.o *.a template + rm -f build/*.o *.a template $(TEST_1_NAME): t/test_1.c $(LIBNAME) $(CC) $(CFLAGS) -o $(TEST_1_NAME) t/test_1.c -lctemplates @@ -39,4 +34,4 @@ test: $(TEST_1_NAME) install: $(LIBNAME) cp $(LIBNAME) /usr/local/lib mkdir -p /usr/local/include/ctemplates - cp *.h /usr/local/include/ctemplates/ + cp include/ctemplates.h /usr/local/include/ctemplates/ -- cgit v1.2.3-70-g09d2