forked from nicolasvw/mictcp
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Makefile
65 lines (45 loc) · 1.56 KB
/
Makefile
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
57
58
59
60
61
62
63
64
65
DATE := `date +'%Y%m%d'`
TAG := moodle-$(USER)
PORT := $(shell expr `id -u` % 2000 + 12487)
PORT2 := $(shell expr $(PORT) + 1)
ifneq ($(tag),)
TAG := $(TAG)-$(tag)
endif
CC := gcc
LD := gcc
TAR_FILENAME := $(DATE)-mictcp-$(TAG).tar.gz
MODULES := api apps
SRC_DIR := $(addprefix src/,$(MODULES)) src
BUILD_DIR := $(addprefix build/,$(MODULES)) build
SRC := $(foreach sdir,$(SRC_DIR),$(wildcard $(sdir)/*.c))
OBJ := $(patsubst src/%.c,build/%.o,$(SRC))
OBJ_CLI := $(patsubst build/apps/gateway.o,,$(patsubst build/apps/server.o,,$(OBJ)))
OBJ_SERV := $(patsubst build/apps/gateway.o,,$(patsubst build/apps/client.o,,$(OBJ)))
OBJ_GWAY := $(patsubst build/apps/server.o,,$(patsubst build/apps/client.o,,$(OBJ)))
INCLUDES := include
vpath %.c $(SRC_DIR)
define make-goal
$1/%.o: %.c
$(CC) -DAPI_CS_Port=$(PORT) -DAPI_SC_Port=$(PORT2) -std=gnu99 -Wall -g -I $(INCLUDES) -c $$< -o $$@
endef
.PHONY: all checkdirs clean
all: checkdirs build/client build/server build/gateway
build/client: $(OBJ_CLI)
$(LD) $^ -o $@ -lm -lpthread
build/server: $(OBJ_SERV)
$(LD) $^ -o $@ -lm -lpthread
build/gateway: $(OBJ_GWAY)
$(LD) $^ -o $@ -lm -lpthread
checkdirs: $(BUILD_DIR)
$(BUILD_DIR):
@mkdir -p $@
clean:
@rm -rf $(BUILD_DIR)
distclean:
@rm -rf $(BUILD_DIR)
@-rm -f *.tar.gz || true
$(foreach bdir,$(BUILD_DIR),$(eval $(call make-goal,$(bdir))))
dist:
@tar --exclude=build --exclude=*tar.gz --exclude=.git* -czvf mictcp-bundle.tar.gz ../mictcp
prof:
@tar --exclude=build --exclude=.*tar.gz --exclude=video -czvf $(TAR_FILENAME) ../mictcp