BE_reseau/Makefile

66 lines
1.6 KiB
Makefile
Raw Permalink Normal View History

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
2016-06-13 23:17:19 +02:00
CC := gcc
LD := gcc
TAR_FILENAME := $(DATE)-mictcp-$(TAG).tar.gz
MODULES := api apps
2016-06-13 23:17:19 +02:00
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
2016-06-13 23:17:19 +02:00
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 $$@
2016-06-13 23:17:19 +02:00
endef
.PHONY: all checkdirs clean
all: checkdirs build/client build/server build/gateway
build/client: $(OBJ_CLI)
$(LD) $^ -o $@ -lm -lpthread
2016-06-13 23:17:19 +02:00
build/server: $(OBJ_SERV)
$(LD) $^ -o $@ -lm -lpthread
2016-06-13 23:17:19 +02:00
build/gateway: $(OBJ_GWAY)
$(LD) $^ -o $@ -lm -lpthread
2016-06-13 23:17:19 +02:00
checkdirs: $(BUILD_DIR)
$(BUILD_DIR):
@mkdir -p $@
clean:
@rm -rf $(BUILD_DIR)
distclean:
@rm -rf $(BUILD_DIR)
@-rm -f *.tar.gz || true
2016-06-13 23:17:19 +02:00
$(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