128 lines
2.4 KiB
Makefile
128 lines
2.4 KiB
Makefile
ifndef HAS_UTIL_MK
|
|
HAS_UTIL_MK := T
|
|
|
|
MK_DIR := $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST))))
|
|
|
|
# define the $(\n) macro which has the value '\n'
|
|
# Note: This really requires two empty lines!
|
|
ifndef \n
|
|
define \n
|
|
|
|
|
|
endef
|
|
endif
|
|
|
|
# define the $, or $(,) macro which has the value ','
|
|
ifndef ,
|
|
, := ,
|
|
endif
|
|
ifndef comma
|
|
comma := ,
|
|
endif
|
|
|
|
# define the $(sp) macro which has the value ' '
|
|
ifndef blank
|
|
blank :=
|
|
endif
|
|
ifndef sp
|
|
sp := $(blank) $(blank)
|
|
endif
|
|
|
|
# define the $= or $(=) macro which has the value '='
|
|
ifndef equals
|
|
equals := =
|
|
endif
|
|
ifndef $(equals)
|
|
$(equals) := =
|
|
endif
|
|
|
|
# define the $# or $(#) macro which has the value '#'
|
|
ifndef \#
|
|
hash := \#
|
|
endif
|
|
ifndef $(hash)
|
|
$(hash) := \#
|
|
endif
|
|
|
|
# define the $: or $(:) macro which has the value ':'
|
|
ifndef colon
|
|
colon := :
|
|
endif
|
|
ifndef $(colon)
|
|
$(colon) := :
|
|
endif
|
|
|
|
# define the $($$) macro which has the value '$'
|
|
ifndef dollar
|
|
dollar := $$
|
|
endif
|
|
ifndef $(dollar)
|
|
$(dollar) := $$
|
|
endif
|
|
|
|
#define macros for '(' and ')'
|
|
ifndef oparen
|
|
oparen := (
|
|
endif
|
|
ifndef cparen
|
|
cparen := )
|
|
endif
|
|
|
|
dummy :=
|
|
sp := $(dummy) $(dummy)
|
|
PARENO := (
|
|
PARENC := )
|
|
|
|
ifneq (,$(or $(ComSpec),$(COMSPEC),$(comspec)))
|
|
ifneq (,$(filter Cygwin,$(shell uname -a)))
|
|
HOSTENV := cygwin
|
|
NULL := /dev/null
|
|
fixpath-shell = $(subst $(sp),\$(sp),$(subst $(oparen),\$(oparen),$(subst $(cparen),\$(cparen),$(subst \,/,$(1)))))
|
|
fixpath-cyg = $(call fixpath-shell,$(1))
|
|
fixpath-make = $(strip\
|
|
$(subst $(sp),?,$(shell cygpath $(call fixpath-cyg,$(1)))))
|
|
else
|
|
HOSTENV := w32
|
|
NULL := nul
|
|
fixpath-make = $(subst \,/,$(subst $(sp),?,$(1)))
|
|
endif
|
|
endif
|
|
|
|
DIRSEP ?= /
|
|
SHQ ?= $(if T,\)
|
|
fixpath-make ?= $(1)
|
|
fixpath-shell ?= $(1)
|
|
|
|
TEST := test
|
|
RD ?= rm -rf
|
|
|
|
NULL ?= $(or $(wildcard /dev/null),nul)
|
|
|
|
ifeq (T,$(V))
|
|
mk-debug = $(info $(1))
|
|
mk-debug-lno = $(warning $(\n)$(1))
|
|
mk-debug-vars = $(foreach _mkv,$(1),$(info $(_mkv) := '$($(_mkv))'))
|
|
endif
|
|
|
|
define include-once-helper
|
|
ifndef $(subst ?,_,$(subst /,_,$(2)))-included
|
|
ifneq (,$(wildcard $(2)))
|
|
$(subst ?,_,$(subst /,_,$(2)))-included := T
|
|
$$(call mk-debug-lno,+ including '$(1)')
|
|
include $(2)
|
|
else
|
|
$$(call mk-debug-lno,[WARN] could not find '$(1)')
|
|
endif
|
|
endif
|
|
endef
|
|
|
|
include-once = $(eval $(call include-once-helper,$1,$(subst $(sp),?,$(1))))
|
|
|
|
# END: HAS_UTIL_MK
|
|
endif
|
|
|
|
|
|
# Local Variables:
|
|
# tab-width: 2
|
|
# End:
|