summaryrefslogtreecommitdiff
path: root/packages/libogcfpc/examples/template/Makefile.fpc
blob: 01efa08dfeca1ecfcb6a4b36533311425fa23d04 (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
#
#   Makefile.fpc for Free Pascal libogcfpc 2.x.y Examples
#

[target]
loaders= 
programs=template

[require]
packages=libogcfpc
tools=bin2s rmdir gxtexconv
nortl=y

[install]
fpcpackage=y

[default]
cpu=powerpc
target=wii
fpcdir=../../../..

[compiler]
options=-g -Xm  

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

[prerules]
BUILD = build
INC = inc
DATA = data
TEXTURES = textures
TPL_FILES = $(foreach dir,textures,$(notdir $(wildcard $(dir)/*.scf)))
BIN_FILES = $(foreach dir,data,$(notdir $(wildcard $(dir)/*)))

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

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

#
# Textures processing rule
#
$(TPL_FILES): $(wildcard %.scf) 
        @echo 'Creating tpl file...'
        $(GXTEXCONV) -s textures/$(@) -o $(DATA)/$(basename $(@)).tpl

	
#
# Binary files processing rule
# 
$(BIN_FILES): $(wildcard %.*)
        @echo 'Converting $(@) file to asm...'
        @$(BIN2S) -a 32 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!'