From 8340767676cb7c5fd8cba0fcc3dfaa5301c6b5ef Mon Sep 17 00:00:00 2001 From: CleverMouse Date: Tue, 18 Jan 2011 15:21:25 +0000 Subject: [PATCH] Makefile: separate fasm rule from programs list to avoid unnecessary rebuilds git-svn-id: svn://kolibrios.org@1744 a494cfbc-eb01-0410-851d-a64ba20cac60 --- data/eng/Makefile | 45 ++---------------------------------- data/eng/Makefile.fasm | 52 ++++++++++++++++++++++++++++++++++++++++++ data/rus/Makefile | 45 ++---------------------------------- data/rus/Makefile.fasm | 52 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 108 insertions(+), 86 deletions(-) create mode 100644 data/eng/Makefile.fasm create mode 100644 data/rus/Makefile.fasm diff --git a/data/eng/Makefile b/data/eng/Makefile index 1d9f804865..3495d5df2d 100644 --- a/data/eng/Makefile +++ b/data/eng/Makefile @@ -310,49 +310,8 @@ File\ Managers/.dir: mkdir -p "File Managers" touch "File Managers/.dir" -# 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 .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 | (echo -n '$(1):' && \ - perl -ne 's|\\|/|g;print " \\\n $$$$1" if /^;include \x27(.*?)\x27/' \ - && echo) > .deps/$(4).Po - kpack --nologo "$$@" --include .deps/$(4).Po -endef - -progname=$(call respace,$(basename $(notdir $(call binarypart,$(f))))) -binarydir=$(subst ./,,$(dir $(call binarypart,$(f)))) -$(foreach f,$(FASM_PROGRAMS),$(eval $(call fasm_meta_rule,$(fbinary),$(fsource),$(binarydir),$(progname)))) - -# Rule for the kernel differs: it uses kerpack instead of kpack. -kernel.mnt: $(KERNEL)/kernel.asm Makefile .deps/.dir - fasm -m 65536 $< "$@" -s .deps/kernel.fas - prepsrc .deps/kernel.fas /dev/null - prepsrc .deps/kernel.fas /dev/stdout | (echo -n 'kernel.mnt:' && \ - perl -ne 's|\\|/|g;print " \\\n $$1" if /^;include \x27(.*?)\x27/' \ - && echo) > .deps/kernel.Po - kerpack $@ --include .deps/kernel.Po +# FASM black magic goes to Makefile.fasm. +include Makefile.fasm # Rule for copying files is simpler, but similar to previous. define copy_meta_rule diff --git a/data/eng/Makefile.fasm b/data/eng/Makefile.fasm new file mode 100644 index 0000000000..ee7433459c --- /dev/null +++ b/data/eng/Makefile.fasm @@ -0,0 +1,52 @@ +# 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))) + fasm -m 65536 $$< "$$@" -s .deps/$(4).fas + prepsrc .deps/$(4).fas /dev/null + prepsrc .deps/$(4).fas /dev/stdout | (echo -n '$(1):' && \ + perl -ne 's|\\|/|g;print " \\\n $$$$1" if /^;include \x27(.*?)\x27/' \ + && echo) > .deps/$(4).Po + kpack --nologo "$$@" +-include .deps/$(4).Po +endef + +progname=$(call respace,$(basename $(notdir $(call binarypart,$(f))))) +binarydir=$(subst ./,,$(dir $(call binarypart,$(f)))) +$(foreach f,$(FASM_PROGRAMS),$(eval $(call fasm_meta_rule,$(fbinary),$(fsource),$(binarydir),$(progname)))) + +# Rule for the kernel differs: it uses kerpack instead of kpack. +kernel.mnt: $(KERNEL)/kernel.asm Makefile.fasm .deps/.dir + fasm -m 65536 $< "$@" -s .deps/kernel.fas + prepsrc .deps/kernel.fas /dev/null + prepsrc .deps/kernel.fas /dev/stdout | (echo -n 'kernel.mnt:' && \ + perl -ne 's|\\|/|g;print " \\\n $$1" if /^;include \x27(.*?)\x27/' \ + && echo) > .deps/kernel.Po + kerpack $@ +-include .deps/kernel.Po diff --git a/data/rus/Makefile b/data/rus/Makefile index c77ee08426..fbdf6c1873 100644 --- a/data/rus/Makefile +++ b/data/rus/Makefile @@ -311,49 +311,8 @@ File\ Managers/.dir: mkdir -p "File Managers" touch "File Managers/.dir" -# 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 .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 | (echo -n '$(1):' && \ - perl -ne 's|\\|/|g;print " \\\n $$$$1" if /^;include \x27(.*?)\x27/' \ - && echo) > .deps/$(4).Po - kpack --nologo "$$@" --include .deps/$(4).Po -endef - -progname=$(call respace,$(basename $(notdir $(call binarypart,$(f))))) -binarydir=$(subst ./,,$(dir $(call binarypart,$(f)))) -$(foreach f,$(FASM_PROGRAMS),$(eval $(call fasm_meta_rule,$(fbinary),$(fsource),$(binarydir),$(progname)))) - -# Rule for the kernel differs: it uses kerpack instead of kpack. -kernel.mnt: $(KERNEL)/kernel.asm Makefile .deps/.dir - fasm -m 65536 $< "$@" -s .deps/kernel.fas - prepsrc .deps/kernel.fas /dev/null - prepsrc .deps/kernel.fas /dev/stdout | (echo -n 'kernel.mnt:' && \ - perl -ne 's|\\|/|g;print " \\\n $$1" if /^;include \x27(.*?)\x27/' \ - && echo) > .deps/kernel.Po - kerpack $@ --include .deps/kernel.Po +# FASM black magic goes to Makefile.fasm. +include Makefile.fasm # Rule for copying files is simpler, but similar to previous. define copy_meta_rule diff --git a/data/rus/Makefile.fasm b/data/rus/Makefile.fasm new file mode 100644 index 0000000000..ee7433459c --- /dev/null +++ b/data/rus/Makefile.fasm @@ -0,0 +1,52 @@ +# 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))) + fasm -m 65536 $$< "$$@" -s .deps/$(4).fas + prepsrc .deps/$(4).fas /dev/null + prepsrc .deps/$(4).fas /dev/stdout | (echo -n '$(1):' && \ + perl -ne 's|\\|/|g;print " \\\n $$$$1" if /^;include \x27(.*?)\x27/' \ + && echo) > .deps/$(4).Po + kpack --nologo "$$@" +-include .deps/$(4).Po +endef + +progname=$(call respace,$(basename $(notdir $(call binarypart,$(f))))) +binarydir=$(subst ./,,$(dir $(call binarypart,$(f)))) +$(foreach f,$(FASM_PROGRAMS),$(eval $(call fasm_meta_rule,$(fbinary),$(fsource),$(binarydir),$(progname)))) + +# Rule for the kernel differs: it uses kerpack instead of kpack. +kernel.mnt: $(KERNEL)/kernel.asm Makefile.fasm .deps/.dir + fasm -m 65536 $< "$@" -s .deps/kernel.fas + prepsrc .deps/kernel.fas /dev/null + prepsrc .deps/kernel.fas /dev/stdout | (echo -n 'kernel.mnt:' && \ + perl -ne 's|\\|/|g;print " \\\n $$1" if /^;include \x27(.*?)\x27/' \ + && echo) > .deps/kernel.Po + kerpack $@ +-include .deps/kernel.Po