use makefile build system
This commit is contained in:
11
.gitignore
vendored
11
.gitignore
vendored
@@ -1,3 +1,8 @@
|
|||||||
.vscode
|
.*
|
||||||
build
|
|
||||||
package/usr
|
!.github/
|
||||||
|
!.gitignore
|
||||||
|
|
||||||
|
/bin/
|
||||||
|
/obj/
|
||||||
|
/compile_commands.json
|
||||||
|
|||||||
28
makefile
Normal file
28
makefile
Normal file
@@ -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)
|
||||||
Reference in New Issue
Block a user