36 lines
532 B
Makefile
36 lines
532 B
Makefile
|
CC = gcc
|
||
|
|
||
|
INCFLAGS = -Isrc
|
||
|
|
||
|
CCFLAGS = -std=c17 -Wall -Wextra -O2
|
||
|
CCFLAGS += $(INCFLAGS)
|
||
|
|
||
|
LDFLAGS += $(INCFLAGS)
|
||
|
|
||
|
BIN = bin
|
||
|
APP = $(BIN)/app
|
||
|
SRC = $(shell find src -name "*.c")
|
||
|
OBJ = $(SRC:%.c=$(BIN)/%.o)
|
||
|
|
||
|
.PHONY: clean build
|
||
|
|
||
|
dirs:
|
||
|
mkdir -p ./$(BIN)
|
||
|
mkdir -p ./$(BIN)/src
|
||
|
mkdir -p ./$(BIN)/src/io
|
||
|
mkdir -p ./$(BIN)/src/packet
|
||
|
mkdir -p ./$(BIN)/src/server
|
||
|
|
||
|
run: build
|
||
|
$(APP)
|
||
|
|
||
|
build: dirs ${OBJ}
|
||
|
${CC} -o $(APP) $(filter %.o,$^) $(LDFLAGS)
|
||
|
|
||
|
$(BIN)/%.o: %.c
|
||
|
$(CC) -o $@ -c $< $(CCFLAGS)
|
||
|
|
||
|
clean:
|
||
|
rm -rf $(APP)
|
||
|
rm -rf $(BIN)
|