diff options
| author | Blake Romero <blake@blkrom.com> | 2024-10-18 02:37:49 +0100 |
|---|---|---|
| committer | Blake Romero <blake@blkrom.com> | 2024-10-30 10:16:05 +0000 |
| commit | 5d7c2925c4ef268413363f0eab01132a6254087e (patch) | |
| tree | 4dac22faa2a42931c037a095f67cf5ef4ea971d3 /Makefile | |
| parent | 83517a2775c953d676fb406dc2f96896b73d2c64 (diff) | |
Refactor main to source & header files, & update Makefile
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 $@ |
