Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Tree: defb9ef5ae
Fetching contributors…

Cannot retrieve contributors at this time

97 lines (75 sloc) 3.814 kB
# Initial Version Copyright (C) 2010 eZuce, Inc., All Rights Reserved.
# Licensed to the User under the LGPL license.
BUILDDIR = $(abspath @builddir@)
SRC = $(abspath @srcdir@)
PACKAGE_REVISION = $(shell $(SRC)/config/revision-gen @PACKAGE_VERSION@)
help-var.DISTRO=To run a command for a different target distro. Default: $(DISTRO). Complete list of available values: @ALL_DISTROS@
DISTRO_OS = $(word 1,$(subst -, ,$(DISTRO)))
DISTRO_VER = $(word 2,$(subst -, ,$(DISTRO)))
DISTRO_ARCH = $(word 3,$(subst -, ,$(DISTRO)))
$(subst fedora,Fedora, \
$(subst centos,CentOS,$(DISTRO_OS)))_$(DISTRO_VER))
# utility
empty :=
space := $(empty) $(empty)
lowercase = $(shell echo $(1) | tr '[:upper:]' '[:lower:]')
# for each sipx-% target, define a variable for the corresponding project directory
PROJ = $(filter $(all),$(subst ., ,$@))
proj = $(call lowercase,$(PROJ))
PROJ_REVISION = $(shell cd $(SRC)/$(PROJ) && ./config/revision-gen @PACKAGE_VERSION@)
# find any matches of $(sipx) or $(lib) anywhere in a target string and expands it into multiple target that
# would follow the given target.
# example: becomes '' when list is 'A B C'
after = $(shell echo $(space)$2$(space) | awk -F : '{if (match($$0,/ $1 /)) {print substr($$0,RSTART)}}')
..._sipx_list = $(call after,$(PROJ),$(sipx))
..._sipx_expanded = $(foreach T,$(..._sipx_list),$(subst $(PROJ),$(T),$*))
..._lib_list = $(call after,$(PROJ),$(lib))
..._lib_expanded = $(foreach T,$(..._lib_list),$(subst $(PROJ),$(T),$*))
..._app_list = $(call after,$(PROJ),$(app))
..._app_expanded = $(foreach T,$(..._app_list),$(subst $(PROJ),$(T),$*))
default-first-target : help;
sipx.% :
$(MAKE) $(foreach P,$(sipx),$(P).$*)
lib.% :
$(MAKE) $(foreach P,$(lib),$(P).$*)
app.% :
$(MAKE) $(foreach P,$(app),$(P).$*)
help.{sipx,lib}.list=list all sipx components
app.list lib.list sipx.list : %.list :
@echo $($*)
include $(sort $(wildcard mak/*.mk))
help.*{1|2}*... = Perform all targets would normally follow the given target in addition to the target itself.\
Very useful when you want to pick-up the build where it last stopped. For example 'make sipXthree...' would\
expand to 'make sipXthree sipXfour sipXfive' but it would not include 'make sipXone sipXtwo'. You can use\
the ... pattern anywhere you a specify a package name. Examples: 'make sipXconfig.rpm...',\
'make distro.centos-5-i386.OpenACD.rpm...'. See 'make sipx.list lib.list' for what the natural order of\
%... :
$(MAKE) $(..._sipx_expanded) $(..._lib_expanded) $(..._app_expanded)
help-values.{1} = Any sipXecs package. For all sipXecs packages use 'sipx'. Complete list of sipXecs packages : $(sipx)
help-values.{2} = Any dependency package. For all dependencies use 'lib'. Complete list of dependencies : $(lib)
help-values.{6} = Any sipXecs application. For all app use 'app'. Complete list of app : $(app)
.PHONY: help
@echo -e "\nCOMMON TARGETS\n==================="
@$(MAKE) --no-print-directory -s help.print
@echo -e "\nALLOWED VALUES\n==================="
@$(MAKE) --no-print-directory -s help-values.print
@echo -e "\nSPECIAL VARIABLES\n==================="
@$(MAKE) --no-print-directory -s help-var.print
help-values.print help.print help-var.print: %.print :
@$(foreach H,$(filter $*.%,$(sort $(.VARIABLES))), \
echo "$$format_help" | Label="$(H:$*.%=%)" Text="$($(H))" bash;)
define format_help
WIDTH=`tput cols`
HELP_WIDTH=`echo $$[$${WIDTH} - $${MARGIN}]`
export TEXT=`echo "$${Text}" | fold -s -w $${HELP_WIDTH} | sed -e "2,10s|^| |g"`
export LABEL="$${Label}"
echo | awk '{printf("%-15s - %s\n", ENVIRON["LABEL"], ENVIRON["TEXT"]);}'
export format_help
Jump to Line
Something went wrong with that request. Please try again.