Rev 1851 | Details | Compare with Previous | Last modification | View Log
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 857 | baho | 1 | # common.mk - common definitions for Makefiles. |
| 2 | # |
||
| 3 | # Supported environments: |
||
| 4 | # GNU/Linux |
||
| 930 | alone | 5 | # Microsoft Windows (partly) |
| 6 | # |
||
| 7 | # Tools used: |
||
| 8 | # GNU core utilities |
||
| 9 | # tools/aspp |
||
| 10 | # tools/sjasmplus |
||
| 11 | # tools/dmimg |
||
| 12 | # |
||
| 13 | # Variables used: |
||
| 14 | # WINTOP - project's base path |
||
| 15 | # WINSDK - project's SDK path |
||
| 16 | # INSTALLDIR - installation path |
||
| 17 | # DEPAS - "tools/aspp" name |
||
| 18 | # DEPAFLAGS - flags for ${DEPAS} |
||
| 19 | # DEPEXT - dependency file's extension (no leading dot) |
||
| 20 | # SJASMPLUS - "tools/sjasmplus" name |
||
| 21 | # SJASMPLUSFLAGS - flags for ${SJASMPLUS} |
||
| 22 | # DMIMG - "tools/dmimg" name |
||
| 578 | dimkam | 23 | |
| 930 | alone | 24 | WINTOP := $(dir $(abspath $(lastword $(MAKEFILE_LIST))../../../)) |
| 25 | WINSDK := $(dir $(WINTOP)src/_sdk/) |
||
| 26 | INSTALLDIR := $(dir $(WINTOP)release/) |
||
| 27 | BIN_INSTALLDIR = $(INSTALLDIR)/bin |
||
| 28 | RES_INSTALLDIR = $(INSTALLDIR)/bin |
||
| 29 | DOC_INSTALLDIR = $(INSTALLDIR)/doc |
||
| 30 | DEPAS = $(WINTOP)tools/aspp |
||
| 31 | DEPAFLAGS = -E -MM -I . -I $(WINSDK) |
||
| 32 | DEPEXT = d |
||
| 1674 | dimkam | 33 | SVNREVISION := $(firstword $(subst :, ,$(shell svnversion -n))) |
| 1750 | kulich | 34 | SVNREVISION := $(subst M,,${SVNREVISION}) |
| 35 | SVNREVISION := $(subst P,,${SVNREVISION}) |
||
| 36 | SVNREVISION := $(subst S,,${SVNREVISION}) |
||
| 37 | SVNREVISION := $(subst Unversioned,0,${SVNREVISION}) |
||
| 930 | alone | 38 | SJASMPLUS = $(WINTOP)tools/sjasmplus |
| 1851 | lvd | 39 | SJASMPLUSFLAGS = --nologo --lst --msg=war -DSVNREVISION=${SVNREVISION} |
| 930 | alone | 40 | DMIMG = $(WINTOP)tools/dmimg |
| 41 | EMULIMG = $(WINTOP)us/sd_nedo.vhd |
||
| 578 | dimkam | 42 | |
| 43 | ifeq ($(OS),Windows_NT) |
||
| 930 | alone | 44 | ISWIN = 1 |
| 45 | # DEPAS = "$(WINTOP)tools/parsasm.bat" |
||
| 46 | RM = @del /Q |
||
| 47 | COPY = @copy /Y |
||
| 48 | MKDIR = @mkdir |
||
| 49 | MOVE = @move |
||
| 50 | IMGUNPACK = $(WINTOP)tools/images.exe |
||
| 578 | dimkam | 51 | else |
| 930 | alone | 52 | MKDIR = @mkdir -p |
| 53 | MOVE = @mv |
||
| 54 | # DEL = @rm -f |
||
| 55 | COPY = cp |
||
| 56 | # BINEXT = |
||
| 57 | endif |
||
| 578 | dimkam | 58 | |
| 930 | alone | 59 | # Clear lists |
| 60 | DEPS= |
||
| 480 | baho | 61 | |
| 930 | alone | 62 | # sjasmplus_rule - rule to compile assembler source file using tools ${DEPAS} and ${SJASMPLUS} |
| 63 | # |
||
| 64 | # Parameters: |
||
| 65 | # ${1} = output file(s) |
||
| 66 | # ${2} = single input file |
||
| 67 | # ${3} = extra parameters for "sjasmplus" |
||
| 68 | # ${4} = variable's name for output dependencies files list (or empty) |
||
| 69 | # ${5} = variable's name for output binaries files list (or empty) |
||
| 70 | # |
||
| 71 | # Usage: |
||
| 72 | # ${eval ${call sjasmplus_rule,${RELEASE}/program.com ${RELEASE}/intro.com,main.asm,,DEPS,BINS}} |
||
| 480 | baho | 73 | |
| 930 | alone | 74 | define sjasmplus_rule = |
| 75 | # Dependency generation rule for .asm file: |
||
| 76 | ${patsubst %${suffix ${2}},%.d,${2}}: ${2} |
||
| 77 | $${RM} $$@ && $${DEPAS} $${DEPAFLAGS} ${addprefix -MT ,${1}} -MT $$@ -MF $$@ $$< |
||
| 78 | ${1}: ${2} |
||
| 79 | $${SJASMPLUS} $${SJASMPLUSFLAGS} ${3} $$< --raw=$$@ |
||
| 80 | ifneq "${4}" "" |
||
| 81 | ${4}+=${patsubst %${suffix ${2}},%.d,${2}} |
||
| 480 | baho | 82 | endif |
| 930 | alone | 83 | ifneq "${5}" "" |
| 84 | ${5}+=${1} |
||
| 85 | endif |
||
| 86 | endef |
||
| 480 | baho | 87 | |
| 930 | alone | 88 | # sjasmplus_odd_rule - rule to compile assembler source file using tools ${DEPAS} and ${SJASMPLUS} |
| 89 | # |
||
| 90 | # Parameters: |
||
| 91 | # ${1} = output file(s) - must be the same as specified in the source file! |
||
| 92 | # ${2} = single input file |
||
| 93 | # ${3} = extra parameters |
||
| 94 | # ${4} = variable's name for output dependencies files list (or empty) |
||
| 95 | # ${5} = variable's name for output binaries files list (or empty) |
||
| 96 | # |
||
| 97 | # Usage: |
||
| 98 | # ${eval ${call sjasmplus_odd_rule,${RELEASE}/program.com ${RELEASE}/intro.com,main.asm,,DEPS,BINS}} |
||
| 480 | baho | 99 | |
| 930 | alone | 100 | define sjasmplus_odd_rule = |
| 101 | # Dependency generation rule for .asm file: |
||
| 102 | # FIXME: No output file specified here (we must check sources manually): |
||
| 103 | ${patsubst %${suffix ${2}},%.d,${2}}: ${2} |
||
| 104 | $${RM} $$@ && $${DEPAS} $${DEPAFLAGS} ${addprefix -MT ,${1}} -MT $$@ -MF $$@ $$< |
||
| 105 | ${1}: ${2} |
||
| 1865 | lvd | 106 | $${SJASMPLUS} $${SJASMPLUSFLAGS} ${SJASMOPTS} ${3} $$< |
| 930 | alone | 107 | ifneq "${4}" "" |
| 108 | ${4}+=${patsubst %${suffix ${2}},%.d,${2}} |
||
| 109 | endif |
||
| 110 | ifneq "${5}" "" |
||
| 111 | ${5}+=${1} |
||
| 112 | endif |
||
| 113 | endef |
||
| 480 | baho | 114 | |
| 930 | alone | 115 | # copy_file_rule - rule to copy single file |
| 116 | # |
||
| 117 | # Parameters: |
||
| 118 | # ${1} = single output file |
||
| 119 | # ${2} = single input file |
||
| 120 | # ${3} = variable's name for output files list (or empty) |
||
| 121 | # |
||
| 122 | # Usage: |
||
| 123 | # ${eval ${call copy_file_rule,${RELEASE}/program.spr,sprites.bin,ALL_BINS}} |
||
| 480 | baho | 124 | |
| 930 | alone | 125 | define copy_file_rule = |
| 126 | ${1}: ${2} |
||
| 127 | $(MKDIR) $${@D} |
||
| 128 | $(COPY) $$< $$@ |
||
| 129 | ifneq "${3}" "" |
||
| 130 | ${3}+=${1} |
||
| 131 | endif |
||
| 132 | endef |
||
| 922 | baho | 133 | |
| 930 | alone | 134 | # copy_to_dir_rule - rule to copy file(s) to a directory |
| 135 | # |
||
| 136 | # Parameters: |
||
| 137 | # ${1} = output directory (no trailing '/') |
||
| 138 | # ${2} = input file(s) |
||
| 139 | # ${3} = variable's name for output files list (or empty) |
||
| 140 | # |
||
| 141 | # Usage: |
||
| 142 | # ${eval ${call copy_to_dir_rule,${RELEASE}/data,gfx.bin music.bin,ALL_BINS}} |
||
| 922 | baho | 143 | |
| 930 | alone | 144 | define copy_to_dir_rule = |
| 145 | ${foreach f,${2},${eval ${call copy_file_rule,${1}/${notdir ${f}},${f},${3}}}} |
||
| 146 | endef |