~ubuntu-branches/ubuntu/utopic/hedgewars/utopic

1.2.13 by Gianfranco Costamagna
Import upstream version 0.9.18
1
###################################################################################
2
# Hedgewars, a free turn based strategy game
3
# Copyright (c) 2011 Richard Deurwaarder <xeli@xelification.com>
4
#
5
# This program is free software; you can redistribute it and/or modify
6
# it under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; version 2 of the License
8
#
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
# GNU General Public License for more details.
13
#
14
# You should have received a copy of the GNU General Public License
15
# along with this program; if not, write to the Free Software
16
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
17
###################################################################################
18
19
find_program(ANT ant DOC "Path to the java package creator: ant")
20
if(NOT EXISTS ${ANT})
1.2.14 by Gianfranco Costamagna
Import upstream version 0.9.19.2
21
    message(FATAL_ERROR "Couldn't detect the Ant build tool")
1.2.13 by Gianfranco Costamagna
Import upstream version 0.9.18
22
endif()
23
24
if(NOT ANDROID_NDK)
25
    find_path(ANDROID_NDK ndk-build)
26
endif()
27
28
if(IS_DIRECTORY "${ANDROID_NDK}")
1.2.14 by Gianfranco Costamagna
Import upstream version 0.9.19.2
29
    message(STATUS "Detected the android NDK directory at: " ${ANDROID_NDK}) 
1.2.13 by Gianfranco Costamagna
Import upstream version 0.9.18
30
else ()
1.2.14 by Gianfranco Costamagna
Import upstream version 0.9.19.2
31
    message(FATAL_ERROR "Couldn't detect the Android NDK directory")
1.2.13 by Gianfranco Costamagna
Import upstream version 0.9.18
32
endif()
33
34
if(NOT ANDROID_NDK_TOOLCHAINDIR)
1.2.14 by Gianfranco Costamagna
Import upstream version 0.9.19.2
35
    set(toolchainbase "${ANDROID_NDK}/toolchains/arm-linux-androideabi-4.6/prebuilt")
1.2.13 by Gianfranco Costamagna
Import upstream version 0.9.18
36
    find_path(ANDROID_NDK_TOOLCHAINDIR arm-linux-androideabi
37
                "${toolchainbase}/linux-x86"
38
                "${toolchainbase}/windows")
39
endif()
40
41
if(IS_DIRECTORY "${ANDROID_NDK_TOOLCHAINDIR}")
1.2.14 by Gianfranco Costamagna
Import upstream version 0.9.19.2
42
    message(STATUS "Detected the Android NDK toolchain at: ${ANDROID_NDK_TOOLCHAINDIR}") 
1.2.13 by Gianfranco Costamagna
Import upstream version 0.9.18
43
else ()
1.2.14 by Gianfranco Costamagna
Import upstream version 0.9.19.2
44
    message(FATAL_ERROR "Couldn't detect the Android NDK toolchain directory: ${ANDROID_NDK_TOOLCHAINDIR}")
1.2.13 by Gianfranco Costamagna
Import upstream version 0.9.18
45
endif()
46
47
if(NOT ANDROID_SDK)#Check if its defined at the cmdline
48
    find_program(ANDROID_SDK adb) #assume they've added platform-tools to their path
49
    get_filename_component(ANDROID_SDK "${ANDROID_SDK}" PATH)
50
    get_filename_component(ANDROID_SDK "${ANDROID_SDK}" PATH)
51
    set(ANDROID_SDK "${ANDROID_SDK}" CACHE PATH "Path to the android sdk" FORCE)
52
endif()
53
54
if( IS_DIRECTORY "${ANDROID_SDK}")
1.2.14 by Gianfranco Costamagna
Import upstream version 0.9.19.2
55
    message(STATUS "Detected the android SDK directory at: " ${ANDROID_SDK}) 
1.2.13 by Gianfranco Costamagna
Import upstream version 0.9.18
56
else ()
1.2.14 by Gianfranco Costamagna
Import upstream version 0.9.19.2
57
    message(FATAL_ERROR "Couldn't detect the Android SDK directory")
1.2.13 by Gianfranco Costamagna
Import upstream version 0.9.18
58
endif()
59
60
if( NOT FPC_DIR)
61
    find_program(FPC_DIR ppcrossarm)
62
    get_filename_component(FPC_DIR "${FPC_DIR}" PATH)
