diff options
Diffstat (limited to 'Makefile')
| -rw-r--r-- | Makefile | 34 |
1 files changed, 25 insertions, 9 deletions
@@ -1,26 +1,42 @@ -# Compiler to options +proj=tdo + +# Compiler options CC=gcc CFLAGS=-std=c17 -Wall -Werror -g # Directory paths -src=src -bin=bin +src:=src +bin:=bin +obj:=obj + +# Files +srcs=$(filter-out $(src)/main.c, $(wildcard $(src)/*.c)) +objs=$(patsubst $(src)/%.c, $(obj)/%.o, $(srcs)) # Directives .PHONY: build -build: $(bin)/tdo +build: $(bin)/$(proj) .PHONY: clean clean: -rm -r $(bin) $(obj) -# Build executable -$(bin)/tdo: $(bin) $(src)/main.c +.PHONY: info +info: + @echo srcs: $(srcs) + @echo objs: $(objs) + +# Make object files +$(obj)/%.o: $(srcs) $(obj) + $(CC) $(CFLAGS) -o $@ -c $< + +# Build executable including any object files +$(bin)/$(proj): $(bin) $(objs) $(src)/main.c $(CC) $(CFLAGS) -o $@ $(filter-out $<,$^) -# Make bin directory +# Make directories $(bin): mkdir $@ - - +$(obj): + mkdir $@ |
