CFLAGS = -Wall -mpoke-function-name -O2 -mlibscl -mthrowback -mmodule -mhard-float -std=gnu99
CMHGFLAGS = -32bit -tgcc 

CC = gcc -c $(CFLAGS) -isystem OSLib: -MMD
ASM = asasm -throwback -IOSLib:
LINK = gcc $(CFLAGS) -LOSLib:

OBJS = \
 areas \
 circular \
 config \
 cursor \
 d3des \
 debug \
 dirtyrect \
 filter \
 frontend \
 header \
 hextile \
 ipserv \
 ipservfe \
 keys \
 mcode \
 pixtrans \
 profiling \
 raw \
 server \
 sockevent \
 task \
 toml \
 vncauth \
 vncbuffer \
 vncserv \
 zrle \

#	Output file

vncserver:	$(addsuffix .o, $(OBJS))
	$(LINK) -o $@ $^ -lOSLib32

testrect: testrect.c dirtyrect.c areas.c
	gcc -Wall -mpoke-function-name -O2 -mlibscl -mthrowback -mhard-float -std=gnu99 -o $@ $^

#	Object files
%.o: %.c
	$(CC) -MF d/$(basename $@) -o $@ $<

mcode.o: mcode.s RegNames.h
	$(ASM) -o $@ $<

#	cmunge stuff

header.o header.h:	cmhg.header
	cmunge $(CMHGFLAGS) -o o.header -d h.header cmhg.header

#	Dependencies
-include d/*

keymapgen: keymapgen.c
	gcc -Wall -mthrowback -std=gnu99 -mlibscl keymapgen.c -o keymapgen