63
    if(IS_DIRECTORY "${FPC_DIR}") 
64
    	set(FPC_DIR "${FPC_DIR}" CACHE PATH "Path to fpc dir used in the android port" FORCE)
65
    endif()
66
endif()
67
68
if( IS_DIRECTORY "${FPC_DIR}")
1.2.14 by Gianfranco Costamagna
Import upstream version 0.9.19.2
69
    message(STATUS "Detected the FreePascal directory at: " "${FPC_DIR}") 
1.2.13 by Gianfranco Costamagna
Import upstream version 0.9.18
70
else ()
1.2.14 by Gianfranco Costamagna
Import upstream version 0.9.19.2
71
    message(FATAL_ERROR "Couldn't detect the FreePascal directory")
1.2.13 by Gianfranco Costamagna
Import upstream version 0.9.18
72
endif()
73
74
set(SDL_DIR /home/richard/Downloads/android-project)
75
76
1.2.14 by Gianfranco Costamagna
Import upstream version 0.9.19.2
77
set(ANDROID_SDK_API_LVL 16)
1.2.13 by Gianfranco Costamagna
Import upstream version 0.9.18
78
set(ANDROID_NDK_API_LVL 5)
79
1.2.14 by Gianfranco Costamagna
Import upstream version 0.9.19.2
80
message(STATUS "Creating Makefile.android...")
1.2.13 by Gianfranco Costamagna
Import upstream version 0.9.18
81
82
configure_file(Templates/Makefile.android .)
83
84
find_program(ANDROID_EXEC NAMES android android.bat PATHS "${ANDROID_SDK}/platform-tools" "${ANDROID_SDK}/tools")
85
if(ANDROID_EXEC)
86
    exec_program(${ANDROID_EXEC}
87
                 ARGS "update project"
88
                 "--path ${CMAKE_CURRENT_SOURCE_DIR}/SDL-android-project"
89
                 "--target android-${ANDROID_SDK_API_LVL}"
90
                 OUTPUT_VARIABLE androidoutput
91
                )
1.2.14 by Gianfranco Costamagna
Import upstream version 0.9.19.2
92
    message(STATUS "Updating android project config...\n" ${androidoutput})
1.2.13 by Gianfranco Costamagna
Import upstream version 0.9.18
93
else()
1.2.14 by Gianfranco Costamagna
Import upstream version 0.9.19.2
94
    message(FATAL_ERROR "Couldn't find the android executable in ${ANDROID_SDK}/platform-tools or ${ANDROID_SDK}/tools.")
1.2.13 by Gianfranco Costamagna
Import upstream version 0.9.18
95
endif()
96
1.2.16 by Gianfranco Costamagna
Import upstream version 0.9.20
97
##
98
# FIXME: this was useful for early version of SDL 1.3 so is most likely not needed anymore
99
#        if so delete the files referenced here from the repository
100
#        commenting out because it inteferes with SDL 2 builds
101
##
102
#exec_program(${HGCOMMAND}
103
#    ARGS revert ${CMAKE_CURRENT_SOURCE_DIR}/SDL-android-project/jni/SDL/src/core/android/SDL_android.cpp
104
#    OUTPUT_VARIABLE dontcare
105
#)
106
#exec_program(${HGCOMMAND}
107
#    ARGS revert ${CMAKE_CURRENT_SOURCE_DIR}/SDL-android-project/jni/SDL/src/main/android/SDL_android_main.cpp
108
#    OUTPUT_VARIABLE dontcare
109
#)
110
#exec_program(${HGCOMMAND}
111
#    ARGS revert ${CMAKE_CURRENT_SOURCE_DIR}/SDL-android-project/jni/SDL/src/file/SDL_rwops.c
112
#    OUTPUT_VARIABLE dontcare
113
#)
114
#exec_program(${HGCOMMAND}
115
#    ARGS revert ${CMAKE_CURRENT_SOURCE_DIR}/SDL-android-project/jni/SDL_mixer/Android.mk
116
#    OUTPUT_VARIABLE dontcare
117
#)
118
#exec_program(${HGCOMMAND}
119
#    ARGS revert ${CMAKE_CURRENT_SOURCE_DIR}/SDL-android-project/jni/SDL_ttf/Android.mk
120
#    OUTPUT_VARIABLE dontcare
121
#)
1.2.13 by Gianfranco Costamagna
Import upstream version 0.9.18
122