Subversion Repositories Kolibri OS

Rev

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

Rev 1744 Rev 1820
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
	fasm -m 65536 $$< "$$@" -s .deps/$(4).fas
31
	fasm -m 65536 $$< "$$@" -s .deps/$(4).fas
32
	prepsrc .deps/$(4).fas /dev/null
32
	prepsrc .deps/$(4).fas /dev/null
33
	prepsrc .deps/$(4).fas /dev/stdout | (echo -n '$(1):' && \
33
	prepsrc .deps/$(4).fas /dev/stdout | \
34
	perl -ne 's|\\|/|g;print " \\\n $$$$1" if /^;include \x27(.*?)\x27/' \
34
	perl -n -e 's|\\|/|g;push @a,$$$$1 if/^;include \x27(.*?)\x27/;' \
35
	&& echo) > .deps/$(4).Po
35
	-e 'END{$$$$a=join " \\\n ",@a;print "$(1): $$$$a\n$$$$a:\n"}' > .deps/$(4).Po
36
	kpack --nologo "$$@"
36
	kpack --nologo "$$@"
37
-include .deps/$(4).Po
37
-include .deps/$(4).Po
38
endef
38
endef
39
 
39
 
40
progname=$(call respace,$(basename $(notdir $(call binarypart,$(f)))))
40
progname=$(call respace,$(basename $(notdir $(call binarypart,$(f)))))
41
binarydir=$(subst ./,,$(dir $(call binarypart,$(f))))
41
binarydir=$(subst ./,,$(dir $(call binarypart,$(f))))
42
$(foreach f,$(FASM_PROGRAMS),$(eval $(call fasm_meta_rule,$(fbinary),$(fsource),$(binarydir),$(progname))))
42
$(foreach f,$(FASM_PROGRAMS),$(eval $(call fasm_meta_rule,$(fbinary),$(fsource),$(binarydir),$(progname))))
43
 
43
 
44
# Rule for the kernel differs: it uses kerpack instead of kpack.
44
# Rule for the kernel differs: it uses kerpack instead of kpack.
45
kernel.mnt: $(KERNEL)/kernel.asm Makefile.fasm .deps/.dir
45
kernel.mnt: $(KERNEL)/kernel.asm Makefile.fasm .deps/.dir
46
	fasm -m 65536 $< "$@" -s .deps/kernel.fas
46
	fasm -m 65536 $< "$@" -s .deps/kernel.fas
47
	prepsrc .deps/kernel.fas /dev/null
47
	prepsrc .deps/kernel.fas /dev/null
48
	prepsrc .deps/kernel.fas /dev/stdout | (echo -n 'kernel.mnt:' && \
48
	prepsrc .deps/kernel.fas /dev/stdout | \
49
	perl -ne 's|\\|/|g;print " \\\n $$1" if /^;include \x27(.*?)\x27/' \
49
	perl -n -e 's|\\|/|g;push @a,$$1 if/^;include \x27(.*?)\x27/;' \
50
	&& echo) > .deps/kernel.Po
50
	-e 'END{$$a=join " \\\n ",@a;print "$@: $$a\n$$a:\n"}' > .deps/kernel.Po
51
	kerpack $@
51
	kerpack $@
52
-include .deps/kernel.Po
52
-include .deps/kernel.Po