Subversion Repositories Kolibri OS

Rev

Rev 5047 | Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

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