Added simple test android app and extended makefile to build it.
authorDaniel G <giri@nwrk.biz>
Fri, 25 Jan 2019 21:06:00 +0000 (22:06 +0100)
committerDaniel G <giri@nwrk.biz>
Fri, 25 Jan 2019 21:06:00 +0000 (22:06 +0100)
_template/src/Makefile
_template/src/android-src/AndroidManifest.xml [new file with mode: 0644]
_template/src/android-src/java/MainActivity.java [new file with mode: 0644]
_template/src/android-src/res/layout/activity_main.xml [new file with mode: 0644]
_template/src/android-src/res/values/strings.xml [new file with mode: 0644]

index e51c0f6..bb661d0 100644 (file)
@@ -6,19 +6,19 @@
 ############################################################################
 
 ###################################
-#GENERAL | EDIT 1/7
+#GENERAL | EDIT 1/11
 ###################################
 WORKDIR = $(shell pwd)
 SOURCES := $(shell ls *.cxx)
 PROJNAME = _template
 LIBDIR =
-INC = -I$(WORKDIR)/../include -I$(WORKDIR)/../../include
+INC = -I$(WORKDIR)/../include
 LDFLAGS = -m32 -std=c++11 -static-libstdc++ -static-libgcc
 CFLAGS = -m32 -Wall -fexceptions -std=c++11 -static-libstdc++ -static-libgcc
 LIB = -lfltk_images -lfltk_png -lfltk_z -lfltk_jpeg -lfltk
 
 ###################################
-#GCC | EDIT 2/7
+#GCC | EDIT 2/11
 ###################################
 CC_GCC = gcc
 CXX_GCC = g++
@@ -27,14 +27,14 @@ LD_GCC = g++
 WINDRES_GCC =
 
 INC_GCC = $(INC)
-LIBDIR_GCC = -L$(WORKDIR)/../lib/linux32 -L$(WORKDIR)/../../lib/linux32
+LIBDIR_GCC = -L$(WORKDIR)/../lib/linux32
 CFLAGS_GCC = $(CFLAGS)
 RESINC_GCC =
 LDFLAGS_GCC = $(LDFLAGS)
-LIB_GCC = $(LIB) -lm -lpthread -lX11 -lxcb -lXau -lXdmcp -lbsd -lrt -ldl
+LIB_GCC = $(LIB) -lm -lpthread -lX11 -lbsd -lrt -ldl
 
 ###################################
-#MinGW | EDIT 3/7
+#MinGW | EDIT 3/11
 ###################################
 CC_WIN = i686-w64-mingw32-gcc
 CXX_WIN = i686-w64-mingw32-g++
@@ -43,14 +43,56 @@ LD_WIN = i686-w64-mingw32-g++
 WINDRES_WIN = i686-w64-mingw32-windres
 
 INC_WIN = $(INC)
-LIBDIR_WIN = -L$(WORKDIR)/../lib/mingw32 -L$(WORKDIR)/../../lib/mingw32
+LIBDIR_WIN = -L$(WORKDIR)/../lib/mingw32
 CFLAGS_WIN = $(CFLAGS) -mwindows -DWIN32 -DUSE_OPENGL32 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
 RESINC_WIN =
 LDFLAGS_WIN =  $(LDFLAGS) -static
 LIB_WIN = $(LIB) -mwindows -lole32 -luuid -lcomctl32 -lpthread
 
 ###################################
