CC = gcc -O2 -std=c11 -pedantic -Wall # -g LIB = qce.a OBJS = qce.o fft.o TEMPLATES = qtype State Q zero init swap product tangle H X Z CX M \ reduce collapse operate print abs2 TMPS = Real.h Complex.h all: $(LIB) # Real.h looks like: # #define qtype qtype_Real # #define swap swap_Real # ... # Complex.h looks like: # #define qtype qtype_Complex # #define swap swap_Complex # ... # $(TMPS): Makefile for type in Real Complex; do \ for t in $(TEMPLATES); do echo "#define $$t $${t}_$${type}"; done > $$type.h; \ done $(OBJS): qce.h template.h template.c $(TMPS) Makefile $(LIB): $(OBJS) Makefile ar rcs $(LIB) $(OBJS) clean: rm -f a.out core $(OBJS) clobber: clean rm -f $(LIB) $(TMPS)