CROSS_COMPILE=/usr/local/wince/bin/arm-wince-pe-

CC=$(CROSS_COMPILE)gcc
STRIP=$(CROSS_COMPILE)strip
CFLAGS=-Wall

CFLAGS+=-O2

LDLIBS=-lc -lgcc -lcoredll -lwinsock

all: boot.exe boot.s blue.exe readregs.exe changes.exe touch.exe
	$(STRIP) *.exe

boot.o: winhack.h build.h

boot.exe: asm.o

copy: all
	#pcp boot.exe ":\\My Documents\\boot.exe"
	pcp changes.exe ":\\My Documents\\changes.exe"
	#pcp readregs.exe ":\\My Documents\\readregs.exe"
	#pcp touch.exe ":\\My Documents\\touch.exe"

run: all
	pcp default.txt ":\\SD-MMC Card\\default.txt"
	pcp boot.exe ":\\My Documents\\boot.exe"
	prun "\\My Documents\\boot"

build:
	echo `expr \`cat BUILD\` + 1` >BUILD-
	mv BUILD- BUILD

BUILD:
	make build

build.h: BUILD
	echo "#define BUILD \"$(USER)-`cat BUILD` `date`\"" >build.h

zip:
	make build
	make
	zip boot-$(USER)-`cat BUILD`.zip \
		BUILD ChangeLog COPYING Makefile \
		winhack.h \
		boot.c asm.S setup.h boot.exe \
		default.txt \
		blue.c \
		readregs.c showregs.py \
		changes.c changes.exe

%.exe: %.o
	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $+ $(LDLIBS)

%.s: %.c
	$(CC) $(CFLAGS) -S -o $@ $+

clean:
	rm -f *.exe *.zip *.o *.s *~ *.pyc boot.h
