-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
57 lines (42 loc) · 1017 Bytes
/
Makefile
File metadata and controls
57 lines (42 loc) · 1017 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
Q=@
CC=gcc
GCCCFLAGS=-Wno-format-truncation
CFLAGS=-std=gnu11 -pedantic -g -Wall -pthread -D_GNU_SOURCE -fsanitize=address
LDFLAGS=-lm
# 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
BUILD_DIR=./objects
BIN=jsfw
RUNARGS=server 7776 ./server_config.json
SOURCES=$(wildcard *.c)
OBJECTS:=$(patsubst %.c,$(BUILD_DIR)/%.o,$(SOURCES))
ifeq ($(CC),gcc)
CFLAGS:=$(CFLAGS) $(GCCCFLAGS)
endif
.PHONY: run
run: $(BIN)
@echo "RUN $(BIN) $(RUNARGS)"
$(Q) chmod +x $(BIN)
$(Q) ./$(BIN) $(RUNARGS)
$(BIN): $(OBJECTS)
@echo "LD $@"
$(Q) $(CC) $(CFLAGS) $^ $(LDFLAGS) -o $@
$(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)