summaryrefslogtreecommitdiff
path: root/packages/libndsfpc/examples/graphics/3D/Simple_Tri/Makefile.fpc
blob: c0fdf6eb8bce5ddf99277239b13e198896f22f48 (plain)
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#
#   Makefile.fpc for Free Pascal libndsfpc 2.x.y Examples
#

[target]
loaders= 
programs=SimpleTri

[require]
packages=libndsfpc
tools=bin2s mmutil grit_fpc rmdir mv ndstool
nortl=y

[install]
fpcpackage=y

[default]
cpu=arm
target=nds
fpcdir=../../../../../..

[compiler]
options=-Xm
targetdir=$(BIN)  
unittargetdir=$(BUILD)

[clean]
files=*.elf *.o *.s *.nds *.nef *.h *.bin *.map \
       $(BUILD)/* \
       $(INC)/* \
       $(BIN)/*
units=*


[prerules]
BIN = bin
BUILD = build
DATA = data
FILESYSTEM = filesystem
GFX = gfx
INC = inc
AUDIO_FILES = $(foreach dir, $(notdir $(wildcard audio/*.*)), $(CURDIR)/audio/$(dir))
GFX_FILES   = $(foreach dir, $(GFX), $(notdir $(wildcard $(dir)/*.bmp $(dir)/*.png)))
BIN_FILES   = $(foreach dir, $(DATA), $(notdir $(wildcard $(dir)/*)))
GBFS_FILES  = $(foreach dir, GBFS, $(notdir $(wildcard $(dir)/*)))

[rules]
.NOTPARALLEL:
clean: dir_delete fpc_clean fpc_cleanall
all: dir_make $(BIN_FILES) $(GFX_FILES) fpc_all 
filesystem: all make_filesystem



#
# Delete temp directories
#
dir_delete:
        @$(DELTREE) $(CURDIR)/$(BUILD) 
        @$(DELTREE) $(CURDIR)/$(INC) 
        @$(DELTREE) $(CURDIR)/$(BIN) 
                
#
# Create temp directories
#
dir_make:
ifneq ($(BUILD), $(CURDIR))
        @$(MKDIR) $(BUILD)
endif
ifneq ($(INC), $(CURDIR))
        @$(MKDIR) $(INC)
endif
ifneq ($(BIN), $(CURDIR))
        @$(MKDIR) $(BIN)
endif

#
# Audio files processing rule
#
soundbank.bin.o : $(AUDIO_FILES)
        @$(MMUTIL) $^ -d -o$(BUILD)/soundbank.bin -h$(BUILD)/soundbank.h
        $(BIN2S) $(BUILD)/soundbank.bin > $(BUILD)/soundbank.bin.s
        $(AS) -o $(BUILD)/soundbank.bin.o $(BUILD)/soundbank.bin.s

#
# Png files processing rule
#
$(GFX_FILES): $(wildcard %.bmp %.png)
        @echo 'Converting $(@) file to asm...'
        $(GRIT) $(GFX)/$(@) -fp -fts -ff $(GFX)/$(basename $(@)).grit -o$(BUILD)/$(@)
        @echo 'Assembling $(@).s file...'
        $(AS) -o $(BUILD)/$(basename $(@)).o $(BUILD)/$(basename $(@)).s
        $(MV) -f $(BUILD)/$(basename $(@)).inc $(INC)/$(basename $(@)).inc           
        @echo 'Done!'

#
# Binary files processing rule
# 
$(BIN_FILES): $(wildcard %.*)
        @echo 'Converting $(@) file to asm...'
        @$(BIN2S) $(DATA)/$(@) > $(BUILD)/$(@).s
        @echo 'Creating $(@).inc include file...'
        @echo "var" > `(echo "$(INC)/"$(@F) | tr . .)`.inc
        @echo " " `(echo $(@F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end: array [0..0] of cuint8; cvar; external;" >> `(echo "$(INC)/"$(@F) | tr . .)`.inc
        @echo " " `(echo $(@F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`": array [0..0] of cuint8; cvar; external;" >> `(echo "$(INC)/"$(@F) | tr . .)`.inc
        @echo " " `(echo $(@F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size": cuint32; cvar; external;" >> `(echo "$(INC)/"$(@F) | tr . .)`.inc
        @echo 'Assembling $(@).s file...'
        @$(AS) -o $(BUILD)/$(@).o $(BUILD)/$(@).s
        @echo 'Done!'


#
# GBFS files processing rule
#
data.gbfs.o:
        @cd GBFS && gbfs ../$(BUILD)/data.gbfs $(GBFS_FILES)
        $(BIN2S) $(BUILD)/data.gbfs > $(BUILD)/data.gbfs.s
        $(AS) -o $(BUILD)/data.gbfs.o $(BUILD)/data.gbfs.s

#
# Nitro Filesystem processing rule
# 
make_filesystem:
	@$(NDSTOOL) -c $(BIN)/$(TARGET_PROGRAMS).fs.nds -9 $(BIN)/$(TARGET_PROGRAMS).nef.bin -d $(CURDIR)/$(FILESYSTEM)