-#RELEASE GCC SETTINGS | EDIT: 4/7
+# ARM | EDIT 4/11
+###################################
+CC_ARM = arm-none-eabi-gcc
+CXX_ARM = arm-none-eabi-g++
+AR_ARM = arm-none-eabi-ar
+LD_ARM = arm-none-eabi-g++
+WINDRES_ARM =
+
+INC_ARM= $(INC)
+LIBDIR_ARM = -L$(WORKDIR)/../lib/arm
+CFLAGS_ARM  = $(CFLAGS)
+RESINC_ARM =
+LDFLAGS_ARM  =  $(LDFLAGS) -static
+LIB_ARM  = $(LIB) -lm -lpthread -lNX11 -lbsd -lrt -ldl
+
+###################################
+# ANDROID | EDIT 5/11
+###################################
+JAVA_HOME=/usr/lib/jvm/java-1.12.0-openjdk-amd64/
+ANDROID_SDK_ROOT=/usr/lib/android-sdk/
+ANDROID_BUILD_TOOLS_VERSION=25.0.0
+ANDROID_PLATORM=android-23
+ANDROID_KEYSTORE_PATH=~/.android/debug.keystore
+ANDROID_KEYSTORE_NAME=androiddebugkey
+ANDROID_KEYSTORE_PW=android
+ANDROID_CP=$(ANDROID_SDK_ROOT)/platforms/$(ANDROID_PLATORM)/android.jar
+AAPT=$(ANDROID_SDK_ROOT)/build-tools/$(ANDROID_BUILD_TOOLS_VERSION)/aapt
+DX=$(ANDROID_SDK_ROOT)/build-tools/$(ANDROID_BUILD_TOOLS_VERSION)/dx
+ZIPALIGN=$(ANDROID_SDK_ROOT)/build-tools/$(ANDROID_BUILD_TOOLS_VERSION)/zipalign
+JAVAC=$(JAVA_HOME)/bin/javac
+JARSIGNER=$(JAVA_HOME)/bin/jarsigner
+
+GENDIR_ANDROID=$(WORKDIR)/obj/Android/gen
+CLASSDIR_ANDROID=$(WORKDIR)/obj/Android/class
+OUT_ANDROID=$(WORKDIR)/bin/Android
+
+# Android app src subdirectory
+ANDROID_SRC=$(WORKDIR)/android-src
+ANDROID_SOURCES=$(shell find $(ANDROID_SRC) -name *.java)
+
+
+###################################
+#RELEASE GCC SETTINGS | EDIT: 6/11
 ###################################
 INC_RELEASE_GCC = $(INC_GCC)
 CFLAGS_RELEASE_GCC = $(CFLAGS_GCC) -O2
@@ -64,7 +106,7 @@ DEP_RELEASE_GCC =
 OUT_RELEASE_GCC = bin/Release_Linux
 
 ###################################
-#DEBUG GCC SETTINGS | EDIT: 5/7
+#DEBUG GCC SETTINGS | EDIT: 7/11
 ###################################
 INC_DEBUG_GCC = $(INC_GCC)
 CFLAGS_DEBUG_GCC = $(CFLAGS_GCC) -g
@@ -78,7 +120,7 @@ DEP_DEBUG_GCC =
 OUT_DEBUG_GCC = bin/Debug_Linux
 
 ###################################
-#RELEASE MinGW SETTINGS | EDIT: 6/7
+#RELEASE MinGW SETTINGS | EDIT: 8/11
 ###################################
 INC_RELEASE_WIN = $(INC_WIN)
 CFLAGS_RELEASE_WIN = $(CFLAGS_WIN) -O2
@@ -92,7 +134,7 @@ DEP_RELEASE_WIN =
 OUT_RELEASE_WIN = bin/Release_Windows
 
 ###################################
-#DEBUG MinGW SETTINGS | EDIT: 7/7
+#DEBUG MinGW SETTINGS | EDIT: 9/11
 ###################################
 INC_DEBUG_WIN = $(INC_WIN)
 CFLAGS_DEBUG_WIN = $(CFLAGS_WIN) -g
@@ -105,6 +147,34 @@ OBJDIR_DEBUG_WIN = obj/Debug_Windows
 DEP_DEBUG_WIN =
 OUT_DEBUG_WIN = bin/Debug_Windows
 
+###################################
+#RELEASE ARM SETTINGS | EDIT: 10/11
+###################################
+INC_RELEASE_ARM = $(INC_ARM)
+CFLAGS_RELEASE_ARM = $(CFLAGS_ARM) -O2
+RESINC_RELEASE_ARM = $(RESINC_ARM)
+RCFLAGS_RELEASE_ARM = $(RCFLAGS_ARM)
+LIBDIR_RELEASE_ARM = $(LIBDIR_ARM)
+LIB_RELEASE_ARM= $(LIB_ARM)
+LDFLAGS_RELEASE_ARM = $(LDFLAGS_ARM) -s
+OBJDIR_RELEASE_ARM = obj/Release_ARM
+DEP_RELEASE_ARM =
+OUT_RELEASE_ARM = bin/Release_ARM
+
+###################################
+#DEBUG ARM SETTINGS | EDIT: 11/11
+###################################
+INC_DEBUG_ARM = $(INC_ARM)
+CFLAGS_DEBUG_ARM = $(CFLAGS_ARM) -g
+RESINC_DEBUG_ARM = $(RESINC_ARM)
+RCFLAGS_DEBUG_ARM = $(RCFLAGS_ARM)
+LIBDIR_DEBUG_ARM = $(LIBDIR_ARM)
+LIB_DEBUG_ARM = $(LIB_ARM)
+LDFLAGS_DEBUG_ARM = $(LDFLAGS_ARM)
+OBJDIR_DEBUG_ARM = obj/Debug_ARM
+DEP_DEBUG_ARM =
+OUT_DEBUG_ARM = bin/Debug_ARM
+
 ############################
 #OBJECT LISTS | DO NOT EDIT!
 ############################
