
#	Proggies
CFLAGS = -mthrowback -Wall -mpoke-function-name -mlibscl -O2
CFLAGSV3M = $(CFLAGS) -march=armv3m -mtune=xscale

CC = gcc
LIB = libfile
ASM = gcc

#	Targets

all: a/libwoum a/libwoumv3m

#	Objects

cfiles = fixmath.o futil.o osspr.o screen.o span.o vec.o tmat.o keyboard.o timer.o tmatstack.o pqueue.o bbbsearch.o smalloc.o amdl.o nvar.o spandraw.o textbuf.o stok.o fbll.o gdll.o jprof2.o sasm.o error.o limpx.o smap.o hmap.o
asmfiles = armscreen.o cbma.o fp_math.o jprof.o jprof2asm.o sasm_s.o

cfilesv3m = $(addprefix v3m/,$(cfiles))
asmfilesv3m = $(addprefix v3m/,$(asmfiles))

#	Library files

a/libwoum: $(cfiles) $(asmfiles) 
	$(LIB) -c a.libwoum $(patsubst %.o,o.%,$(cfiles) $(asmfiles))

a/libwoumv3m: $(cfilesv3m) $(asmfilesv3m)
	$(LIB) -c a.libwoumv3m $(patsubst v3m/%.o,v3m.o.%,$(cfilesv3m) $(asmfilesv3m))

#	Object files

$(cfiles): %.o: %.c
	$(CC) -c $(CFLAGS) $< -o $@

$(asmfiles): %.o: %.s
	$(ASM) -c $(CFLAGS) $< -o $@

$(cfilesv3m): v3m/%.o: %.c
	$(CC) -c $(CFLAGSV3M) $< -o $@

$(asmfilesv3m): v3m/%.o: %.s
	$(ASM) -c $(CFLAGSV3M) $< -o $@

#	C files

fixmath.c: fixmath.h
	touch fixmath.c

futil.c: futil.h
	touch futil.c

keyboard.c: keyboard.h
	touch keyboard.c

osspr.c: osspr.h
	touch osspr.c

screen.c: screen.h
	touch screen.c

span.c: span.h cbma.h error.h
	touch span.c

timer.c: timer.h
	touch timer.c

tmat.c: tmatmain.c tmat.h fixconv.h
	touch tmat.c

tmatmain.c: tmattran.c rtmattran.c
	touch tmatmain.c

tmatstack.c: tmatsmain.c tmatstack.h fixconv.h
	touch tmatstack.c

vec.c: vecmain.c vec.h fixconv.h
	touch vec.c

pqueue.c: pqueue.h
	touch pqueue.c

bbbsearch.c: bbbsearch.h
	touch bbbsearch.c

smalloc.c: smalloc.h
	touch smalloc.c

amdl.c: amdl.h
	touch amdl.c

nvar.c: nvar.h
	touch nvar.c

spandraw.c: spandraw.h error.h
	touch spandraw.c

textbuf.c: textbuf.h
	touch textbuf.c

stok.c: stok.h
	touch stok.c

fbll.c: fbll.h
	touch fbll.c

gdll.c: gdll.h
	touch gdll.c

jprof2.c: jprof2.h sasm.h error.h
	touch jprof2.c

sasm.c: sasm.h error.h
	touch sasm.c

error.c: error.h
	touch error.c

smap.c: smap.h gdll.h
	touch smap.c

hmap.c: hmap.h
	touch hmap.c

#	Assembler files

fixmath.s: bindings.s
	touch fixmath.s

cbma.s: bindings.s
	touch cbma.s

sasm_s.s: bindings.s
	touch sasm_s.s

#	Header files

fixconv.h: fixmath.h
	touch fixconv.h

span.h: fixmath.h
	touch span.h

tmat.h: vec.h
	touch tmat.h

tmatstack.h: tmat.h
	touch tmatstack.h

vec.h: fixmath.h
	touch vec.h

nvar.h: fbll.h
	touch nvar.h

spandraw.h: span.h tmat.h
	touch spandraw.h

stok.h: fixmath.h
	touch stok.h
