Rev 1743 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1743 | Rev 1744 | ||
---|---|---|---|
Line 309... | Line 309... | ||
309 | touch $@ |
309 | touch $@ |
310 | File\ Managers/.dir: |
310 | File\ Managers/.dir: |
311 | mkdir -p "File Managers" |
311 | mkdir -p "File Managers" |
312 | touch "File Managers/.dir" |
312 | touch "File Managers/.dir" |
Line 313... | Line -... | ||
313 | - | ||
314 | # Define the rule for all FASM programs. |
- | |
315 | # Yes, this looks like a black magic. |
- | |
316 | # But it is not so scary as it seems. |
- | |
317 | # First, we define "meta-rule" as a rule which is |
- | |
318 | # macro depending on $(fasmprog). |
- | |
319 | # Second, the construction foreach+eval creates |
- | |
320 | # usual rules, one for each $(fasmprog) in $(FASM_PROGRAMS). |
- | |
321 | # Note that meta-rule is double-expanded, first |
- | |
322 | # time as the arg of eval - it is the place where $(fasmprog) |
- | |
323 | # gets expanded - and second time as the rule; |
- | |
324 | # so all $ which are expected to expand at the second time should be escaped. |
- | |
325 | # And all $ which are expected to be expanded by the shell should be escaped |
- | |
326 | # twice, so they become $$$$. |
- | |
327 | - | ||
328 | # The arguments of macro fasm_meta_rule: |
- | |
329 | # $(1) = name of binary file, |
313 | |
330 | # $(2) = name of main source file. |
- | |
331 | # $(3) = folder of binary file - without spaces. |
- | |
332 | # $(4) = name of program - without path and extension, |
- | |
333 | define fasm_meta_rule |
- | |
334 | $(1): $(2) Makefile .deps/.dir $$(call respace,$$(addsuffix .dir,$(3))) |
- | |
335 | fasm -m 65536 $$< "$$@" -s .deps/$(4).fas |
- | |
336 | prepsrc .deps/$(4).fas /dev/null |
- | |
337 | prepsrc .deps/$(4).fas /dev/stdout | (echo -n '$(1):' && \ |
- | |
338 | perl -ne 's|\\|/|g;print " \\\n $$$$1" if /^;include \x27(.*?)\x27/' \ |
- | |
339 | && echo) > .deps/$(4).Po |
- | |
340 | kpack --nologo "$$@" |
314 | # FASM black magic goes to Makefile.fasm. |
341 | -include .deps/$(4).Po |
- | |
342 | endef |
- | |
343 | - | ||
344 | progname=$(call respace,$(basename $(notdir $(call binarypart,$(f))))) |
- | |
345 | binarydir=$(subst ./,,$(dir $(call binarypart,$(f)))) |
- | |
346 | $(foreach f,$(FASM_PROGRAMS),$(eval $(call fasm_meta_rule,$(fbinary),$(fsource),$(binarydir),$(progname)))) |
- | |
347 | - | ||
348 | # Rule for the kernel differs: it uses kerpack instead of kpack. |
- | |
349 | kernel.mnt: $(KERNEL)/kernel.asm Makefile .deps/.dir |
- | |
350 | fasm -m 65536 $< "$@" -s .deps/kernel.fas |
- | |
351 | prepsrc .deps/kernel.fas /dev/null |
- | |
352 | prepsrc .deps/kernel.fas /dev/stdout | (echo -n 'kernel.mnt:' && \ |
- | |
353 | perl -ne 's|\\|/|g;print " \\\n $$1" if /^;include \x27(.*?)\x27/' \ |
- | |
354 | && echo) > .deps/kernel.Po |
- | |
355 | kerpack $@ |
- | |
Line 356... | Line 315... | ||
356 | -include .deps/kernel.Po |
315 | include Makefile.fasm |
357 | 316 | ||
358 | # Rule for copying files is simpler, but similar to previous. |
317 | # Rule for copying files is simpler, but similar to previous. |
359 | define copy_meta_rule |
318 | define copy_meta_rule |