Subversion Repositories NedoOS

Rev

Rev 922 | Details | Compare with Previous | Last modification | View Log

Rev Author Line No. Line
930 alone 1
# Supported environments:
2
#   GNU/Linux.
3
#
4
# Tools used:
5
#   GNU core utilities, tools/aspp, tools/sjasmplus, _sdk/nedores.bin.
6
 
7
include ../../_sdk/common.mk
8
 
9
NAME		= tank.com
10
OBJECTS		=
11
SOURCES		= main.asm
12
SPRITES		= sprset.bmp tileset.bmp
13
RESOURCES	=
14
DOCS		=
15
INSTALLDIR	?= ../../../release/nedogame
16
BIN_INSTALLDIR	= ${INSTALLDIR}
17
RES_INSTALLDIR	= ${INSTALLDIR}
18
DOC_INSTALLDIR	= ${INSTALLDIR}/doc
19
NEDORES		= ../../_sdk/nedores.bin
20
 
21
# All targets
22
TARGETS=executables resources
23
.PHONY: empty ${foreach t,${TARGETS},${t} install-${t} clean-${t}} all install install-doc clean
24
 
25
.DEFAULT_GOAL=all
26
 
27
empty:
28
	@echo 'Usage: make [ TARGET | ACTION-TARGET | all | install | install-doc | clean ]'
29
	@echo 'where ACTION is one of: install clean'
30
	@echo '      TARGET is one of: ${TARGETS}'
31
 
32
# Clear lists
33
DEPS=
34
 
35
# Create directories
36
${sort \
37
${BIN_INSTALLDIR} \
38
${RES_INSTALLDIR} \
39
${DOC_INSTALLDIR} \
40
}:
41
	mkdir -p $@
42
 
43
##########################
44
## Target "executables" ##
45
##########################
46
 
47
EXEC_DEPS=
48
EXEC_ASTS=
49
EXEC_BINS=
50
 
51
define nedores_rule =
52
# File order does matter!
53
${1}: ${2} ${3}
54
	${NEDORES} $$^ $$@
55
EXEC_ASTS+=${1}
56
endef
57
 
58
${foreach f,${filter %.bmp,${SPRITES}},\
59
${eval ${call nedores_rule,${patsubst %.bmp,%.ast,${f}},${f},${patsubst %.bmp,%.da,${f}}}}}
60
 
61
${eval ${call sjasmplus_odd_rule,${NAME},${SOURCES},,EXEC_DEPS,EXEC_BINS}}
62
 
63
executables: ${EXEC_BINS}
64
 
65
install-executables: executables | ${BIN_INSTALLDIR}
66
	cp ${EXEC_BINS} $|
67
 
68
clean-executables:
69
	${RM} ${EXEC_DEPS} ${EXEC_ASTS} ${EXEC_BINS}
70
 
71
DEPS+=${EXEC_DEPS}
72
 
73
########################
74
## Target "resources" ##
75
########################
76
 
77
resources: ${RESOURCES}
78
 
79
install-resources: resources | ${RES_INSTALLDIR}
80
ifneq "${sort ${RESOURCES}}" ""
81
	cp ${RESOURCES} $|
82
endif
83
 
84
clean-resources:
85
 
86
####################
87
## Common targets ##
88
####################
89
 
90
all: executables resources
91
 
92
install: install-executables install-resources
93
 
94
ifeq "${sort ${DOCS}}" ""
95
install-doc:
96
else
97
install-doc: ${DOCS} | ${DOC_INSTALLDIR}
98
	cp $^ $|
99
endif
100
 
101
clean: clean-executables clean-resources
102
 
103
##################
104
## Dependencies ##
105
##################
106
 
107
ifneq "${sort \
108
${filter empty,${MAKECMDGOALS}} \
109
${filter clean,${MAKECMDGOALS}} \
110
${filter clean-%,${MAKECMDGOALS}} \
111
}" ""
112
else
113
# FIXME: Triggered when multiple targets specified.
114
include ${DEPS}
115
endif