aboutsummaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorAlexander Pickering <alexandermpickering@gmail.com>2018-10-25 12:08:54 -0400
committerAlexander Pickering <alexandermpickering@gmail.com>2018-10-25 12:08:54 -0400
commitb9899c6cbe2f694c9db36e9d4e15c532d10b546f (patch)
tree248564d6bd22dd6f11459a51f73a144ae91756fc /Makefile
parentd416a80324225d0c64c5021e74773a2e768de73a (diff)
downloadlibctemplates-b9899c6cbe2f694c9db36e9d4e15c532d10b546f.tar.gz
libctemplates-b9899c6cbe2f694c9db36e9d4e15c532d10b546f.tar.bz2
libctemplates-b9899c6cbe2f694c9db36e9d4e15c532d10b546f.zip
Started refactoring code
Added a src/ and build/ directory Added a include/ directory Included file is smaller
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile27
1 files changed, 11 insertions, 16 deletions
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/