-
Notifications
You must be signed in to change notification settings - Fork 5
/
Makefile.win.target
79 lines (59 loc) · 3.21 KB
/
Makefile.win.target
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# spell-checker:ignore (make) EXEEXT LDFLAGS SHELLSTATUS addsuffix addprefix devnull endef falsey ifeq ifneq ; (names/vars) msdosdjgpp lessecho lesskey scrsize xbuf OSID POSIX
AUX_names := lessecho lesskey
AUX_adds_lessecho := version
AUX_adds_lesskey := lesskey_parse version xbuf
AUX_skips := scrsize## `scrsize` is POSIX only
$(call %debug_var,AUX_names)
$(call %debug_var,AUX_skips)
####
AUX_targets := $(addprefix ${OUT_DIR_bin}/,$(addsuffix ${EXEEXT},${AUX_names}))
OBJ_files := $(filter-out $(addprefix ${OUT_DIR_obj}/,$(addsuffix .${O},${AUX_names} ${AUX_skips})),${OBJ_files})
$(call %debug_var,AUX_targets)
$(call %debug_var,OBJ_files)
####
# ref: <https://stackoverflow.com/questions/6877238/what-is-the-windows-equivalent-of-the-diff-command> @@ <https://archive.is/dKoTB>
# NOTE: after execution, ${.SHELLSTATUS} == 0 if files are identical; 1 if files are different; 2 if error
ifeq (${OSID},win)
%diff_shell_s = "${SystemRoot}\System32\fc" $(call %map,%shell_quote,$(call %map,%as_win_path,${1} ${2})) 2> ${devnull}
else
%diff_shell_s = diff ${1} ${2} 2> ${devnull}
endif
####
DEFINE_EXT := $(if $(filter-out i586-pc-msdosdjgpp-gcc,${CC}),wn,ds)
DEFINE_EXISTS := $(if $(wildcard ${SRC_DIR}/defines.h),${true},${false})
DEFINE_DIFFERS := ${false}
DEFINE_DIFF := $(shell $(call %diff_shell_s,${SRC_DIR}/defines.h,${SRC_DIR}/defines.${DEFINE_EXT}))
# * if ${.SHELLSTATUS} == 0, there is no difference (${DEFINE_DIFF} may contain other, extraneous, text)
# * if ${.SHELLSTATUS} == 1, then ${DEFINE_DIFF} contains the difference text
$(call %debug_var,.SHELLSTATUS)
ifeq (${.SHELLSTATUS},0)
DEFINE_DIFF := $()
else
DEFINE_DIFFERS := ${true}
endif
$(call %debug_var,DEFINE_EXT)
$(call %debug_var,DEFINE_EXISTS)
$(call %debug_var,DEFINE_DIFF)
$(call %debug_var,DEFINE_DIFFERS)
ifeq (${true},${DEFINE_DIFFERS})
$(if $(call %rm_file,${SRC_DIR}/defines.h),$(call %info,previous (incompatible) '${SRC_DIR}/defines.h' removed.),)
endif
####
${SRC_DIR}/defines.h: ${SRC_DIR}/defines.${DEFINE_EXT} $(filter-out ${SRC_DIR}/defines.h,${DEPS_common})
@${CP} $(call %map,%shell_quote,$(call %map,%as_win_path,$< $@)) >${devnull}
@$(call %touch_shell_s,$(call %shell_quote,$@))
@${ECHO} $(call %shell_escape,$(call %info_text,created '$@' from '$<'.))
####
define @AUX_template =
$${OUT_DIR_bin}/${1}$${EXEEXT}: $${OUT_DIR_bin}/%$${EXEEXT}: $${OUT_DIR_obj}/%.$${O} $(foreach name,${AUX_adds_${1}},$${OUT_DIR_obj}/${name}.$${O}) $${DEPS_common} | $${OUT_DIR_bin}
$$(call %link,$${LDFLAGS},$$(call %shell_quote,$$@),$$(call %map,%shell_quote,$$< $(foreach name,${AUX_adds_${1}},$${OUT_DIR_obj}/${name}.$${O})),$$(call %map,%shell_quote,$$(call %filter_by_stem,$$@,$${TEST_REZ_files})),$$(call %LDX_flags,$$(if $$(call %is_gui,$$@),windows,$${SUBSYSTEM})))
$$(if $$(and $${STRIP},$$(call %is_falsey,$${DEBUG})),$${STRIP} $$(call %shell_quote,$$@),)
@$${ECHO} $$(call %shell_escape,$$(call %success_text,made '$$@'.))
endef
# $(foreach name,${AUX_names},$(call %info,$(call @AUX_template,${name})))
$(foreach name,${AUX_names},$(eval $(call @AUX_template,${name})))
####
all: aux
all_phony_targets += aux
# aux: build ${AUX_targets} ## Build auxillary executables (`lessecho` and `lesskey`)
aux: ${AUX_targets} ## Build auxillary executables (`lessecho` and `lesskey`)