CFLAGS+= -Isrc/ -L. -std=c99 -pedantic CC?=gcc LIBNAME = libctemplates.a BIN_POSTFIX = .exe ifeq ($(DEBUG),true) CFLAGS += -g -O0 -Wall -Wextra -Werror else CFLAGS += -O3 endif objs = ctemplates fbuf hashmap kmp lexer objfiles = $(objs:%=build/%.o) test_srcs = $(wildcard t/*.c) test_objs = $(test_srcs:%.c=%.o) test_bins = $(test_srcs:%.c=%) $(LIBNAME): $(objfiles) ar rc $@ $^ ranlib $@ $(objfiles) : build/%.o : src/%.c src/%.h $(CC) $(CFLAGS) -c -o $@ $< clean: $(RM) build/*.o *.a $(LIBNAME) test: $(test_bins) ./test_1.exe ./test_2.exe ./test_3.ext $(test_bins) : % : %.o $(CC) -Iinclude/ -o $@ $< libctemplates.a $(test_objs) : %.o : %.c $(LIBNAME) $(CC) -Iinclude/ -o $@ -c $< examples: $(example_bins) $(example_bins) $(example_bins): %$(BIN_POSTFIX) : %.o $(CC) $(CFLAGS) -o $@ $< -lctemplates $(example_objs): %.o : %.c $(CC) -I./include -L. -c -o $@ $< -lctemplates install: $(LIBNAME) cp $(LIBNAME) /usr/local/lib mkdir -p /usr/local/include/ctemplates cp include/ctemplates.h /usr/local/include/ctemplates/