CC = gcc
CFLAGS = $(T3F_CFLAGS) $(GLOBAL_CFLAGS) $(IPHONE_ARCHITECTURES) $(IPHONE_COMPILER_SETTINGS) $(IPHONE_SYS_ROOT) $(IPHONE_MIN_VERSION) $(APP_CFLAGS) $(IPHONE_CFLAGS)
CXX = g++
CXXFLAGS = $(CFLAGS)
LFLAGS = $(IPHONE_LINKER_SETTINGS) $(IPHONE_ARCHITECTURES) $(IPHONE_SYS_ROOT) $(IPHONE_MIN_VERSION)
PLATFORM_OBJECTS = t3f/menu.o $(IPHONE_PLATFORM_OBJECTS)
PLATFORM_LIBS = -framework IOKit -framework AudioToolbox -framework OpenGLES -framework OpenAL -framework CoreGraphics -framework Foundation -framework QuartzCore -framework UIKit -framework MobileCoreServices -lallegro_dialog$(LIB_SUFFIX) -lallegro_main-static $(IPHONE_PLATFORM_LIBS)
PLATFORM_TARGET = $(APP_PACKAGE_DIR)/$(APP_TITLE).app
LIB_SUFFIX = -static
DEPEND_LIBS = -lz -lpng -lvorbisidec -ldumb -lfreetype $(IPHONE_DEPEND_LIBS)
DEL_COMMAND = rm -f
DEL_FOLDER_COMMAND = rm -rf
SED_COMMAND = sed -i ''
PLATFORM_CLEAN = rm -rf $(APP_PACKAGE_DIR)/$(APP_TITLE).app
COPY_COMMAND = cp

include makefile.common

prepare_platform:
	@echo Ready to build...

$(APP_PACKAGE_DIR)/$(APP_TITLE).app : $(APP_EXE_NAME)
	@$(DEL_FOLDER_COMMAND) $(APP_PACKAGE_DIR)/$(APP_TITLE).app
	@mkdir $(APP_PACKAGE_DIR)/$(APP_TITLE).app
	@cp $(APP_EXE_NAME) $(APP_PACKAGE_DIR)/$(APP_TITLE).app/$(APP_TITLE)
	@cp ../icons/macosx_icon.icns $(APP_PACKAGE_DIR)/$(APP_TITLE).app/$(APP_TITLE).icns
	@cp -a ../bin/data $(APP_PACKAGE_DIR)/$(APP_TITLE).app
	@cp -a ../docs $(APP_PACKAGE_DIR)/$(APP_TITLE).app
	@cp ../iphone/Info.plist $(APP_PACKAGE_DIR)/$(APP_TITLE).app
	@cp ../iphone/Pkginfo $(APP_PACKAGE_DIR)/$(APP_TITLE).app
	@sed -i '' "s|T3F_APP_EXECUTABLE|$(APP_TITLE)|" $(APP_PACKAGE_DIR)/$(APP_TITLE).app/Info.plist
	@sed -i '' "s|T3F_APP_ICON|$(APP_TITLE).icns|" $(APP_PACKAGE_DIR)/$(APP_TITLE).app/Info.plist
	@sed -i '' "s|T3F_APP_DISPLAY_NAME|$(APP_TITLE)|" $(APP_PACKAGE_DIR)/$(APP_TITLE).app/Info.plist
	@sed -i '' "s|T3F_APP_VERSION|$(APP_VERSION)|" $(APP_PACKAGE_DIR)/$(APP_TITLE).app/Info.plist
	@sed -i '' "s|T3F_APP_PACKAGE|$(APP_ANDROID_PACKAGE)|" $(APP_PACKAGE_DIR)/$(APP_TITLE).app/Info.plist
	@echo Application bundle created!

iphone_package: $(APP_PACKAGE_DIR)/$(APP_TITLE).app
	@echo iPhone package created!
