2011-01-18 18:21:25 +03:00
|
|
|
# This is not a independent Makefile; it is auxiliary file
|
|
|
|
# included from main Makefile.
|
|
|
|
# It depends on the following variables and macro:
|
|
|
|
# $(FASM_PROGRAMS) is a list of all programs to build with FASM rule;
|
|
|
|
# $(binarypart) is a macro which converts from $(1)=item of $(FASM_PROGRAMS)
|
|
|
|
# to space-escaped full name of binary, $(respace) unescapes spaces;
|
|
|
|
# $(fbinary) and $(fsource) gives space-unescaped full name of binary
|
|
|
|
# and source (respectively) of $(f)=item of $(FASM_PROGRAMS).
|
|
|
|
|
|
|
|
# Define the rule for all FASM programs.
|
|
|
|
# Yes, this looks like a black magic.
|
|
|
|
# But it is not so scary as it seems.
|
|
|
|
# First, we define "meta-rule" as a rule which is
|
|
|
|
# macro depending on $(fasmprog).
|
|
|
|
# Second, the construction foreach+eval creates
|
|
|
|
# usual rules, one for each $(fasmprog) in $(FASM_PROGRAMS).
|
|
|
|
# Note that meta-rule is double-expanded, first
|
|
|
|
# time as the arg of eval - it is the place where $(fasmprog)
|
|
|
|
# gets expanded - and second time as the rule;
|
|
|
|
# so all $ which are expected to expand at the second time should be escaped.
|
|
|
|
# And all $ which are expected to be expanded by the shell should be escaped
|
|
|
|
# twice, so they become $$$$.
|
|
|
|
|
|
|
|
# The arguments of macro fasm_meta_rule:
|
|
|
|
# $(1) = name of binary file,
|
|
|
|
# $(2) = name of main source file.
|
|
|
|
# $(3) = folder of binary file - without spaces.
|
|
|
|
# $(4) = name of program - without path and extension,
|
|
|
|
define fasm_meta_rule
|
|
|
|
$(1): $(2) Makefile.fasm .deps/.dir $$(call respace,$$(addsuffix .dir,$(3)))
|
2012-06-15 15:08:31 +04:00
|
|
|
fasm -m 65536 "$$<" "$$@" -s .deps/$(4).fas
|
2011-01-18 18:21:25 +03:00
|
|
|
prepsrc .deps/$(4).fas /dev/null
|
2011-01-31 14:22:30 +03:00
|
|
|
prepsrc .deps/$(4).fas /dev/stdout | \
|
2012-02-21 13:31:37 +04:00
|
|
|
perl -n -e 's|\\|/|g;s| |\\ |g;push @a,$$$$1 if/^;include\\ \x27(.*?)\x27/;' \
|
2012-02-06 14:58:01 +04:00
|
|
|
-e 'END{$$$$a=join " \\\n ",@a;print q`$(1): `,"$$$$a\n$$$$a:\n"}' > .deps/$(4).Po
|
2011-01-18 18:21:25 +03:00
|
|
|
kpack --nologo "$$@"
|
|
|
|
-include .deps/$(4).Po
|
|
|
|
endef
|
|
|
|
|
2012-06-15 18:18:39 +04:00
|
|
|
define fasm_nokpack_meta_rule
|
|
|
|
$(1): $(2) Makefile.fasm .deps/.dir $$(call respace,$$(addsuffix .dir,$(3)))
|
|
|
|
fasm -m 65536 "$$<" "$$@" -s .deps/$(4).fas
|
|
|
|
prepsrc .deps/$(4).fas /dev/null
|
|
|
|
prepsrc .deps/$(4).fas /dev/stdout | \
|
|
|
|
perl -n -e 's|\\|/|g;s| |\\ |g;push @a,$$$$1 if/^;include\\ \x27(.*?)\x27/;' \
|
|
|
|
-e 'END{$$$$a=join " \\\n ",@a;print q`$(1): `,"$$$$a\n$$$$a:\n"}' > .deps/$(4).Po
|
|
|
|
-include .deps/$(4).Po
|
|
|
|
endef
|
|
|
|
|
2011-01-18 18:21:25 +03:00
|
|
|
progname=$(call respace,$(basename $(notdir $(call binarypart,$(f)))))
|
|
|
|
binarydir=$(subst ./,,$(dir $(call binarypart,$(f))))
|
2012-06-15 15:08:31 +04:00
|
|
|
$(foreach f,$(FASM_PROGRAMS) $(FASM_PROGRAMS_CD) $(SKIN_SOURCES),$(eval $(call fasm_meta_rule,$(fbinary),$(fsource),$(binarydir),$(progname))))
|
2012-06-15 18:18:39 +04:00
|
|
|
$(foreach f,$(FASM_NOKPACK_PROGRAMS),$(eval $(call fasm_nokpack_meta_rule,$(fbinary),$(fsource),$(binarydir),$(progname))))
|
2011-01-18 18:21:25 +03:00
|
|
|
|
|
|
|
# Rule for the kernel differs: it uses kerpack instead of kpack.
|
|
|
|
kernel.mnt: $(KERNEL)/kernel.asm Makefile.fasm .deps/.dir
|
2012-06-15 15:08:31 +04:00
|
|
|
fasm -m 65536 "$<" "$@" -s .deps/kernel.fas
|
2011-01-18 18:21:25 +03:00
|
|
|
prepsrc .deps/kernel.fas /dev/null
|
2011-01-31 14:22:30 +03:00
|
|
|
prepsrc .deps/kernel.fas /dev/stdout | \
|
2012-02-21 13:31:37 +04:00
|
|
|
perl -n -e 's|\\|/|g;s| |\\ |g;push @a,$$1 if/^;include\\ \x27(.*?)\x27/;' \
|
2011-01-31 14:22:30 +03:00
|
|
|
-e 'END{$$a=join " \\\n ",@a;print "$@: $$a\n$$a:\n"}' > .deps/kernel.Po
|
2011-01-18 18:21:25 +03:00
|
|
|
kerpack $@
|
|
|
|
-include .deps/kernel.Po
|