# Copyright 2010, The Native Client SDK Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can
# be found in the LICENSE file.

# Makefile for the XM Player example.

.PHONY: all clean

CCFILES =  xm_player.cc _mod.cc geturl_handler.cc

NACL_SDK_ROOT = ../..

INCLUDES = -I$(NACL_SDK_ROOT) -I"/cygdrive/h/libs/boost/include/boost-1_47"
LDFLAGS = -lppruntime \
          -lppapi_cpp \
          -lplatform \
          -lgio \
          -lpthread \
          -lsrpc \
		  -lz

all: check_variables xm_player.nmf xm_player_dbg.nmf

# common.mk has rules to build .o files from .cc files.
-include ../common.mk

xm_player.nmf: xm_player_x86_32.nexe xm_player_x86_64.nexe
	@echo "Creating xm_player.nmf..."
	$(PYTHON) ../generate_nmf.py --nmf $@ \
	 --x86-64 xm_player_x86_64.nexe --x86-32 xm_player_x86_32.nexe

xm_player_dbg.nmf: xm_player_x86_32_dbg.nexe xm_player_x86_64_dbg.nexe
	@echo "Creating xm_player_dbg.nmf..."
	$(PYTHON) ../generate_nmf.py --nmf $@ \
	 --x86-64 xm_player_x86_64_dbg.nexe \
	 --x86-32 xm_player_x86_32_dbg.nexe

xm_player_x86_32.nexe: $(OBJECTS_X86_32)
	$(CPP) $^ $(LDFLAGS) -m32 -o $@
	$(NACL_STRIP) $@ -o $@

xm_player_x86_64.nexe: $(OBJECTS_X86_64)
	$(CPP) $^ $(LDFLAGS) -m64 -o $@
	$(NACL_STRIP) $@ -o $@

xm_player_x86_32_dbg.nexe: $(OBJECTS_X86_32_DBG)
	$(CPP) $^ $(LDFLAGS) -m32 -o $@

xm_player_x86_64_dbg.nexe: $(OBJECTS_X86_64_DBG)
	$(CPP) $^ $(LDFLAGS) -m64 -o $@

clean:
	-$(RM) *.nmf *.o *.obj *.nexe

# This target is used by the SDK build system to produce a pre-built version
# of the .nexe.  You do not need to call this target.
install_prebuilt: xm_player.nmf
	-$(RM) $(OBJECTS_X86_32) $(OBJECTS_X86_64)
