Subversion Repositories Kolibri OS

Rev

Rev 3554 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3554 Rev 4630
1
# This is not a independent Makefile; it is auxiliary file
1
# This is not a independent Makefile; it is auxiliary file
2
# included from main Makefile.
2
# included from main Makefile.
3
# It depends on the following variables and macro:
3
# It depends on the following variables and macro:
4
# $(FASM_PROGRAMS) is a list of all programs to build with FASM rule;
4
# $(FASM_PROGRAMS) is a list of all programs to build with FASM rule;
5
# $(binarypart) is a macro which converts from $(1)=item of $(FASM_PROGRAMS)
5
# $(binarypart) is a macro which converts from $(1)=item of $(FASM_PROGRAMS)
6
# to space-escaped full name of binary, $(respace) unescapes spaces;
6
# to space-escaped full name of binary, $(respace) unescapes spaces;
7
# $(fbinary) and $(fsource) gives space-unescaped full name of binary
7
# $(fbinary) and $(fsource) gives space-unescaped full name of binary
8
# and source (respectively) of $(f)=item of $(FASM_PROGRAMS).
8
# and source (respectively) of $(f)=item of $(FASM_PROGRAMS).
9
 
9
 
10
# Define the rule for all FASM programs.
10
# Define the rule for all FASM programs.
11
# Yes, this looks like a black magic.
11
# Yes, this looks like a black magic.
12
# But it is not so scary as it seems.
12
# But it is not so scary as it seems.
13
# First, we define "meta-rule" as a rule which is
13
# First, we define "meta-rule" as a rule which is
14
# macro depending on $(fasmprog).
14
# macro depending on $(fasmprog).
15
# Second, the construction foreach+eval creates
15
# Second, the construction foreach+eval creates
16
# usual rules, one for each $(fasmprog) in $(FASM_PROGRAMS).
16
# usual rules, one for each $(fasmprog) in $(FASM_PROGRAMS).
17
# Note that meta-rule is double-expanded, first
17
# Note that meta-rule is double-expanded, first
18
# time as the arg of eval - it is the place where $(fasmprog)
18
# time as the arg of eval - it is the place where $(fasmprog)
19
# gets expanded - and second time as the rule;
19
# gets expanded - and second time as the rule;
20
# so all $ which are expected to expand at the second time should be escaped.
20
# so all $ which are expected to expand at the second time should be escaped.
21
# And all $ which are expected to be expanded by the shell should be escaped
21
# And all $ which are expected to be expanded by the shell should be escaped
22
# twice, so they become $$$$.
22
# twice, so they become $$$$.
23
 
23
 
24
# The arguments of macro fasm_meta_rule:
24
# The arguments of macro fasm_meta_rule:
25
# $(1) = name of binary file,
25
# $(1) = name of binary file,
26
# $(2) = name of main source file.
26
# $(2) = name of main source file.
27
# $(3) = folder of binary file - without spaces.
27
# $(3) = folder of binary file - without spaces.
28
# $(4) = name of program - without path and extension,
28
# $(4) = name of program - without path and extension,
29
define fasm_meta_rule
29
define fasm_meta_rule
30
$(1): $(2) Makefile.fasm .deps/.dir $$(call respace,$$(addsuffix .dir,$(3)))
30
$(1): $(2) Makefile.fasm .deps/.dir $$(call respace,$$(addsuffix .dir,$(3)))
31
	tmpfile=`mktemp --tmpdir build.XXXXXXXX` && \
31
	tmpfile=`mktemp --tmpdir build.XXXXXXXX` && \
32
	(fasm -m 65536 "$$<" "$$@" -s $$$$tmpfile && \
32
	(fasm -m 65536 "$$<" "$$@" -s $$$$tmpfile && \
33
	fasmdep -e $$$$tmpfile > .deps/$(4).Po && \
33
	fasmdep -e $$$$tmpfile > .deps/$(4).Po && \
34
	rm $$$$tmpfile) || (rm $$$$tmpfile; false)
34
	rm $$$$tmpfile) || (rm $$$$tmpfile; false)
