diff options
| -rw-r--r-- | Makefile | 34 | ||||
| -rw-r--r-- | src/main.c | 13 | ||||
| -rw-r--r-- | src/tdo.c | 15 | ||||
| -rw-r--r-- | src/tdo.h | 8 |
4 files changed, 50 insertions, 20 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 $@ @@ -2,7 +2,9 @@ #include <stdio.h> // for input/output #include <stdlib.h> // for STD macros #include <getopt.h> // for getopt +#include "tdo.h" +// for debugging void print_args(int argc, char* argv[]) { printf("There are %i arguments\n",argc); printf("Those arguments are:\n"); @@ -11,17 +13,6 @@ void print_args(int argc, char* argv[]) { } } -void new_tdo(int argc, char** argv) { - printf("New todo: "); - // just in case not using quotes - for (int i=2; i<argc; ++i) printf("%s ",argv[i]); - printf("\n"); -} - -void print_version() { - printf("tdo version 0.0.1\n"); -} - int main(int argc, char* argv[]) { char* valid_opts = "nv"; int opt; diff --git a/src/tdo.c b/src/tdo.c new file mode 100644 index 0000000..7b3ff0e --- /dev/null +++ b/src/tdo.c @@ -0,0 +1,15 @@ +#include <stdio.h> +#include "tdo.h" + +void print_version() { + printf("tdo version 0.0.1\n"); +} + +void new_tdo(int argc, char** argv) { + printf("New todo: "); + // just in case not using quotes + for (int i=2; i<argc; ++i) printf("%s ",argv[i]); + printf("\n"); +} + + diff --git a/src/tdo.h b/src/tdo.h new file mode 100644 index 0000000..4af5e14 --- /dev/null +++ b/src/tdo.h @@ -0,0 +1,8 @@ +#include <stdio.h> + +// Print version +void print_version(); + +// Create a new todo item +void new_tdo(int argc, char** argv); + |
