2022-08-27 19:29:43 -05:00
|
|
|
Q=@
|
2022-10-12 12:33:18 -05:00
|
|
|
CC=clang
|
|
|
|
|
|
|
|
GCCCFLAGS=-Wno-format-truncation
|
2022-10-12 12:40:53 -05:00
|
|
|
CFLAGS=-std=c11 -pedantic -g -Wall -pthread -D_GNU_SOURCE -fsanitize=address
|
|
|
|
LDFLAGS=-lm -fsanitize=address
|
2022-10-12 12:33:18 -05:00
|
|
|
|
2022-08-29 17:27:03 -05:00
|
|
|
BUILD_DIR=./objects
|
2022-08-27 19:29:43 -05:00
|
|
|
BIN=jsfw
|
|
|
|
|
2022-10-07 18:36:53 -05:00
|
|
|
RUNARGS=server 7776 ./server_config.json
|
2022-08-27 19:29:43 -05:00
|
|
|
|
2022-08-29 17:27:03 -05:00
|
|
|
SOURCES=$(wildcard *.c)
|
2022-08-27 19:29:43 -05:00
|
|
|
|
|
|
|
OBJECTS:=$(patsubst %.c,$(BUILD_DIR)/%.o,$(SOURCES))
|
|
|
|
|
2022-10-12 12:33:18 -05:00
|
|
|
ifeq ($(CC),gcc)
|
|
|
|
CFLAGS:=$(CFLAGS) $(GCCCFLAGS)
|
|
|
|
endif
|
|
|
|
|
2022-08-27 19:29:43 -05:00
|
|
|
.PHONY: run
|
|
|
|
run: $(BIN)
|
|
|
|
@echo "RUN $(BIN) $(RUNARGS)"
|
|
|
|
$(Q) chmod +x $(BIN)
|
|
|
|
$(Q) ./$(BIN) $(RUNARGS)
|
|
|
|
|
|
|
|
$(BIN): $(OBJECTS)
|
|
|
|
@echo "LD $@"
|
2022-10-01 11:36:57 -05:00
|
|
|
$(Q) $(CC) $(CFLAGS) $^ $(LDFLAGS) -o $@
|
2022-08-27 19:29:43 -05:00
|
|
|
|
|
|
|
$(BUILD_DIR)/%.o: %.c | $(BUILD_DIR)
|
|
|
|
@echo "CC $<"
|
|
|
|
$(Q) $(CC) $(CFLAGS) -c $< -o $@
|
|
|
|
|
|
|
|
.PRECIOUS: $(BUILD_DIR)
|
|
|
|
$(BUILD_DIR):
|
|
|
|
@echo "MKDIR"
|
|
|
|
$(Q) mkdir -p $(BUILD_DIR)
|
|
|
|
|
|
|
|
.PHONY: clean
|
|
|
|
clean:
|
|
|
|
@echo "CLEAN"
|
|
|
|
$(Q) rm -fr $(BUILD_DIR)
|
|
|
|
$(Q) rm -fr $(BIN)
|
|
|
|
|