# Alex 2009
# Builds the Wiz version, uses the Open2x toolchain and libs

NAME	=	./sopwith

SRC		=	./src
OBJ		=	./objwiz

CFILES	= 	$(notdir $(wildcard $(SRC)/*.c))
OFILES	= 	$(addprefix $(OBJ)/, $(CFILES:.c=.o))

OPEN2X	=	/home/hopez/wiz/toolchain

SDL_CONFIG = $(OPEN2X)/bin/sdl-config

LIBS 		+= $(shell $(SDL_CONFIG) --libs)

CFLAGS	=	-DGP2X_WIZ \
			-O3 -s \
 			-msoft-float \
 			`$(OPEN2X)/bin/sdl-config --cflags` \
 			-I$(OPEN2X)/include -I$(OPEN2X)/arm-open2x-linux/include

PREFIX			:=	arm-openwiz-linux-gnu-
export PATH		:=	$(OPEN2X)/bin:$(PATH)
export CC		:=	$(PREFIX)gcc
export CXX		:=	$(PREFIX)g++
export AS		:=	$(PREFIX)as
export AR		:=	$(PREFIX)ar
export OBJCOPY	:=	$(PREFIX)objcopy
export READELF	:=	$(PREFIX)readelf
export STRIP	:=	$(PREFIX)strip

all : $(NAME)

$(NAME) : $(OFILES)
	$(CC) -o $(NAME) $(OFILES) $(LIBS)

$(OBJ)/%.o : $(SRC)/%.c
	$(CC) -c -o $@ $< $(CFLAGS)

clean :
	rm -f $(NAME) $(OFILES)

