# chext: rename file extensions project # General variables CFLAGS=-O3 -Wall -Wextra -std=c11 INCLUDE_PATH := -Isrc INCLUDE_PATH += -Isrc/libchext # Projects all: tools doc runtest tools: cli libchext test # Command line tool: chext CLI_HEADERS=$(wildcard src/cli/*.h) CLI_SOURCES=$(wildcard src/cli/*.c) # src/cli/args.c src/cli/main.c CLI_OBJECTS=$(CLI_SOURCES:src/%.c=build/%.o) # build/cli/args.o build/cli/main.o cli: bin/chext bin/chext: $(CLI_OBJECTS) $(CLI_HEADERS) lib/chext.a | bin gcc $(CFLAGS) -o $@ $(CLI_OBJECTS) lib/chext.a # Library: chext.a LIB_HEADERS=$(wildcard src/libchext/*.h) LIB_SOURCES=$(wildcard src/libchext/*.c) LIB_OBJECTS=$(LIB_SOURCES:src/%.c=build/%.o) .PHONY: libchext libchext: lib/chext.a lib/chext.a: $(LIB_OBJECTS) | lib ar rs $@ $^ # Unit testing TEST_HEADERS=$(wildcard src/test/*.h) TEST_SOURCES=$(wildcard src/test/*.c) TEST_OBJECTS=$(TEST_SOURCES:src/%.c=build/%.o) runtest: test bin/test test: bin/test bin/test: $(TEST_OBJECTS) $(TEST_HEADERS) lib/chext.a | bin gcc $(CFLAGS) -o $@ $(TEST_OBJECTS) lib/chext.a # Compile a C source file build/%.o: src/%.c | build gcc -c $(CFLAGS) $(INCLUDE_PATH) -o $@ $< # Directories build: mkdir -p $@ $@/cli $@/libchext $@/test bin: mkdir -p $@ lib: mkdir -p $@ # Documentation .PHONY: doc doc: Doxyfile doxygen Doxyfile # Misc .PHONY: zip zip: rm -f chext.zip zip -r9 chext.zip Doxyfile Makefile src .PHONY: clean clean: rm -rf build bin doc lib html latex