lutin/Makefile.Android.mk
2012-09-14 17:19:17 +02:00

242 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.

TARGET_OS = Android
TARGET_ARCH = ARM
TARGET_CROSS = $(PROJECT_NDK)/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-
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 $(EWOL_FOLDER)/Build/core/main.mk
CONFIG2___EWOL_APPL_ORGANISATION_TYPE__ := $(subst _,$(empty),$(call convert-special-char,$(CONFIG___EWOL_APPL_ORGANISATION_TYPE__)))
CONFIG2___EWOL_APPL_COMPAGNY__ := $(subst _,$(empty),$(call convert-special-char,$(CONFIG___EWOL_APPL_COMPAGNY__)))
CONFIG2___EWOL_APPL_NAME__ := $(subst _,$(empty),$(call convert-special-char,$(CONFIG___EWOL_APPL_NAME__)))
CONFIG2___EWOL_ANDROID_ICON__ := $(subst $(quote),$(empty),$(CONFIG___EWOL_ANDROID_ICON__))
FINAL_FOLDER_JAVA=$(TARGET_OUT_FINAL)
FINAL_FOLDER_JAVA_PROJECT=$(FINAL_FOLDER_JAVA)/src/$(CONFIG2___EWOL_APPL_ORGANISATION_TYPE__)/$(CONFIG2___EWOL_APPL_COMPAGNY__)/$(CONFIG2___EWOL_APPL_NAME__)
FINAL_FILE_ABSTRACTION = $(FINAL_FOLDER_JAVA_PROJECT)/$(CONFIG2___EWOL_APPL_NAME__).java
javaclean:
$(Q)rm -rf $(FINAL_FOLDER_JAVA)/
$(Q)mkdir -p $(FINAL_FOLDER_JAVA_PROJECT)/
$(FINAL_FILE_ABSTRACTION) : $(EWOL_FOLDER)/Java/PROJECT_NAME.java $(CONFIG_GLOBAL_FILE)
$(Q)mkdir -p $(dir $@)
$(Q)cp $(EWOL_FOLDER)/Java/PROJECT_NAME.java $@
$(Q)sed -i "s|__PROJECT_ORG_TYPE__|$(CONFIG2___EWOL_APPL_ORGANISATION_TYPE__)|" $@
$(Q)sed -i "s|__PROJECT_VENDOR__|$(CONFIG2___EWOL_APPL_COMPAGNY__)|" $@
$(Q)sed -i "s|__PROJECT_NAME__|$(CONFIG2___EWOL_APPL_NAME__)|" $@
$(Q)sed -i "s|__PROJECT_PACKAGE__|$(CONFIG2___EWOL_APPL_NAME__)|" $@
ifeq ("$(CONFIG___VIDEO__OPENGL_ES_2)","y")
$(Q)sed -i "s|__CONF_OGL_ES_V__|2|" $@
else
$(Q)sed -i "s|__CONF_OGL_ES_V__|1|" $@
endif
APPL_VERSION:=$(shell git describe --tags)
# --abbrev=0)
$(FINAL_FOLDER_JAVA)/AndroidManifest.xml : $(CONFIG_GLOBAL_FILE)
@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=\"$(CONFIG2___EWOL_APPL_ORGANISATION_TYPE__).$(CONFIG2___EWOL_APPL_COMPAGNY__).$(CONFIG2___EWOL_APPL_NAME__)\" " >> $@
@echo " android:versionCode=\"1\" " >> $@
@echo " android:versionName=\"$(APPL_VERSION)\"> " >> $@
ifeq ("$(CONFIG___VIDEO__OPENGL_ES_2)","y")
@echo " <uses-feature android:glEsVersion=\"0x00020000\" android:required=\"true\" />" >> $@
endif
@echo " <uses-sdk android:minSdkVersion=\"$(CONFIG___EWOL_ANDROID_MINIMUM_SDK_VERSION__)\" /> " >> $@
@echo " " >> $@
@echo " <application android:label=\"$(CONFIG___EWOL_APPL_NAME__)\" " >> $@
ifneq ("$(wildcard ./$(CONFIG2___EWOL_ANDROID_ICON__).png)","")
@mkdir -p $(FINAL_FOLDER_JAVA)/res/drawable/
@cp ./$(CONFIG2___EWOL_ANDROID_ICON__).png $(FINAL_FOLDER_JAVA)/res/drawable/icon.png
@echo " android:icon=\"@drawable/icon\" " >> $@
endif
@echo " > " >> $@
@echo " <activity android:name=\".$(CONFIG2___EWOL_APPL_NAME__)\" " >> $@
@echo " android:label=\"$(CONFIG___EWOL_APPL_BASIC_TITLE__)\" " >> $@
ifneq ("$(wildcard ./$(CONFIG2___EWOL_ANDROID_ICON__).png)","")
@echo " android:icon=\"@drawable/icon\" " >> $@
endif
@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 ("$(CONFIG___ANDROID_PERMISSION__WRITE_EXTERNAL_STORAGE__)","y")
@echo " <uses-permission android:name=\"android.permission.WRITE_EXTERNAL_STORAGE\" /> " >> $@
endif
ifeq ("$(CONFIG___ANDROID_PERMISSION__CAMERA__)","y")
@echo " <uses-permission android:name=\"android.permission.CAMERA\" /> " >> $@
endif
ifeq ("$(CONFIG___ANDROID_PERMISSION__INTERNET__)","y")
@echo " <uses-permission android:name=\"android.permission.INTERNET\" /> " >> $@
endif
ifeq ("$(CONFIG___ANDROID_PERMISSION__MODIFY_AUDIO_SETTINGS__)","y")
@echo " <uses-permission android:name=\"android.permission.MODIFY_AUDIO_SETTINGS\" /> " >> $@
endif
ifeq ("$(CONFIG___ANDROID_PERMISSION__READ_CALENDAR__)","y")
@echo " <uses-permission android:name=\"android.permission.READ_CALENDAR\" /> " >> $@
endif
ifeq ("$(CONFIG___ANDROID_PERMISSION__READ_CONTACTS__)","y")
@echo " <uses-permission android:name=\"android.permission.READ_CONTACTS\" /> " >> $@
endif
ifeq ("$(CONFIG___ANDROID_PERMISSION__READ_FRAME_BUFFER__)","y")
@echo " <uses-permission android:name=\"android.permission.READ_FRAME_BUFFER\" /> " >> $@
endif
ifeq ("$(CONFIG___ANDROID_PERMISSION__READ_PROFILE__)","y")
@echo " <uses-permission android:name=\"android.permission.READ_PROFILE\" /> " >> $@
endif
ifeq ("$(CONFIG___ANDROID_PERMISSION__RECORD_AUDIO__)","y")
@echo " <uses-permission android:name=\"android.permission.RECORD_AUDIO\" /> " >> $@
endif
ifeq ("$(CONFIG___ANDROID_PERMISSION__SET_ORIENTATION__)","y")
@echo " <uses-permission android:name=\"android.permission.SET_ORIENTATION\" /> " >> $@
endif
ifeq ("$(CONFIG___ANDROID_PERMISSION__VIBRATE__)","y")
@echo " <uses-permission android:name=\"android.permission.VIBRATE\" /> " >> $@
endif
ifeq ("$(CONFIG___ANDROID_PERMISSION__ACCESS_COARSE_LOCATION__)","y")
@echo " <uses-permission android:name=\"android.permission.ACCESS_COARSE_LOCATION\" /> " >> $@
endif
ifeq ("$(CONFIG___ANDROID_PERMISSION__ACCESS_FINE_LOCATION__)","y")
@echo " <uses-permission android:name=\"android.permission.ACCESS_FINE_LOCATION\" /> " >> $@
endif
@echo "</manifest> " >> $@
final : javaclean $(FINAL_FILE_ABSTRACTION) $(FINAL_FOLDER_JAVA)/AndroidManifest.xml
$(Q)mkdir -p $(FINAL_FOLDER_JAVA)/res/
@echo ".apk/assets/ <== assets"
$(Q)mkdir -p $(FINAL_FOLDER_JAVA)/data/assets/
$(Q)cp -r $(EWOL_FOLDER)/share/* $(FINAL_FOLDER_JAVA)/data/assets/
$(Q)cp -r share/* $(FINAL_FOLDER_JAVA)/data/assets/
@echo ".apk/lib/armeabi/ <== *.so"
$(Q)mkdir -p $(FINAL_FOLDER_JAVA)/data/lib/armeabi/
$(Q)cp $(TARGET_OUT_STAGING)/usr/lib/$(CONFIG2___EWOL_APPL_NAME__).so $(FINAL_FOLDER_JAVA)/data/lib/armeabi/lib$(CONFIG2___EWOL_APPL_NAME__).so
@# 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 $(FINAL_FOLDER_JAVA)/AndroidManifest.xml \
-F $(FINAL_FOLDER_JAVA)/resources.res \
-I $(PROJECT_SDK)/platforms/android-15/android.jar\
-S $(FINAL_FOLDER_JAVA)/res/ \
-J $(FINAL_FOLDER_JAVA)/src
$(Q)mkdir -p $(FINAL_FOLDER_JAVA)/build/classes/
@echo ".class <== .java"
@# more information with : -Xlint
$(Q)javac \
-d $(FINAL_FOLDER_JAVA)/build/classes \
-classpath $(PROJECT_SDK)/platforms/android-15/android.jar \
$(FINAL_FILE_ABSTRACTION) \
$(EWOL_FOLDER)/Java/src/org/ewol/interfaceJNI.java \
$(EWOL_FOLDER)/Java/src/org/ewol/interfaceOpenGL.java \
$(EWOL_FOLDER)/Java/src/org/ewol/interfaceSurfaceView.java \
$(EWOL_FOLDER)/Java/src/org/ewol/interfaceAudio.java \
$(FINAL_FOLDER_JAVA)/src/R.java
@echo ".dex <== .class"
$(Q)$(PROJECT_SDK)/platform-tools/dx \
--dex --no-strict \
--output=$(FINAL_FOLDER_JAVA)/build/$(CONFIG2___EWOL_APPL_NAME__).dex \
$(FINAL_FOLDER_JAVA)/build/classes/
@echo ".apk <== .dex, assets, .so, res"
$(Q)$(PROJECT_SDK)/tools/apkbuilder \
$(FINAL_FOLDER_JAVA)/build/$(CONFIG2___EWOL_APPL_NAME__)-unalligned.apk \
-u \
-z $(FINAL_FOLDER_JAVA)/resources.res \
-f $(FINAL_FOLDER_JAVA)/build/$(CONFIG2___EWOL_APPL_NAME__).dex \
-rf $(FINAL_FOLDER_JAVA)/data
@# doc :
@# http://developer.android.com/tools/publishing/app-signing.html
@# keytool is situated in $(JAVA_HOME)/bin ...
$(if $(wildcard ./$(CONFIG2___EWOL_APPL_NAME__)-$(BUILD_DIRECTORY_MODE).jks),$(empty), \
$(Q)echo "./$(CONFIG2___EWOL_APPL_NAME__).jks <== dynamic key (NOTE : It might ask some question to generate the key for android)" ; \
keytool -genkeypair -v \
-keystore ./$(CONFIG2___EWOL_APPL_NAME__)-$(BUILD_DIRECTORY_MODE).jks \
-storepass Pass$(CONFIG2___EWOL_APPL_NAME__) \
-alias alias$(CONFIG2___EWOL_APPL_NAME__) \
-keypass PassK$(CONFIG2___EWOL_APPL_NAME__) \
-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"
@#generate the pass file :
@echo "Pass$(CONFIG2___EWOL_APPL_NAME__)" > tmpPass.boo
@echo "PassK$(CONFIG2___EWOL_APPL_NAME__)" >> tmpPass.boo
@# verbose mode : -verbose
$(Q)jarsigner \
-sigalg MD5withRSA \
-digestalg SHA1 \
-keystore ./$(CONFIG2___EWOL_APPL_NAME__)-$(BUILD_DIRECTORY_MODE).jks \
$(FINAL_FOLDER_JAVA)/build/$(CONFIG2___EWOL_APPL_NAME__)-unalligned.apk \
alias$(CONFIG2___EWOL_APPL_NAME__) \
< tmpPass.boo
$(Q)rm tmpPass.boo
@echo "apk(aligned) <== apk"
@# verbose mode : -v
$(Q)zipalign 4 \
$(FINAL_FOLDER_JAVA)/build/$(CONFIG2___EWOL_APPL_NAME__)-unalligned.apk \
$(FINAL_FOLDER_JAVA)/$(CONFIG2___EWOL_APPL_NAME__).apk
install:
@echo ------------------------------------------------------------------------
@echo Install : $(TARGET_OUT_FINAL)/$(CONFIG2___EWOL_APPL_NAME__).apk
@echo ------------------------------------------------------------------------
@# $(PROJECT_SDK)/platform-tools/adb kill-server
@# install application
sudo $(PROJECT_SDK)/platform-tools/adb install -r $(FINAL_FOLDER_JAVA)/$(CONFIG2___EWOL_APPL_NAME__).apk
uninstall:
@echo ------------------------------------------------------------------------
@echo UnInstall : $(ANDROID_BASIC_FOLDER)bin/$(CONFIG2___EWOL_APPL_NAME__).apk
@echo ------------------------------------------------------------------------
@echo ... TODO ...