-
Notifications
You must be signed in to change notification settings - Fork 17
/
Makefile
90 lines (68 loc) · 2.85 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
################################################################################
#
# µCity - City building game for Game Boy Color.
# Copyright (c) 2017-2019 Antonio Niño Díaz (AntonioND/SkyLyrac)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
################################################################################
## ROM name ##
NAME := ucity
EXT := gbc
################################################################################
## Command to run resulting ROM in an emulator ##
EMULATOR := wine ./tools/bgb.exe
################################################################################
## Source, data and include folders - subfolders are included ##
SOURCE := source data
################################################################################
# RGBDS can be made to point at a specific folder with the binaries of RGBDS.
RGBASM := $(RGBDS)rgbasm
RGBLINK := $(RGBDS)rgblink
RGBFIX := $(RGBDS)rgbfix
BIN := $(NAME).$(EXT)
COMPAT_BIN := $(NAME)_compat.$(EXT)
# List of relative paths to all folders and subfolders with code or data.
SOURCE_ALL_DIRS := $(sort $(shell find $(SOURCE) -type d -print))
# All files with extension asm are assembled.
ASMFILES := $(foreach dir,$(SOURCE_ALL_DIRS),$(sort $(wildcard $(dir)/*.asm)))
# List of include directories: All source and data folders.
# A '/' is appended to the path.
INCLUDES := $(foreach dir,$(SOURCE_ALL_DIRS),-I$(dir)/)
# Prepare object paths from source files.
OBJ := $(ASMFILES:.asm=.obj)
# Targets
.PHONY : all rebuild clean run
all: $(BIN) $(COMPAT_BIN)
rebuild:
@make -B
@rm -f $(OBJ)
run: $(BIN)
$(EMULATOR) $(BIN)
clean:
@echo rm $(OBJ) $(BIN) $(COMPAT_BIN) $(NAME).sym $(NAME).map
@rm -f $(OBJ) $(BIN) $(COMPAT_BIN) $(NAME).sym $(NAME).map
%.obj : %.asm
@echo rgbasm $<
@$(RGBASM) $(INCLUDES) -E -o$@ $<
$(BIN): $(OBJ)
@echo rgblink $(BIN)
@$(RGBLINK) -o $(BIN) -p 0xFF -m $(NAME).map -n $(NAME).sym $(OBJ)
@echo rgbfix $(BIN)
@$(RGBFIX) -p 0xFF -v $(BIN)
$(COMPAT_BIN): $(BIN)
@echo rgbfix $(COMPAT_BIN)
@cp $(BIN) $(COMPAT_BIN)
@$(RGBFIX) -v -O -r 3 $(COMPAT_BIN)
################################################################################