# portable gui library

all: riscos_release gtk_release
debug: riscos_debug gtk_debug
clean:
	-rm *.o


SHARED_FLAGS = -std=c9x -Wall -W -Wundef -Wshadow -Wpointer-arith -Wbad-function-cast -Wcast-qual \
-Wcast-align -Wwrite-strings -Wconversion -Wstrict-prototypes -Wmissing-prototypes \
-Wmissing-declarations -Wredundant-decls -Wnested-externs -Winline
# -mstubs
RISCOS_FLAGS = $(SHARED_FLAGS) -Driscos
RISCOS_TOOLS = /home/james/Tools
RISCOS_RELEASE_CC = $(RISCOS_TOOLS)/riscos-gcc/cross/bin/gcc $(RISCOS_FLAGS) -O3 \
	-I$(RISCOS_TOOLS)/oslib/
RISCOS_DEBUG_CC = $(RISCOS_TOOLS)/riscos-gcc/cross/bin/gcc $(RISCOS_FLAGS) -mpoke-function-name \
	-DDEBUG -I$(RISCOS_TOOLS)/oslib/
RISCOS_LIBS = $(RISCOS_TOOLS)/oslib/lib/oslib.o

GTK_FLAGS = $(SHARED_FLAGS) -Dgtk
GTK_RELEASE_CC = gcc $(GTK_FLAGS) -O3 `gtk-config --cflags`
GTK_DEBUG_CC = gcc $(GTK_FLAGS) -DDEBUG `gtk-config --cflags`
GTK_LIBS = `gtk-config --libs`


SHARED = messages textarea wstring
LOCAL = main_PLAT window_PLAT dialog_PLAT textarea_PLAT menu_PLAT
RISCOS = $(subst PLAT,riscos,$(LOCAL)) $(SHARED) ufont
RISCOS_OBJS = $(addsuffix .ro.o,$(RISCOS))
GTK = $(subst PLAT,gtk,$(LOCAL)) $(SHARED)
GTK_OBJS = $(addsuffix .gtk.o,$(GTK))


riscos_release: gui_riscos.o guitest.ro.o
	$(RISCOS_RELEASE_CC) -o !guitest/guitest,ff8 gui_riscos.o guitest.ro.o $(RISCOS_LIBS)
riscos_debug: _gui_riscos.o _guitest.ro.o
	$(RISCOS_DEBUG_CC) -o !guitest/guitest,ff8 _gui_riscos.o _guitest.ro.o $(RISCOS_LIBS)

gtk_release: gui_gtk.o guitest.gtk.o
	$(GTK_RELEASE_CC) -o guitest_gtk gui_gtk.o guitest.gtk.o $(GTK_LIBS)
gtk_debug: _gui_gtk.o _guitest.gtk.o
	$(GTK_DEBUG_CC) -o guitest_gtk _gui_gtk.o _guitest.gtk.o $(GTK_LIBS)


gui_riscos.o: $(RISCOS_OBJS)
	$(RISCOS_TOOLS)/riscos-gcc/cross/bin/libfile -c gui_riscos.o $(RISCOS_OBJS)
_gui_riscos.o: $(addprefix _,$(RISCOS_OBJS))
	$(RISCOS_TOOLS)/riscos-gcc/cross/bin/libfile -c _gui_riscos.o $(addprefix _,$(RISCOS_OBJS))

gui_gtk.o: $(GTK_OBJS)
	ld -r -o gui_gtk.o $(GTK_OBJS)
_gui_gtk.o: $(addprefix _,$(GTK_OBJS))
	ld -r -o _gui_gtk.o $(addprefix _,$(GTK_OBJS))


%.ro.o: %.c gui.h gui_riscos.h
	$(RISCOS_RELEASE_CC) -o $@ -c $<
_%.ro.o: %.c gui.h gui_riscos.h
	$(RISCOS_DEBUG_CC) -o $@ -c $<

%.gtk.o: %.c gui.h gui_gtk.h
	$(GTK_RELEASE_CC) -o $@ -c $<
_%.gtk.o: %.c gui.h gui_gtk.h
	$(GTK_DEBUG_CC) -o $@ -c $<
