You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

155 lines
4.2 KiB

.PHONY: clean all rel_mktemp_dir console help
include buildflags.mk
include build.mk
CONTROLLER_REL_TAR:=$(CURDIR)/controller_$(shell date +%Y%m%d%H%M).tar.gz
CONSOLE_REL_TAR:=$(CURDIR)/console_$(shell date +%Y%m%d%H%M).tar.gz
all: common controller console
help:
@echo "Available build rules"; \
echo "---------------------"; \
echo " console Build all executables for the console"; \
echo " controller Build the controller executables"; \
echo " all Build both controller and console"; \
echo " release_console Build a release tar file for the console"; \
echo " release_controller Build a release tar file for the controller"; \
echo " release Build both controller and console release"; \
echo " clean Clean for both controller and console"; \
echo ""; \
echo " HOSTSYS=<prefix> Cross compile for <prefix>.";\
echo " e.g.: HOSTSYS=arm-linux-gnueabihf"; \
echo ""; \
echo "Building a release"; \
echo "------------------"; \
echo "Simply running \"$(MAKE) release\" will build both the console and"; \
echo "controller. They are stored in individual tar files, in the root"; \
echo "of the dt_ctrl directory."; \
echo "The releases are built in a temporary work directory from a clean"; \
echo "git checkout. A release to be used for production must always"; \
echo "be built from a version which is already committed to the"; \
echo "golden repository (on eris.camras.nl)."
clean: subdirs_CLEAN
rm -rf lib/*
rm -rf include/libnova
# Rules for building a release
rel_mktemp_dir:
$(eval REL_BUILD_DIR:=$(shell mktemp -d /tmp/dt_ctrl_XXXXXX))
@echo "****** Building code in dir: $(REL_BUILD_DIR)"
rel_clone_dir: rel_mktemp_dir
@echo "****** Creating clean checkout of source"; \
git clone . $(REL_BUILD_DIR) >/dev/null; \
echo " Done"
rel_utils: rel_clone_dir
@echo "****** Building common/utils"; \
$(MAKE) -C $(REL_BUILD_DIR)/common/utils >/dev/null; \
echo " Done"
rel_trace: rel_utils
@echo "****** Building common/trace"; \
$(MAKE) -C $(REL_BUILD_DIR)/common/trace >/dev/null; \
echo " Done"
rel_command: rel_utils
@echo "****** Building common/command"; \
$(MAKE) -C $(REL_BUILD_DIR)/common/command >/dev/null; \
echo " Done"
rel_log:
@echo "****** Building common/log"; \
$(MAKE) -C $(REL_BUILD_DIR)/common/log >/dev/null; \
echo " Done"
rel_ctrl: rel_trace rel_log rel_command
@echo "****** Building controller"; \
$(MAKE) -C $(REL_BUILD_DIR)/controller >/dev/null; \
echo " Done"
rel_cons: rel_trace rel_log rel_command
@echo "****** Building console"; \
$(MAKE) -C $(REL_BUILD_DIR)/console >/dev/null; \
echo " Done"
$(CONSOLE_REL_TAR): rel_cons
@tar -C $(REL_BUILD_DIR)/release -zhcf $@ console
@echo "****** Created console release file $@"
$(CONTROLLER_REL_TAR): rel_ctrl
@tar -C $(REL_BUILD_DIR)/release -zhcf $@ controller
@echo "****** Created controller release file $@"
release: $(CONSOLE_REL_TAR) $(CONTROLLER_REL_TAR)
release_console: $(CONSOLE_REL_TAR)
release_controller: $(CONTROLLER_REL_TAR)
DIR := .
SRCS :=
TARGETS :=
CLEAN :=
define SUBDIR
ifeq ($(DIR),.)
DIR := $1
else
DIR := $(DIR)/$1
endif
$(DIR)_TMPTARGETS:=$(value TARGETS)
TARGETS:=
include $(DIR)/$1/build.mk
targets_$$(DIR): $$(TARGETS)
$$(TARGETS): $(DIR)/$1/build.mk Makefile build.mk buildflags.mk
TARGETS:= $$($(DIR)_TMPTARGETS) $$(TARGETS)
DIR := $(DIR)
endef
CFLAGS := $(BUILD_CFLAGS) -D_GNU_SOURCE -Icommon -Icommon/include -Icontroller -Iconsole/console -Iinclude
LDFLAGS := -Lcommon/lib -Lcontroller/lib -Lconsole/console/lib -Llib -Wl,--as-needed
VPATH += common/lib controller/lib console/console/lib lib
VPATH += include
TARGETS:=
$(eval $(call SUBDIR,common))
common: $(TARGETS)
TARGETS:=
$(eval $(call SUBDIR,controller))
controller: $(TARGETS)
ifdef BUILD_CONSOLE
TARGETS:=
$(eval $(call SUBDIR,console))
console: $(TARGETS)
endif
SRCS_IL = $(filter %.il,$(SRCS))
$(SRCS_IL): $(IL2C)
SRCS_TMP:=$(SRCS:.il=.il2c.d)
DEPS:=$(SRCS_TMP:.c=.d)
DEPSLIBS:=$(foreach DEP,$(DEPS),$(dir $(DEP)).libs/$(notdir $(DEP)))
-include $(DEPS) $(DEPSLIBS)
CLEAN += $(DEPS) $(DEPSLIBS) $(SRCS_IL:.il=.il2c.c)
subdirs_CLEAN:
$(foreach CLEANITEM,$(CLEAN), rm -rf $(CLEANITEM);)