lutin/Makefile.Android.mk

256 lines
11 KiB
Makefile
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Setup macros definitions
include $(BUILD_SYSTEM)/core/defs.mk
# include generic makefile :
include $(BUILD_SYSTEM)/core/check-project-variable.mk
PROJECT_NDK?=..
TARGET_OS = Android
TARGET_ARCH = ARM
TARGET_CROSS = $(PROJECT_NDK)/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-
TARGET_OUT_FOLDER_BINARY := ERROR_NOTHING_MUST_BE_SET_HERE
TARGET_OUT_FOLDER_LIBRAIRY := data/lib/armeabi
TARGET_OUT_FOLDER_DATA := data/assets
TARGET_OUT_FOLDER_DOC := doc
TARGET_OUT_PREFIX_LIBRAIRY := lib
ANDROID_BOARD_ID = 14
TARGET_GLOBAL_C_INCLUDES+=-I$(PROJECT_NDK)/platforms/android-$(ANDROID_BOARD_ID)/arch-arm/usr/include
TARGET_GLOBAL_LDLIBS_SHARED = --sysroot=$(PROJECT_NDK)/platforms/android-$(ANDROID_BOARD_ID)/arch-arm
#generic makefile
include $(BUILD_SYSTEM)/core/main.mk
FINAL_FOLDER_JAVA_PROJECT=$(TARGET_OUT_STAGING)/src/$(PROJECT_COMPAGNY_TYPE)/$(PROJECT_COMPAGNY_NAME2)/$(PROJECT_NAME2)
FINAL_FILE_ABSTRACTION = $(FINAL_FOLDER_JAVA_PROJECT)/$(PROJECT_NAME2).java
$(FINAL_FILE_ABSTRACTION) : $(EWOL_FOLDER)/sources/android/PROJECT_NAME.java $(CONFIG_GLOBAL_FILE)
$(Q)mkdir -p $(dir $@)
$(Q)cp $(EWOL_FOLDER)/sources/android/PROJECT_NAME.java $@
$(Q)sed -i "s|__PROJECT_ORG_TYPE__|$(PROJECT_COMPAGNY_TYPE)|" $@
$(Q)sed -i "s|__PROJECT_VENDOR__|$(PROJECT_COMPAGNY_NAME2)|" $@
$(Q)sed -i "s|__PROJECT_NAME__|$(PROJECT_NAME2)|" $@
$(Q)sed -i "s|__PROJECT_PACKAGE__|$(PROJECT_NAME2)|" $@
$(Q)sed -i "s|__CONF_OGL_ES_V__|2|" $@
APPL_VERSION:=$(shell git describe --tags)
# --abbrev=0)
$(eval $(call copy-one-file,$(PROJECT_ICON),$(TARGET_OUT_STAGING)/res/drawable/icon.png))
$(TARGET_OUT_STAGING)/AndroidManifest.xml : $(CONFIG_GLOBAL_FILE) $(TARGET_OUT_STAGING)/res/drawable/icon.png
@echo "AndroidManifest.xml <== configFile"
@echo "<?xml version=\"1.0\" encoding=\"utf-8\"?> " > $@
@echo "<!-- Manifest is autoGenerated with Ewol ... do not patch it-->" >> $@
@echo "<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\" " >> $@
@echo " package=\"$(PROJECT_COMPAGNY_TYPE).$(PROJECT_COMPAGNY_NAME2).$(PROJECT_NAME2)\" " >> $@
@echo " android:versionCode=\"1\" " >> $@
@echo " android:versionName=\"$(APPL_VERSION)\"> " >> $@
@echo " <uses-feature android:glEsVersion=\"0x00020000\" android:required=\"true\" />" >> $@
@echo " <uses-sdk android:minSdkVersion=\"$(__EWOL_ANDROID_MINIMUM_SDK_VERSION__)\" /> " >> $@
@echo " " >> $@
@echo " <application android:label=\"$(PROJECT_NAME)\" " >> $@
@echo " android:icon=\"@drawable/icon\" " >> $@
@echo " > " >> $@
@echo " <activity android:name=\".$(PROJECT_NAME2)\" " >> $@
@echo " android:label=\"$(__EWOL_APPL_BASIC_TITLE__)\" " >> $@
@echo " android:icon=\"@drawable/icon\" " >> $@
@echo " android:configChanges=\"orientation\"> " >> $@
@echo " <intent-filter> " >> $@
@echo " <action android:name=\"android.intent.action.MAIN\" /> " >> $@
@echo " <category android:name=\"android.intent.category.LAUNCHER\" /> " >> $@
@echo " </intent-filter> " >> $@
@echo " </activity> " >> $@
@echo " </application> " >> $@
ifeq ("$(__ANDROID_PERMISSION__WRITE_EXTERNAL_STORAGE__)","y")
@echo " <uses-permission android:name=\"android.permission.WRITE_EXTERNAL_STORAGE\" /> " >> $@
endif
ifeq ("$(__ANDROID_PERMISSION__CAMERA__)","y")
@echo " <uses-permission android:name=\"android.permission.CAMERA\" /> " >> $@
endif
ifeq ("$(__ANDROID_PERMISSION__INTERNET__)","y")
@echo " <uses-permission android:name=\"android.permission.INTERNET\" /> " >> $@
endif
ifeq ("$(__ANDROID_PERMISSION__MODIFY_AUDIO_SETTINGS__)","y")
@echo " <uses-permission android:name=\"android.permission.MODIFY_AUDIO_SETTINGS\" /> " >> $@
endif
ifeq ("$(__ANDROID_PERMISSION__READ_CALENDAR__)","y")
@echo " <uses-permission android:name=\"android.permission.READ_CALENDAR\" /> " >> $@
endif
ifeq ("$(__ANDROID_PERMISSION__READ_CONTACTS__)","y")
@echo " <uses-permission android:name=\"android.permission.READ_CONTACTS\" /> " >> $@
endif
ifeq ("$(__ANDROID_PERMISSION__READ_FRAME_BUFFER__)","y")
@echo " <uses-permission android:name=\"android.permission.READ_FRAME_BUFFER\" /> " >> $@
endif
ifeq ("$(__ANDROID_PERMISSION__READ_PROFILE__)","y")
@echo " <uses-permission android:name=\"android.permission.READ_PROFILE\" /> " >> $@
endif
ifeq ("$(__ANDROID_PERMISSION__RECORD_AUDIO__)","y")
@echo " <uses-permission android:name=\"android.permission.RECORD_AUDIO\" /> " >> $@
endif
ifeq ("$(__ANDROID_PERMISSION__SET_ORIENTATION__)","y")
@echo " <uses-permission android:name=\"android.permission.SET_ORIENTATION\" /> " >> $@
endif
ifeq ("$(__ANDROID_PERMISSION__VIBRATE__)","y")
@echo " <uses-permission android:name=\"android.permission.VIBRATE\" /> " >> $@
endif
ifeq ("$(__ANDROID_PERMISSION__ACCESS_COARSE_LOCATION__)","y")
@echo " <uses-permission android:name=\"android.permission.ACCESS_COARSE_LOCATION\" /> " >> $@
endif
ifeq ("$(__ANDROID_PERMISSION__ACCESS_FINE_LOCATION__)","y")
@echo " <uses-permission android:name=\"android.permission.ACCESS_FINE_LOCATION\" /> " >> $@
endif
@echo "</manifest> " >> $@
javaclean:
$(Q)mkdir -p $(FINAL_FOLDER_JAVA_PROJECT)/
final : javaclean $(FINAL_FILE_ABSTRACTION) $(TARGET_OUT_STAGING)/AndroidManifest.xml
$(Q)mkdir -p $(TARGET_OUT_STAGING)/res/
$(Q)mkdir -p $(TARGET_OUT_STAGING)/src/
@# Doc :
@# http://asantoso.wordpress.com/2009/09/15/how-to-build-android-application-package-apk-from-the-command-line-using-the-sdk-tools-continuously-integrated-using-cruisecontrol/
@echo "R.java <== Resources files"
$(Q)$(PROJECT_SDK)/platform-tools/aapt p -f \
-M $(TARGET_OUT_STAGING)/AndroidManifest.xml \
-F $(TARGET_OUT_STAGING)/resources.res \
-I $(PROJECT_SDK)/platforms/android-15/android.jar\
-S $(TARGET_OUT_STAGING)/res/ \
-J $(TARGET_OUT_STAGING)/src
@#aapt package -f -M ${manifest.file} -F ${packaged.resource.file} -I ${path.to.android-jar.library}
@# -S ${android-resource-directory} [-m -J ${folder.to.output.the.R.java}]
$(Q)mkdir -p $(TARGET_OUT_STAGING)/build/classes/
@echo ".class <== .java"
@# more information with : -Xlint
$(Q)javac \
-d $(TARGET_OUT_STAGING)/build/classes \
-classpath $(PROJECT_SDK)/platforms/android-15/android.jar \
$(FINAL_FILE_ABSTRACTION) \
$(EWOL_FOLDER)/sources/android/src/org/ewol/interfaceJNI.java \
$(EWOL_FOLDER)/sources/android/src/org/ewol/interfaceOpenGL.java \
$(EWOL_FOLDER)/sources/android/src/org/ewol/interfaceSurfaceView.java \
$(EWOL_FOLDER)/sources/android/src/org/ewol/interfaceAudio.java \
$(TARGET_OUT_STAGING)/src/R.java
@echo ".dex <== .class"
$(Q)$(PROJECT_SDK)/platform-tools/dx \
--dex --no-strict \
--output=$(TARGET_OUT_STAGING)/build/$(PROJECT_NAME2).dex \
$(TARGET_OUT_STAGING)/build/classes/
@echo ".apk <== .dex, assets, .so, res"
$(Q)$(PROJECT_SDK)/tools/apkbuilder \
$(TARGET_OUT_STAGING)/build/$(PROJECT_NAME2)-unalligned.apk \
-u \
-z $(TARGET_OUT_STAGING)/resources.res \
-f $(TARGET_OUT_STAGING)/build/$(PROJECT_NAME2).dex \
-rf $(TARGET_OUT_STAGING)/data
@# doc :
@# http://developer.android.com/tools/publishing/app-signing.html
@# keytool is situated in $(JAVA_HOME)/bin ...
$(if $(wildcard ./$(PROJECT_NAME2)-$(BUILD_DIRECTORY_MODE).jks),$(empty), \
$(Q)echo "./$(PROJECT_NAME2)-$(BUILD_DIRECTORY_MODE).jks <== dynamic key (NOTE : It might ask some question to generate the key for android)" ; \
keytool -genkeypair -v \
-keystore ./$(PROJECT_NAME2)-$(BUILD_DIRECTORY_MODE).jks \
-storepass Pass$(PROJECT_NAME2) \
-alias alias$(PROJECT_NAME2) \
-keypass PassK$(PROJECT_NAME2) \
-keyalg RSA \
-validity 365 \
)
@# Question poser a ce moment, les automatiser ...
@# Quels sont vos prénom et nom ?
@# Edouard DUPIN
@# [Unknown] : Quel est le nom de votre unité organisationnelle ?
@# org
@# [Unknown] : Quelle est le nom de votre organisation ?
@# EWOL
@# [Unknown] : Quel est le nom de votre ville de résidence ?
@# Paris
@# [Unknown] : Quel est le nom de votre état ou province ?
@# France
@# [Unknown] : Quel est le code de pays à deux lettres pour cette unité ?
@# FR
@# [Unknown] : Est-ce CN=Edouard DUPIN, OU=org, O=EWOL, L=Paris, ST=France, C=FR ?
@# oui
@# [non] :
@# Génération d'une paire de clés RSA de 1 024 bits et d'un certificat autosigné (SHA1withRSA) d'une validité de 365 jours
@# pour : CN=Edouard DUPIN, OU=org, O=EWOL, L=Paris, ST=France, C=FR
@# keytool is situated in $(JAVA_HOME)/bin ...
@echo "apk(Signed) <== apk"
ifeq ("$(DEBUG)","1")
@#generate the pass file (debug mode does not request to have a complicated key) :
@echo "Pass$(PROJECT_NAME2)" > tmpPass.boo
@echo "PassK$(PROJECT_NAME2)" >> tmpPass.boo
@# verbose mode : -verbose
$(Q)jarsigner \
-keystore ./$(PROJECT_NAME2)-$(BUILD_DIRECTORY_MODE).jks \
$(TARGET_OUT_STAGING)/build/$(PROJECT_NAME2)-unalligned.apk \
alias$(PROJECT_NAME2) \
< tmpPass.boo \
2> /dev/null
$(Q)rm tmpPass.boo
else
@# sign the application request loggin and password :
$(Q)jarsigner \
-keystore ./$(PROJECT_NAME2)-$(BUILD_DIRECTORY_MODE).jks \
$(TARGET_OUT_STAGING)/build/$(PROJECT_NAME2)-unalligned.apk \
alias$(PROJECT_NAME2)
endif
@echo "apk(aligned) <== apk"
$(Q)rm -f $(TARGET_OUT_STAGING)/$(PROJECT_NAME2).apk
@# verbose mode : -v
$(Q)$(PROJECT_SDK)/tools/zipalign 4 \
$(TARGET_OUT_STAGING)/build/$(PROJECT_NAME2)-unalligned.apk \
$(TARGET_OUT_STAGING)/$(PROJECT_NAME2).apk
@# copy file in the final stage :
$(Q)mkdir -p $(TARGET_OUT_FINAL)/
@echo "Generated out : $(TARGET_OUT_FINAL)/$(PROJECT_NAME2).apk"
$(Q)cp $(TARGET_OUT_STAGING)/$(PROJECT_NAME2).apk $(TARGET_OUT_FINAL)/$(PROJECT_NAME2).apk
install:
@echo ------------------------------------------------------------------------
@echo Install : $(TARGET_OUT_FINAL)/$(PROJECT_NAME2).apk
@echo ------------------------------------------------------------------------
$(Q)sudo $(PROJECT_SDK)/platform-tools/adb install -r $(TARGET_OUT_FINAL)/$(PROJECT_NAME2).apk
uninstall:
@echo ------------------------------------------------------------------------
@echo UnInstall : $(PROJECT_NAME2)
@echo ------------------------------------------------------------------------
$(Q)sudo $(PROJECT_SDK)/platform-tools/adb uninstall $(PROJECT_NAME2)
log:
@echo ------------------------------------------------------------------------
@echo Run android logat
@echo ------------------------------------------------------------------------
$(Q)sudo $(PROJECT_SDK)/platform-tools/adb shell logcat
shell:
@echo ------------------------------------------------------------------------
@echo Run android shell
@echo ------------------------------------------------------------------------
sudo $(PROJECT_SDK)/platform-tools/adb shell