2022-08-27 19:29:43 -05:00
|
|
|
Q=@
|
2022-10-12 15:28:50 -05:00
|
|
|
CC=gcc
|
2022-10-12 12:33:18 -05:00
|
|
|
|
|
|
|
GCCCFLAGS=-Wno-format-truncation
|
2023-04-15 11:24:25 -05:00
|
|
|
CFLAGS=-std=c11 -pedantic -g -Wall -pthread -D_GNU_SOURCE
|
2022-10-12 15:28:50 -05:00
|
|
|
LDFLAGS=-lm
|
2022-10-12 12:33:18 -05:00
|
|
|
|
2023-04-15 11:24:25 -05:00
|
|
|
# The root for /sys and /dev needs to be moved in docker, this should stay empty in most cases
|
|
|
|
FSROOT=""
|
|
|
|
|
|
|
|
# enable VERBOSE if VERBOSE=1
|
|
|
|
ifeq ($(VERBOSE),1)
|
|
|
|
CFLAGS+=-DVERBOSE
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifdef FSROOT
|
|
|
|
CFLAGS+=-D_FSROOT=$(FSROOT)
|
|
|
|
endif
|
|
|
|
|
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)
|
|
|
|
|