diff --git a/.gitignore b/.gitignore index 646396f..042b4a1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,8 @@ -.vscode -build -package/usr \ No newline at end of file +.* + +!.github/ +!.gitignore + +/bin/ +/obj/ +/compile_commands.json diff --git a/makefile b/makefile new file mode 100644 index 0000000..fd843f3 --- /dev/null +++ b/makefile @@ -0,0 +1,28 @@ +CC := x86_64-pc-linux-gnu-gcc +CFLAGS := -Wall -Wextra -Wpedantic -O2 -std=gnu17 +LDFLAGS := + +SRC = $(shell find src/ -name '*.c') +OBJ := $(patsubst src/%,obj/%,$(SRC:.c=.o)) +BIN := bin/coinflip + +compile: compile_commands.json $(BIN) +clean: + rm -rf obj/ bin/ compile_commands.json + +# link the .o files +$(BIN): $(OBJ) + @mkdir -p $(@D) + $(CC) $(LDFLAGS) $(OBJ) -o $(BIN) + +# compile .o files (w/ .d files) +obj/%.o: src/%.c + @mkdir -p $(@D) + $(CC) -c -MD -MP $(CFLAGS) -o $@ $< + +compile_commands.json: makefile + $(MAKE) clean + @touch compile_commands.json + bear -- make compile + +-include $(OBJ:.o=.d)