# compiler (can be replaced by clang) CC = gcc # linker LD = $(CC) # compiler options ## -Wall: most warnings ## -pedantic: more warnings ## -g: debugging symbols ## -std=c99: ### accept C++ // comments ### accept C++-like variable declaration: anywhere in functions and in for(int i; ...; ...) ### disable GNU extensions for better compatibility with other compilers (clang, msvc) CFLAGS = -Wall -pedantic -g -std=c99 # linker options LDFLAGS = # for multiple targets: ## duplicate this section ## rename SOURCE to SOURCE1, SOURCE2, etc. ## and EXE to EXE1, EXE2, etc. # SOURCES: list of C filenames needed to build the executable EXE SOURCES = Automaton.c testAutomaton.c # EXE: name of the executable produced EXE = testAutomaton # default targets all: Makefile.d $(EXE) # build the executable $(EXE): $(SOURCES:%.c=%.o) $(LD) $^ -o $@ $(LDFLAGS) # clean everything but sources distclean: clean $(RM) $(EXE) # create .o from .c .c.o: $(CC) -c $(CFLAGS) $< # remove non essential files clean: $(RM) *.o *~ *.log Makefile.d *.tmp .*tmp # only real files can be non phony targets .PHONY: all clean distclean debug release # for .h dependencies Makefile.d: $(CC) -MM *.c > Makefile.d # for .h dependencies -include Makefile.d