aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile31
-rw-r--r--include/ctemplates.h2
-rw-r--r--t/test_1.c2
3 files changed, 14 insertions, 21 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
diff --git a/include/ctemplates.h b/include/ctemplates.h
index e0598ad..1aa79ba 100644
--- a/include/ctemplates.h
+++ b/include/ctemplates.h
@@ -10,8 +10,6 @@
* of the GNU General Public License (GPL)
*/
-#include <stddef.h>
-
#ifndef _CTEMPLATE_H
#define _CTEMPLATE_H
diff --git a/t/test_1.c b/t/test_1.c
index 34ee9e2..8f7353c 100644
--- a/t/test_1.c
+++ b/t/test_1.c
@@ -4,7 +4,7 @@
*/
#include <stdio.h>
-
+#include <string.h>
#include <ctemplates.h>
char t_1[] = "This is a <TMPL_VAR name=\"what\">!";