35
	kpack --nologo "$$@"
35
	kpack --nologo "$$@"
36
-include .deps/$(4).Po
36
-include .deps/$(4).Po
37
endef
37
endef
38
 
38
 
39
define fasm_nokpack_meta_rule
39
define fasm_nokpack_meta_rule
40
$(1): $(2) Makefile.fasm .deps/.dir $$(call respace,$$(addsuffix .dir,$(3)))
40
$(1): $(2) Makefile.fasm .deps/.dir $$(call respace,$$(addsuffix .dir,$(3)))
41
	tmpfile=`mktemp --tmpdir build.XXXXXXXX` && \
41
	tmpfile=`mktemp --tmpdir build.XXXXXXXX` && \
42
	(fasm -m 65536 "$$<" "$$@" -s $$$$tmpfile && \
42
	(fasm -m 65536 "$$<" "$$@" -s $$$$tmpfile && \
43
	fasmdep -e $$$$tmpfile > .deps/$(4).Po && \
43
	fasmdep -e $$$$tmpfile > .deps/$(4).Po && \
44
	rm $$$$tmpfile) || (rm $$$$tmpfile; false)
44
	rm $$$$tmpfile) || (rm $$$$tmpfile; false)
45
-include .deps/$(4).Po
45
-include .deps/$(4).Po
46
endef
46
endef
47
 
47
 
48
progname=$(call respace,$(basename $(notdir $(call binarypart,$(f)))))
48
progname=$(call respace,$(basename $(notdir $(call binarypart,$(f)))))
49
binarydir=$(subst ./,,$(dir $(call binarypart,$(f))))
49
binarydir=$(subst ./,,$(dir $(call binarypart,$(f))))
50
$(foreach f,$(FASM_PROGRAMS) $(FASM_PROGRAMS_CD) $(SKIN_SOURCES),$(eval $(call fasm_meta_rule,$(fbinary),$(fsource),$(binarydir),$(progname))))
50
$(foreach f,$(FASM_PROGRAMS) $(FASM_PROGRAMS_CD) $(SKIN_SOURCES),$(eval $(call fasm_meta_rule,$(fbinary),$(fsource),$(binarydir),$(progname))))
51
$(foreach f,$(FASM_NOKPACK_PROGRAMS),$(eval $(call fasm_nokpack_meta_rule,$(fbinary),$(fsource),$(binarydir),$(progname))))
51
$(foreach f,$(FASM_NOKPACK_PROGRAMS),$(eval $(call fasm_nokpack_meta_rule,$(fbinary),$(fsource),$(binarydir),$(progname))))
52
 
52
 
53
# Rule for the kernel differs: it uses kerpack instead of kpack.
53
# Rule for the kernel differs: it uses kerpack instead of kpack.
54
kernel.mnt: $(KERNEL)/kernel.asm Makefile.fasm .deps/.dir
54
kernel.mnt: $(KERNEL)/kernel.asm Makefile.fasm .deps/.dir
55
	tmpfile=`mktemp --tmpdir build.XXXXXXXX` && \
55
	tmpfile=`mktemp --tmpdir build.XXXXXXXX` && \
56
	(fasm -m 131072 "$<" "$@" -s $$tmpfile && \
56
	(fasm -m 131072 "$<" "$@" -s $$tmpfile && \
57
	fasmdep -e $$tmpfile > .deps/kernel.Po && \
57
	fasmdep -e $$tmpfile > .deps/kernel.Po && \
58
	rm $$tmpfile) || (rm $$tmpfile; false)
58
	rm $$tmpfile) || (rm $$tmpfile; false)
59
	kerpack "$@"
59
	kerpack "$@"
60
-include .deps/kernel.Po
60
-include .deps/kernel.Po
-
 
61