aboutsummaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile31
1 files changed, 13 insertions, 18 deletions
diff --git a/Makefile b/Makefile
index e8375b1..dfa9bf0 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-CFLAGS = -Isrc/ -L. -std=c99 -pedantic
+CFLAGS+= -Isrc/ -L. -std=c99 -pedantic
CC?=gcc
LIBNAME = libctemplates.a
BIN_POSTFIX = .exe
@@ -13,13 +13,10 @@ objs = ctemplates fbuf hashmap kmp lexer
objfiles = $(objs:%=build/%.o)
-TEST_1_NAME = t/test_1$(BIN_POSTFIX)
-TEST_2_NAME = t/test_2$(BIN_POSTFIX)
-TEST_3_NAME = t/test_3$(BIN_POSTFIX)
+test_srcs = $(wildcard t/*.c)
+test_objs = $(test_srcs:%.c=%.o)
+test_bins = $(test_srcs:%.c=%)
-examples=hello variable
-example_bins=$(examples:%=examples/%$(BIN_POSTFIX))
-example_objs=$(examples:%=examples/%.o)
$(LIBNAME): $(objfiles)
ar rc $@ $^
@@ -31,22 +28,20 @@ $(objfiles) : build/%.o : src/%.c src/%.h
clean:
$(RM) build/*.o *.a $(LIBNAME)
-$(TEST_1_NAME): t/test_1.c $(LIBNAME)
- $(CC) $(CFLAGS) -o $@ $< -lctemplates
+test: $(test_bins)
+ ./test_1.exe
+ ./test_2.exe
+ ./test_3.ext
-$(TEST_2_NAME): t/test_2.c $(LIBNAME)
- $(CC) $(CFLAGS) -o $@ $< -lctemplates
+$(test_bins) : % : %.o
+ $(CC) -Iinclude/ -o $@ $< libctemplates.a
-$(TEST_3_NAME): t/test_3.c $(LIBNAME)
- $(CC) $(CFLAGS) -o $@ $< -lctemplates
-
-test: $(TEST_1_NAME) $(TEST_2_NAME) $(TEST_3_NAME)
- #$(TEST_1_NAME)
- #$(TEST_2_NAME)
- $(TEST_3_NAME)
+$(test_objs) : %.o : %.c $(LIBNAME)
+ $(CC) -Iinclude/ -o $@ -c $<
examples: $(example_bins)
$(example_bins)
+
$(example_bins): %$(BIN_POSTFIX) : %.o
$(CC) $(CFLAGS) -o $@ $< -lctemplates