###############################################################################
# Makefile for a GP32 application.
###############################################################################

PREFIX		 = /mythtv/media/devel/toolchains/openwiz/arm-openwiz-linux-gnu
TARGET		 = arm-openwiz-linux-gnu

# Change the line below to the name of your program
PROGRAM = glquake

# If you have any directories with include files, add them here with -I on
# the front of each
INCLUDES = -I../WinQuake \
	   -I$(PREFIX)/include \

# list all .c files here
CFILES	=		WinQuake/chase.c \
			WinQuake/cl_demo.c \
			WinQuake/cl_input.c \
			WinQuake/cl_main.c \
			WinQuake/cl_parse.c \
			WinQuake/cl_tent.c \
			WinQuake/cmd.c \
			WinQuake/common.c \
			WinQuake/console.c \
			WinQuake/crc.c \
			WinQuake/cvar.c \
			WinQuake/gl_draw.c \
			WinQuake/gl_mesh.c \
			WinQuake/gl_model.c \
			WinQuake/gl_refrag.c \
			WinQuake/gl_rlight.c \
			WinQuake/gl_rmain.c \
			WinQuake/gl_rmisc.c \
			WinQuake/gl_rsurf.c \
			WinQuake/gl_screen.c \
			WinQuake/gl_test.c \
			WinQuake/gl_warp.c \
			WinQuake/host.c \
			WinQuake/host_cmd.c \
			WinQuake/keys.c \
			WinQuake/menu.c \
			WinQuake/mathlib.c \
			WinQuake/nonintel.c \
			WinQuake/pr_cmds.c \
			WinQuake/pr_edict.c \
			WinQuake/pr_exec.c \
			WinQuake/r_part.c \
			WinQuake/sbar.c \
			WinQuake/sv_main.c \
			WinQuake/sv_phys.c \
			WinQuake/sv_move.c \
			WinQuake/sv_user.c \
			WinQuake/zone.c \
			WinQuake/view.c \
			WinQuake/wad.c \
			WinQuake/world.c \
			WinQuake/net_vcr.c \
			WinQuake/net_main.c \
			WinQuake/net_loop.c \
			WinQuake/net_bsd.c \
			WinQuake/net_dgrm.c \
			WinQuake/snd_mem.c \
			WinQuake/snd_mix.c \
			WinQuake/snd_dma.c \
			WinQuake/sys_linux.c \
			WinQuake/cd_linux.c \
			wiz/net_udp.c \
			wiz/vid_nanogl.c \
			wiz/snd_sdl.c \
			wiz/in_wiz.c

# list all assembler (.s) files here
#SFILES=			ARMASM/memcpy.S

##############################################################################
# You shouldn't need to change anything below here, really
##############################################################################



ALL_INCLUDES = $(INCLUDES)
ALL_LIBS = $(LIBS)

CFLAGS     =	-g -DGLQUAKE \
		-Wall \
		$(shell $(PREFIX)/bin/sdl-config --cflags)
#		-O3 -mcpu=cortex-a8 -mtune=cortex-a8 -march=armv7-a \
#		-mfloat-abi=softfp -mfpu=neon -ftree-vectorize \
#		-ffast-math -fomit-frame-pointer -fno-strict-aliasing -fsingle-precision-constant

LDFLAGS = $(shell $(PREFIX)/bin/sdl-config --libs) -lnanoGL -lwizGLES -lstdc++

OFILES  =       $(SFILES:.S=.o) $(CFILES:.c=.o)

CC = $(PREFIX)/bin/$(TARGET)-gcc

$(PROGRAM): $(OFILES)
	$(CC) $(OFILES) $(LDFLAGS) $(LIBDIRS) $(ALL_LIBS) -o $@

.PHONY: all clean

all:		$(PROGRAM)

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

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

clean:
	-rm -f $(OFILES) $(MAPFILE) $(PROGRAM)

install: all
	 $(CROSS)/bin/$(TARGET)-strip -o $(PROGRAM).gpe $(PROGRAM)