@@ -112,6 +182,8 @@ OBJ_DEBUG_GCC = $(addprefix $(OBJDIR_DEBUG_GCC)/,$(SOURCES:%.cxx=%.o))
 OBJ_RELEASE_GCC = $(addprefix $(OBJDIR_RELEASE_GCC)/,$(SOURCES:%.cxx=%.o))
 OBJ_DEBUG_WIN = $(addprefix $(OBJDIR_DEBUG_WIN)/,$(SOURCES:%.cxx=%.o))
 OBJ_RELEASE_WIN = $(addprefix $(OBJDIR_RELEASE_WIN)/,$(SOURCES:%.cxx=%.o))
+OBJ_DEBUG_ARM = $(addprefix $(OBJDIR_DEBUG_ARM)/,$(SOURCES:%.cxx=%.o))
+OBJ_RELEASE_ARM = $(addprefix $(OBJDIR_RELEASE_ARM)/,$(SOURCES:%.cxx=%.o))
 
 ##########################
 #FUNCTIONS | DO NOT EDIT!
@@ -210,4 +282,69 @@ clean_release_windows:
        rm -rf $(OUT_RELEASE_WIN)
        rm -rf $(OBJDIR_RELEASE_WIN)
 
-.PHONY: before_debug_linux out_debug_linux after_debug_linux before_release_linux out_release_linux after_release_linux before_debug_windows out_debug_windows after_debug_windows before_release_windows out_release_windows after_release_windows
+######## DEBUG ARM
+before_debug_arm:
+       test -d $(OUT_DEBUG_ARM) || mkdir -p $(OUT_DEBUG_ARM)
+       test -d $(OBJDIR_DEBUG_ARM) || mkdir -p $(OBJDIR_DEBUG_ARM)
+
+after_debug_arm:
+
+debug_arm: before_debug_arm out_debug_arm after_debug_arm
+
+out_debug_arm: before_debug_arm $(OBJ_DEBUG_ARM) $(DEP_DEBUG_ARM)
+       $(LD_ARM) $(LDFLAGS_DEBUG_ARM) $(LIBDIR_ARM) $(LIBDIR_DEBUG_ARM) $(OBJ_DEBUG_ARM) $(LIB_DEBUG_ARM)  -o $(OUT_DEBUG_ARM)/$(PROJNAME)
+
+$(OBJDIR_DEBUG_ARM)/%.o: %.cxx
+       $(CXX_ARM) $(CFLAGS_DEBUG_ARM) $(INC_DEBUG_ARM) -c $< -D_DEBUG -o $@
+
+clean_debug_arm:
+       rm -f $(OBJ_DEBUG_ARM) $(OUT_DEBUG_ARM)/$(PROJNAME)
+       rm -rf $(OUT_DEBUG_ARM)
+       rm -rf $(OBJDIR_DEBUG_ARM)
+
+######## RELEASE ARM
+before_release_arm:
+       test -d $(OUT_RELEASE_ARM) || mkdir -p $(OUT_RELEASE_ARM)
+       test -d $(OBJDIR_RELEASE_ARM) || mkdir -p $(OBJDIR_RELEASE_ARM)
+
+after_release_arm:
+
+release_arm: before_release_arm out_release_arm after_release_arm
+
+out_release_arm: before_release_arm $(OBJ_RELEASE_ARM) $(DEP_RELEASE_ARM)
+       $(LD_ARM) $(LDFLAGS_RELEASE_ARM) $(LIBDIR_ARM) $(LIBDIR_RELEASE_ARM) $(OBJ_RELEASE_ARM) $(LIB_RELEASE_ARM)  -o $(OUT_RELEASE_ARM)/$(PROJNAME)
+
+$(OBJDIR_RELEASE_ARM)/%.o: %.cxx
+       $(CXX_ARM) $(CFLAGS_RELEASE_ARM) $(INC_RELEASE_ARM) -c $< -D_RELEASE -o $@
+
+clean_release_arm:
+       rm -f $(OBJ_RELEASE_ARM) $(OUT_RELEASE_ARM)/$(PROJNAME)
+       rm -rf $(OUT_RELEASE_ARM)
+       rm -rf $(OBJDIR_RELEASE_ARM)
+
+######## ANDROID APK
+before_android_apk:
+       test -d $(OUT_ANDROID) || mkdir -p $(OUT_ANDROID)
+       test -d $(GENDIR_ANDROID) || mkdir -p $(GENDIR_ANDROID)
+       test -d $(CLASSDIR_ANDROID) || mkdir -p $(CLASSDIR_ANDROID)
+       $(AAPT) package -f -m -J $(GENDIR_ANDROID) -M $(ANDROID_SRC)/AndroidManifest.xml -S $(ANDROID_SRC)/res -I $(ANDROID_CP)
+
+after_android_apk:
+       $(JARSIGNER) -keystore $(ANDROID_KEYSTORE_PATH) -storepass '$(ANDROID_KEYSTORE_PW)' $(GENDIR_ANDROID)/$(PROJNAME).apk.unaligned  $(ANDROID_KEYSTORE_NAME)
+       $(ZIPALIGN) -f 4 $(GENDIR_ANDROID)/$(PROJNAME).apk.unaligned  $(OUT_ANDROID)/$(PROJNAME).apk
+
+android_apk: before_android_apk out_apk after_android_apk
+
+out_apk: 
+       $(JAVAC) -classpath $(ANDROID_CP) -sourcepath 'src:$(GENDIR_ANDROID)' -d '$(CLASSDIR_ANDROID)' -target 1.7 -source 1.7 $(ANDROID_SOURCES)
+       $(DX) --dex --output=$(GENDIR_ANDROID)/classes.dex $(CLASSDIR_ANDROID)
+       $(AAPT) package -f -M $(ANDROID_SRC)/AndroidManifest.xml -S $(ANDROID_SRC)/res -I $(ANDROID_CP) -F $(GENDIR_ANDROID)/$(PROJNAME).apk.unaligned
+       cd $(GENDIR_ANDROID) && $(AAPT) add $(GENDIR_ANDROID)/$(PROJNAME).apk.unaligned classes.dex
+
+clean_android_apk:
+       rm -rf $(OUT_ANDROID)
+       rm -rf $(GENDIR_ANDROID)
+       rm -rf $(CLASSDIR_ANDROID)
+
+.PHONY: before_debug_linux out_debug_linux after_debug_linux before_release_linux out_release_linux after_release_linux before_debug_windows out_debug_windows after_debug_windows
+.PHONY: before_debug_arm out_debug_arm after_debug_arm before_release_arm out_release_arm after_release_arm before_release_windows out_release_windows after_release_windows
diff --git a/_template/src/android-src/AndroidManifest.xml b/_template/src/android-src/AndroidManifest.xml
new file mode 100644 (file)
index 0000000..89c25c7
--- /dev/null
@@ -0,0 +1,15 @@
+<manifest
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    package="com.giri.template">
+  <application
+      android:label="@string/app_name">
+    <activity
+        android:name=".MainActivity"
+        android:label="@string/app_name">
+      <intent-filter>
+        <action android:name="android.intent.action.MAIN"/>
+        <category android:name="android.intent.category.LAUNCHER"/>
+      </intent-filter>
+    </activity>
+  </application>
+</manifest>
\ No newline at end of file
diff --git a/_template/src/android-src/java/MainActivity.java b/_template/src/android-src/java/MainActivity.java
new file mode 100644 (file)
index 0000000..bbe0c24
--- /dev/null
@@ -0,0 +1,12 @@
+package com.giri.template;
+
+import android.app.Activity;
+import android.os.Bundle;
+
+public class MainActivity extends Activity {
+  @Override
+  protected void onCreate(Bundle savedInstanceState) {
+    super.onCreate(savedInstanceState);
+    setContentView(R.layout.activity_main);
+  }
+}
\ No newline at end of file
diff --git a/_template/src/android-src/res/layout/activity_main.xml b/_template/src/android-src/res/layout/activity_main.xml
new file mode 100644 (file)
index 0000000..2c5482a
--- /dev/null
@@ -0,0 +1,7 @@
+<TextView
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:text="@string/hello_world"
+    tools:context=".MainActivity"/>
\ No newline at end of file
diff --git a/_template/src/android-src/res/values/strings.xml b/_template/src/android-src/res/values/strings.xml
new file mode 100644 (file)
index 0000000..148b866
--- /dev/null
@@ -0,0 +1,4 @@
+<resources>
+  <string name="app_name">Hello World</string>
+  <string name="hello_world">Hello world!</string>
+</resources>
\ No newline at end of file