Hi
my first jni app and run into those android.mk problems:
SDL_SRCS := \
$(LOCAL_PATH)/src/*.c \
$(LOCAL_PATH)/src/*.cpp \
1: How should that look to include all .c and cpp files in src?
#LOCAL_SRC_FILES := $(foreach files $(SDL_SRCS), $(wildcard *.c)$
(files))
LOCAL_SRC_FILES := $(foreach F, $(SDL_SRCS), $(dir $(F)),$(notdir $
(wildcard $(LOCAL_PATH)/$(F))))
2: what libs to include?
LOCAL_LDLIBS := -llog -lGLESv2 -lm
the original c++ makefile has those:
LDFLAGS = -lm -lGL -lGLU -lglut
LIBOBJS =
LIBS = -L/usr/X11R6/lib -L/usr/lib -L/usr/lib -lGL -lGLU -lglut -lSDL -
lSDLmain -lSDL_mixer
Many thanks indeed
Michael
So this is a major news for devs, if you found your AOSP / CM build doesn't work, make sure that you have the following line enabled if you are using TARGET_ARCH_VARIANT := armv7-a :
TARGET_ARCH_VARIANT_FPU := vfpv3-d16
This is due to a bug in armv7-a.mk in CM repo that automatically set FPU to neno for no reason. (btw, I have already reported the bug, so lets see it get patched or not later)
btw DO NOT change the line of TARGET_ARCH_VARIANT_FPU to vfpv3, otherwise your CM / AOSP build will not boot @ all.
The following BoardConfig.mk is used for compiling CWM on my kernels. And it is working for compiling CWM on my machine. You can edit the line such as USE_CAMERA_STUB, TARGET_NO_RADIOIMAGE or TARGET_PREBUILT_KERNEL on your own. However do not edit the line since TARGET_CPU_ABI to BOARD_FLASH_BLOCK_SIZE as they are vital and already right for our I9103.
Code:
LOCAL_PATH := $(call my-dir)
#USE_CAMERA_STUB := true
# inherit from the proprietary version
-include vendor/samsung/I9103/BoardConfigVendor.mk
TARGET_CPU_ABI := armeabi-v7a
TARGET_CPU_ABI2 := armeabi
TARGET_ARCH_VARIANT := armv7-a
TARGET_ARCH_VARIANT_CPU := cortex-a9
# DO NOT change the following line to vfpv3 as it is not really supported on our device!
TARGET_ARCH_VARIANT_FPU := vfpv3-d16
TARGET_CPU_SMP := true
ARCH_ARM_HAVE_TLS_REGISTER := true
TARGET_HAVE_TEGRA_ERRATA_657451 := true
TARGET_BOARD_PLATFORM := tegra
TARGET_BOARD_PLATFORM_GPU := tegra # Useless for CM7 build
TARGET_BOOTLOADER_BOARD_NAME := n1
TARGET_USERIMAGES_USE_EXT4 := true
BOARD_KERNEL_CMDLINE :=
BOARD_KERNEL_BASE := 0x10000000
BOARD_KERNEL_PAGESIZE := 2048
# fix this up by examining /proc/mtd on a running device
# Boot image size is 16384 x 512 bytes = 8388608
# You can double check it with fdisk -l /dev/block/mmcblk0p8
BOARD_BOOTIMAGE_PARTITION_SIZE := 0x00800000
# Recovery image size is 10240 x 512 bytes = 5242880
# You can double check it with fdisk -l /dev/block/mmcblk0p8
BOARD_RECOVERYIMAGE_PARTITION_SIZE := 0x00500000
# System image size is 1228800 x 512 bytes = 629145600
# You can double check it with fdisk -l /dev/block/mmcblk0p2
BOARD_SYSTEMIMAGE_PARTITION_SIZE := 0x25800000
# User data image size is 4194304 x 512 bytes = 2147483648
# You can double check it with fdisk -l /dev/block/mmcblk0p6
BOARD_USERDATAIMAGE_PARTITION_SIZE := 0x80000000
BOARD_FLASH_BLOCK_SIZE := 2048
TARGET_PREBUILT_KERNEL := device/samsung/I9103/kernel
TARGET_NO_KERNEL := false
TARGET_NO_RECOVERY := false
TARGET_NO_BOOTLOADER := true
TARGET_NO_RADIOIMAGE := true
BOARD_HAS_NO_SELECT_BUTTON := true
# Use this flag if the board has a ext4 partition larger than 2gb
BOARD_HAS_LARGE_FILESYSTEM := true
btw I have an updated version of armv7-a.mk so that it should work on any device using armv7-a even when FPU is not defined. If your toolchain is complaing errors like the switch -mcpu is not working with -march, just remove the -mcpu switch on your own.
Code:
# Configuration for Linux on ARM.
# Generating binaries for the ARMv7-a architecture and higher
#
ARCH_ARM_HAVE_THUMB_SUPPORT := true
ARCH_ARM_HAVE_FAST_INTERWORKING := true
ARCH_ARM_HAVE_64BIT_DATA := true
ARCH_ARM_HAVE_HALFWORD_MULTIPLY := true
ARCH_ARM_HAVE_CLZ := true
ARCH_ARM_HAVE_FFS := true
ARCH_ARM_HAVE_ARMV7A := true
ifeq ($(strip $(TARGET_ARCH_VARIANT_FPU)),)
ARCH_ARM_HAVE_VFP := false
else
ARCH_ARM_HAVE_VFP := true
endif
ifeq ($(strip $(TARGET_ARCH_VARIANT_FPU)),neon)
ARCH_ARM_HAVE_NEON := true
endif
ifeq ($(strip $(TARGET_CPU_SMP)),true)
ARCH_ARM_HAVE_TLS_REGISTER := true
endif
arch_variant_cflags := \
-march=armv7-a \
-mtune=$(strip $(TARGET_ARCH_VARIANT_CPU)) \
-mcpu=$(strip $(TARGET_ARCH_VARIANT_CPU)) \
-D__ARM_ARCH_7__ \
-D__ARM_ARCH_7A__
ifeq ($(strip $(ARCH_ARM_HAVE_VFP)),true)
ifeq ($(strip $(ARCH_ARM_HAVE_NEON)),true)
arch_variant_cflags += -D__ARM_NEON__ -D__ARM_HAVE_NEON
else
arch_variant_cflags += -D__VFP_FP__ -D__ARM_HAVE_VFP
endif
arch_variant_cflags += -mfloat-abi=softfp -mfpu=$(strip $(TARGET_ARCH_VARIANT_FPU))
else
arch_variant_cflags += -mfloat-abi=soft
endif
ifeq ($(strip $(TARGET_ARCH_VARIANT_CPU)),cortex-a8)
arch_variant_ldflags := \
-Wl,--fix-cortex-a8
else
arch_variant_ldflags :=
endif
In addition, please look at the required errata for building stuffs on our device.
As our device is using an epic old ARM cpu, it means that it may have errata inside. Errata means errors on the hardware that cannot be fixed, however can be bypassed with errata patch.
In conjunction with finding the required errata patch, this is our cpuinfo
cat /proc/cpuinfo
Processor : ARMv7 Processor rev 0 (v7l)
processor : 0
BogoMIPS : 999.42
processor : 1
BogoMIPS : 999.42
Features : swp half thumb fastmult vfp edsp vfpv3 vfpv3d16
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x1
CPU part : 0xc09
CPU revision : 0
Hardware : n1
Revision : 000d
Serial : 304d11d0943807ae
So next time when you try to make a custom kernel or port a kernel to this device, keep an eye on those errata please. Nvidia git sometimes made patch for those erratas as well.
For example, TARGET_HAVE_TEGRA_ERRATA_657451 is a config value telling that the src code to enable errata #657451 patch for our device. (And I have enabled that in our BoardConfig.mk already.)
Now though it sounds sad it works, but in that case does LG O2X's ARM also belong to our family of devices ?
.....that just kinda destroyed my hopes
This was sent from a Galaxy Ace. Problem?
'cooleagle' said:
Now though it sounds sad it works, but in that case does LG O2X's ARM also belong to our family of devices ?
Click to expand...
Click to collapse
its got the same AP20H tegra 2 processor i think
Because of this is it difficult to get ics .....
How its going to effect us......
according to Google policy company should provide s/w updates atleast for 16 months ....... So samy should provide ics update for us at that time they should correct the algorithms .... i am totally disturbed after seeing this.......
Sent from my GT-I9103 using XDA
mj.vikram said:
Because of this is it difficult to get ics .....
How its going to effect us......
according to Google policy company should provide s/w updates atleast for 16 months ....... So samy should provide ics update for us at that time they should correct the algorithms .... i am totally disturbed after seeing this.......
Sent from my GT-I9103 using XDA
Click to expand...
Click to collapse
Don't lose sleep over it. S2's design was also started in 2010.
We'll get ICS as LG O2X which has the same SOC is going to get it, moreover Samsung India has confirmed that this device is capable of being upgraded to ICS so sit tight till it arrives.
Please check the first topic again, it includes a specific change to BoardConfig.mk that allows anyone to build AOSP / CM for our board. Otherwise your CM7 won't boot from that.
UnknownzD said:
Please check the first topic again, it includes a specific change to BoardConfig.mk that allows anyone to build AOSP / CM for our board. Otherwise your CM7 won't boot from that.
Click to expand...
Click to collapse
Damn! you're good!
Where have you been all this time!
Thanks for all this good info!
UnknownzD you are Rolling in the Deep !
Hope to hear lots of goods news & info from you in near future man, keep them coming buddy . . . !
Cheers ! :beer:
FranzJesus said:
Damn! you're good!
Where have you been all this time!
Thanks for all this good info!
Click to expand...
Click to collapse
In case your build still doesn't work, create a armv7-a-test.mk file under /build/core/combo/arch/arm/ and then place the following lines into it. This is the working one that I can built CWM on top of it.
---------------------------------------------------------------------------
# Configuration for Linux on ARM.
# Generating binaries for the ARMv5TE architecture and higher
#
ARCH_ARM_HAVE_THUMB_SUPPORT := true
ARCH_ARM_HAVE_FAST_INTERWORKING := true
ARCH_ARM_HAVE_64BIT_DATA := true
ARCH_ARM_HAVE_HALFWORD_MULTIPLY := true
ARCH_ARM_HAVE_CLZ := true
ARCH_ARM_HAVE_FFS := true
ARCH_ARM_HAVE_ARMV7A := true
#ARCH_ARM_HAVE_VFP := true
# Note: Hard coding the 'tune' value here is probably not ideal,
# and a better solution should be found in the future.
#
arch_variant_cflags := \
-march=armv7-a \
-mtune=$(strip $(TARGET_ARCH_VARIANT_CPU)) \
-mcpu=$(strip $(TARGET_ARCH_VARIANT_CPU)) \
# -mfloat-abi=softfp \
# -mfpu=$(strip $(TARGET_ARCH_VARIANT_FPU)) \
-D__ARM_ARCH_7__ \
-D__ARM_ARCH_7A__
# -D__ARM_ARCH_5__ \
# -D__ARM_ARCH_5T__ \
# -D__ARM_ARCH_5E__ \
# -D__ARM_ARCH_5TE__
---------------------------------------------------------------------------
btw, you have to put the the first 2 lines into your BoardConfig.mk in order to enable it. The third line is optional unless you want enable the vfp calculation (which should be the one causing problem).
TARGET_ARCH_VARIANT := armv7-a-test
TARGET_ARCH_VARIANT_CPU := cortex-a9
TARGET_ARCH_VARIANT_FPU := vfpv3
I am still testing on what caused the problem. Seems like the vfp (floating point calculation) has a strong relationship to the halt problem.
Edited : Okay I have confirmed, the VFP part should be the one causing issue. You may want to disable it first and I will work that out later (to find where the bug is).
Where have you been Mate?? Awesome Work!! Continue!!
So I have figured out our right BoardConfig.mk. Do not change the TARGET_ARCH_VARIANT_FPU, otherwise the boot.img won't boot @ all.
LOCAL_PATH := $(call my-dir)
#USE_CAMERA_STUB := true
# inherit from the proprietary version
-include vendor/samsung/I9103/BoardConfigVendor.mk
TARGET_CPU_ABI := armeabi-v7a
TARGET_CPU_ABI2 := armeabi
TARGET_ARCH_VARIANT := armv7-a
TARGET_ARCH_VARIANT_CPU := cortex-a9
# DO NOT change the following line to vfpv3 as it is not supported on our device!
TARGET_ARCH_VARIANT_FPU := vfpv3-d16
TARGET_CPU_SMP := true
ARCH_ARM_HAVE_TLS_REGISTER := true
TARGET_HAVE_TEGRA_ERRATA_657451 := true
TARGET_BOARD_PLATFORM := tegra
TARGET_BOARD_PLATFORM_GPU := tegra # Useless for CM7 build
TARGET_BOOTLOADER_BOARD_NAME := n1
TARGET_USERIMAGES_USE_EXT4 := true
BOARD_KERNEL_CMDLINE :=
BOARD_KERNEL_BASE := 0x10000000
BOARD_KERNEL_PAGESIZE := 2048
# fix this up by examining /proc/mtd on a running device
# Boot image size is 16384 x 512 bytes = 8388608
# You can double check it with fdisk -l /dev/block/mmcblk0p8
BOARD_BOOTIMAGE_PARTITION_SIZE := 0x00800000
# Recovery image size is 10240 x 512 bytes = 5242880
# You can double check it with fdisk -l /dev/block/mmcblk0p8
BOARD_RECOVERYIMAGE_PARTITION_SIZE := 0x00500000
# System image size is 1228800 x 512 bytes = 629145600
# You can double check it with fdisk -l /dev/block/mmcblk0p2
BOARD_SYSTEMIMAGE_PARTITION_SIZE := 0x25800000
# User data image size is 4194304 x 512 bytes = 2147483648
# You can double check it with fdisk -l /dev/block/mmcblk0p6
BOARD_USERDATAIMAGE_PARTITION_SIZE := 0x80000000
BOARD_FLASH_BLOCK_SIZE := 2048
TARGET_PREBUILT_KERNEL := device/samsung/I9103/kernel
TARGET_NO_KERNEL := false
TARGET_NO_RECOVERY := false
TARGET_NO_BOOTLOADER := true
TARGET_NO_RADIOIMAGE := true
BOARD_HAS_NO_SELECT_BUTTON := true
# Use this flag if the board has a ext4 partition larger than 2gb
BOARD_HAS_LARGE_FILESYSTEM := true
btw the errata fix is for our cpu and is only needed on userland (non-kernel side binary), do not remove that errata fix otherwise the SMP part doesn't work. It requires the errata patch to make it working.
UnknownzD said:
So I have figured out our right BoardConfig.mk. Do not change the TARGET_ARCH_VARIANT_FPU, otherwise the boot.img won't boot @ all.
LOCAL_PATH := $(call my-dir)
#USE_CAMERA_STUB := true
# inherit from the proprietary version
-include vendor/samsung/I9103/BoardConfigVendor.mk
TARGET_CPU_ABI := armeabi-v7a
TARGET_CPU_ABI2 := armeabi
TARGET_ARCH_VARIANT := armv7-a
TARGET_ARCH_VARIANT_CPU := cortex-a9
# DO NOT change the following line to vfpv3 as it is not supported on our device!
TARGET_ARCH_VARIANT_FPU := vfpv3-d16
TARGET_CPU_SMP := true
ARCH_ARM_HAVE_TLS_REGISTER := true
TARGET_HAVE_TEGRA_ERRATA_657451 := true
TARGET_BOARD_PLATFORM := tegra
TARGET_BOARD_PLATFORM_GPU := tegra # Useless for CM7 build
TARGET_BOOTLOADER_BOARD_NAME := n1
TARGET_USERIMAGES_USE_EXT4 := true
BOARD_KERNEL_CMDLINE :=
BOARD_KERNEL_BASE := 0x10000000
BOARD_KERNEL_PAGESIZE := 2048
# fix this up by examining /proc/mtd on a running device
# Boot image size is 16384 x 512 bytes = 8388608
# You can double check it with fdisk -l /dev/block/mmcblk0p8
BOARD_BOOTIMAGE_PARTITION_SIZE := 0x00800000
# Recovery image size is 10240 x 512 bytes = 5242880
# You can double check it with fdisk -l /dev/block/mmcblk0p8
BOARD_RECOVERYIMAGE_PARTITION_SIZE := 0x00500000
# System image size is 1228800 x 512 bytes = 629145600
# You can double check it with fdisk -l /dev/block/mmcblk0p2
BOARD_SYSTEMIMAGE_PARTITION_SIZE := 0x25800000
# User data image size is 4194304 x 512 bytes = 2147483648
# You can double check it with fdisk -l /dev/block/mmcblk0p6
BOARD_USERDATAIMAGE_PARTITION_SIZE := 0x80000000
BOARD_FLASH_BLOCK_SIZE := 2048
TARGET_PREBUILT_KERNEL := device/samsung/I9103/kernel
TARGET_NO_KERNEL := false
TARGET_NO_RECOVERY := false
TARGET_NO_BOOTLOADER := true
TARGET_NO_RADIOIMAGE := true
BOARD_HAS_NO_SELECT_BUTTON := true
# Use this flag if the board has a ext4 partition larger than 2gb
BOARD_HAS_LARGE_FILESYSTEM := true
Click to expand...
Click to collapse
Compiling a CM7 build right now!!!
Will be back soon...
Thank you soo much!!
FranzJesus said:
Compiling a CM7 build right now!!!
Will be back soon...
Thank you soo much!!
Click to expand...
Click to collapse
If you guys want to see the difference between the old armv7-a.mk and my version, look it here : http://review.cyanogenmod.com/#/c/15478/1/core/combo/arch/arm/armv7-a.mk
Now I need some time to finish my CWM, by working on the ramdisk.
I have a minor update on the first post as changing the line
TARGET_ARCH_VARIANT_FPU := vfpv3
to
TARGET_ARCH_VARIANT_FPU := vfpv3-d16
That is because our device won't boot with the code compiled with -mfpu=vfpv3. Please refer to the first post for more info.
Wow you're good . My hat's off to you sire
This was sent from a Galaxy Ace. Problem?
Will the errata patch update the ARMv7 revision ?
This was sent from a Galaxy Ace. Problem?
EmoBoiix3 said:
Will the errata patch update the ARMv7 revision ?
This was sent from a Galaxy Ace. Problem?
Click to expand...
Click to collapse
The errata patch does not update the ARM revision (if you are talking the one captured from cpuinfo). That is because basically all the erratas cannot be patched as it is a hardware problem or bug. However, we can avoid such thing happens (such as errata in race condition) by applying the so called 'patch'. Therefore those patches are NOT fixing the problem at all, instead they just try to avoid it.
UnknownzD said:
The errata patch does not update the ARM revision (if you are talking the one captured from cpuinfo). That is because basically all the erratas cannot be patched as it is a hardware problem or bug. However, we can avoid such thing happens (such as errata in race condition) by applying the so called 'patch'. Therefore those patches are NOT fixing the problem at all, instead they just try to avoid it.
Click to expand...
Click to collapse
Ohh , you meant by workarounds !
I am trying to compile a simple program with ndk-build that uses functions from the OpenSSL libcrypto.so shared library, but I have some errors:
This is my Android.mk
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := lib-crypto
LOCAL_SRC_FILES := libcrypto.so
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := tema1
LOCAL_SRC_FILES := tema1.c
LOCAL_SHARED_LIBRARIES := lib-crypto
LOCAL_C_INCLUDES := /home/aleksei/openSSL0.9.8/include
include $(BUILD_EXECUTABLE)
libcrypto.so is the library that I have built for android. I want to make a program using it. Now it gives me this error:
Install : libcrypto.so => libs/armeabi/libcrypto.so
Executable : tema1
./obj/local/armeabi/libcrypto.so: undefined reference to `dladdr'
collect2: ld returned 1 exit status
make: *** [obj/local/armeabi/tema1] Error 1
What am I doing wrong?
Code:
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=4.2.2
TARGET_PRODUCT=aokp_p3110
TARGET_BUILD_VARIANT=userdebug
TARGET_BUILD_TYPE=release
TARGET_BUILD_APPS=
TARGET_ARCH=arm
TARGET_ARCH_VARIANT=armv7-a-neon
HOST_ARCH=x86
HOST_OS=linux
HOST_OS_EXTRA=Linux-3.5.0-17-generic-x86_64-with-LinuxMint-14-nadia
HOST_BUILD_TYPE=release
BUILD_ID=JDQ39
OUT_DIR=/home/arun/aokp/out
============================================
Checking build tools versions...
grep: /bltsville/gcbv/version.h: No such file or directory
ls: cannot access /bltsville/ticpu/lib/android/libbltsville_*.*.so: No such file or directory
build/core/base_rules.mk:130: *** device/samsung/p3100/power: MODULE.TARGET.SHARED_LIBRARIES.power.piranha already defined by device/samsung/omap4-common/libpower. Stop.
Contents of both files...
OMAP4-Common/libpower
Code:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := power.$(TARGET_BOOTLOADER_BOARD_NAME)
LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/hw
LOCAL_SRC_FILES := power.c
#LOCAL_SHARED_LIBRARIES := liblog
#LOCAL_MODULE_TAGS := optional
include $(BUILD_SHARED_LIBRARY)
P3100/power
Code:
LOCAL_PATH := $(call my-dir)
# HAL module implemenation stored in
# hw/<POWERS_HARDWARE_MODULE_ID>.<ro.hardware>.so
include $(CLEAR_VARS)
LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/hw
LOCAL_SHARED_LIBRARIES := liblog libcutils
LOCAL_SRC_FILES := power_piranha.c
LOCAL_MODULE := power.piranha
LOCAL_MODULE_TAGS := optional
include $(BUILD_SHARED_LIBRARY)
Solution needed urgently please..
Solved.
Got new error
Code:
make: *** No rule to make target `device/samsung/omap4-common/bltsville/ticpu/lib/android/libbltsville_ticpu.', needed by `/home/arun/aokp/out/target/product/p3110/obj/lib/libbltsville_ticpu.'. Stop.
What changes will be needed in make file to solve it ?
Android.mk
Code:
LOCAL_PATH := $(call my-dir)
#Copying libbltsville_ticpu.BV_CPUVERSION.so
include $(CLEAR_VARS)
BV_CPUVERSION :=$(shell ls $(COMMON_PATH)/bltsville/ticpu/lib/android/libbltsville_*.*.so|\
sed 's/device\/samsung\/omap4-common\/bltsville\/ticpu\/lib\/android\/libbltsville_ticpu.//')
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_CLASS := SHARED_LIBRARIES
LOCAL_MODULE := libbltsville_ticpu.$(BV_CPUVERSION)
LOCAL_SRC_FILES := lib/android/libbltsville_ticpu.$(BV_CPUVERSION)
LOCAL_MODULE_PATH:= $(TARGET_OUT_VENDOR)/lib
include $(BUILD_PREBUILT)
#Creating SymLinks
#libbltsville_ticpu.so -> libbltsville_ticpu.BV_CPUVERSION.so
#libbltsville_cpu.so -> libbltsville_ticpu.so
SYMLINKS := $(TARGET_OUT_VENDOR)/lib/libbltsville_ticpu.so
$(SYMLINKS): TICPU_BINARY := ./libbltsville_ticpu.$(BV_CPUVERSION)
$(SYMLINKS): $(LOCAL_INSTALLED_MODULE) $(LOCAL_PATH)/Android.mk
[user=279333]@ECHO[/user] "Symlink: [email protected] -> $(TICPU_BINARY)"
[user=4143519]@mkdir[/user] -p $(dir [email protected])
[user=1516568]@rm -rf[/user] [email protected]
$(hide) ln -fs $(TICPU_BINARY) [email protected]
@cp -afr $(COMMON_PATH)/bltsville/ticpu/lib/android/libbltsville_ticpu_license.txt $(TARGET_OUT_VENDOR)/lib
ALL_DEFAULT_INSTALLED_MODULES += $(SYMLINKS)
SYMLINKS1 := $(TARGET_OUT_VENDOR)/lib/libbltsville_cpu.so
$(SYMLINKS1): LINK_BINARY := ./libbltsville_ticpu.so
$(SYMLINKS1): $(LOCAL_INSTALLED_MODULE) $(LOCAL_PATH)/Android.mk
[user=279333]@ECHO[/user] "Symlink: [email protected] -> $(LINK_BINARY)"
[user=4143519]@mkdir[/user] -p $(dir [email protected])
[user=1516568]@rm -rf[/user] [email protected]
$(hide) ln -fs $(LINK_BINARY) [email protected]
ALL_DEFAULT_INSTALLED_MODULES += $(SYMLINKS1)
# for mm
all_modules: $(SYMLINKS) $(SYMLINKS1)
Since PAC partially based on AOKP, I am sure @Nick0703 would be willing to help if you get into trouble. Good luck :good:
bro i am glad that you are developing aokp 4.2.2 for tab 2.
thanks.
I know its an useless reply
The master branch of SELinux doesn't include native android support,
and the external selinux repo from google is limited and only targets host for tools.
You can make a few edits to get some useful binaries to use on Android on master branch
even though libsepol and libselinux aren't patched for android compliance, the tools are still useful.
dispol for example allows you to dump sepolicy rules for everything, for example you could recreate the supersu.te if you wanted.
checkpolicy allows you to write out a new sepolicy with edits.
getfilecon and setfilecon are very useful for getting contexts and setting contexts.
I only enabled a few binaries, but there are many more you can add by following the examples in the Android.mkby default it builds:
checkmodule
checkpolicy
chkcon
dismod
dispol
getfilecon
sefcontext_compile
setfilecon
I thought id share this here as folks often only use libsepol for sepolicy-inject and as security gets tighter it will be useful to know how to compile for target devices.
dispol is very useful, selecting a file to output to and then choosing option 1 dumps all rules.
also you can see specific rules, such as the filename_trans rule I implemented for Substratum's Interfacer,
allowing it to auto set the contexts on files it creates in /data/system/theme to "theme_data_file"
Select a command:
1) display unconditional AVTAB
2) display conditional AVTAB (entirely)
3) display conditional AVTAB (only ENABLED rules)
4) display conditional AVTAB (only DISABLED rules)
5) display conditional bools
6) display conditional expressions
7) change a boolean value
8) display role transitions
c) display policy capabilities
p) display the list of permissive types
u) display unknown handling setting
F) display filename_trans rules
f) set output file
m) display menu
q) quit
Command ('m' for menu): F
filename_trans rules:
ueventd device :chr_file klog_device __kmsg__
wpa wifi_data_file :dir wpa_socket sockets
interfacer system_data_file :file theme_data_file theme
system_server system_data_file :sock_file system_ndebug_socket ndebugsocket
hostapd wifi_data_file :dir wpa_socket hostapd
hostapd wifi_data_file :dir wpa_socket sockets
Command ('m' for menu): p
permissive sids:
recovery
su
supersu
Command ('m' for menu):
similarly checkpolicy makes it easy to write out a new policy
angler:/ $ checkpolicy /sepolicy -b -d -M -c 30 -o /sdcard/sepolicy.new
checkpolicy: loading policy configuration from /sepolicy
libsepol.policydb_index_others: security: 1 users, 2 roles, 801 types, 0 bools
libsepol.policydb_index_others: security: 1 sens, 1024 cats
libsepol.policydb_index_others: security: 63 classes, 13466 rules, 0 cond rules
checkpolicy: policy configuration loaded
checkpolicy: writing binary representation (version 30) to /sdcard/sepolicy.new
Theres quite a bit of trickery/makefile l33tness going on, so id encourage you to understand/look at this Sexy af Android.mk below, considering this is where most of the magic happens.
Code:
LOCAL_PATH:= $(call my-dir)
libselinux_src_files := \
libselinux/src/audit2why.c \
libselinux/src/avc.c \
libselinux/src/avc_internal.c \
libselinux/src/avc_sidtab.c \
libselinux/src/booleans.c \
libselinux/src/callbacks.c \
libselinux/src/canonicalize_context.c \
libselinux/src/checkAccess.c \
libselinux/src/check_context.c \
libselinux/src/checkreqprot.c \
libselinux/src/compute_av.c \
libselinux/src/compute_create.c \
libselinux/src/compute_member.c \
libselinux/src/compute_relabel.c \
libselinux/src/compute_user.c \
libselinux/src/context.c \
libselinux/src/deny_unknown.c \
libselinux/src/disable.c \
libselinux/src/enabled.c \
libselinux/src/fgetfilecon.c \
libselinux/src/freecon.c \
libselinux/src/freeconary.c \
libselinux/src/fsetfilecon.c \
libselinux/src/get_context_list.c \
libselinux/src/get_default_type.c \
libselinux/src/get_initial_context.c \
libselinux/src/getenforce.c \
libselinux/src/getfilecon.c \
libselinux/src/getpeercon.c \
libselinux/src/init.c \
libselinux/src/is_customizable_type.c \
libselinux/src/label.c \
libselinux/src/label_backends_android.c \
libselinux/src/label_db.c \
libselinux/src/label_file.c \
libselinux/src/label_media.c \
libselinux/src/label_support.c \
libselinux/src/label_x.c \
libselinux/src/lgetfilecon.c \
libselinux/src/load_policy.c \
libselinux/src/lsetfilecon.c \
libselinux/src/mapping.c \
libselinux/src/matchmediacon.c \
libselinux/src/matchpathcon.c \
libselinux/src/policyvers.c \
libselinux/src/procattr.c \
libselinux/src/query_user_context.c \
libselinux/src/regex.c \
libselinux/src/selinux_check_securetty_context.c \
libselinux/src/selinux_config.c \
libselinux/src/selinux_restorecon.c \
libselinux/src/sestatus.c \
libselinux/src/setenforce.c \
libselinux/src/setexecfilecon.c \
libselinux/src/setfilecon.c \
libselinux/src/setrans_client.c \
libselinux/src/seusers.c \
libselinux/src/sha1.c \
libselinux/src/stringrep.c
libselinux_android_srcs := \
libselinux/src/android/android.c \
libselinux/src/android/android_host.c \
common_src_files := \
libsepol/src/assertion.c \
libsepol/src/avrule_block.c \
libsepol/src/avtab.c \
libsepol/src/boolean_record.c \
libsepol/src/booleans.c \
libsepol/src/conditional.c \
libsepol/src/constraint.c \
libsepol/src/context.c \
libsepol/src/context_record.c \
libsepol/src/debug.c \
libsepol/src/ebitmap.c \
libsepol/src/expand.c \
libsepol/src/genbools.c \
libsepol/src/genusers.c \
libsepol/src/handle.c \
libsepol/src/hashtab.c \
libsepol/src/hierarchy.c \
libsepol/src/ibendport_record.c \
libsepol/src/ibendports.c \
libsepol/src/ibpkey_record.c \
libsepol/src/ibpkeys.c \
libsepol/src/iface_record.c \
libsepol/src/interfaces.c \
libsepol/src/kernel_to_cil.c \
libsepol/src/kernel_to_common.c \
libsepol/src/kernel_to_conf.c \
libsepol/src/link.c \
libsepol/src/mls.c \
libsepol/src/module.c \
libsepol/src/module_to_cil.c \
libsepol/src/node_record.c \
libsepol/src/nodes.c \
libsepol/src/polcaps.c \
libsepol/src/policydb.c \
libsepol/src/policydb_convert.c \
libsepol/src/policydb_public.c \
libsepol/src/port_record.c \
libsepol/src/ports.c \
libsepol/src/roles.c \
libsepol/src/services.c \
libsepol/src/sidtab.c \
libsepol/src/symtab.c \
libsepol/src/user_record.c \
libsepol/src/users.c \
libsepol/src/util.c \
libsepol/src/write.c
cil_src_files := \
libsepol/cil/src/cil_binary.c \
libsepol/cil/src/cil_build_ast.c \
libsepol/cil/src/cil.c \
libsepol/cil/src/cil_copy_ast.c \
libsepol/cil/src/cil_find.c \
libsepol/cil/src/cil_fqn.c \
libsepol/cil/src/cil_list.c \
libsepol/cil/src/cil_log.c \
libsepol/cil/src/cil_mem.c \
libsepol/cil/src/cil_parser.c \
libsepol/cil/src/cil_policy.c \
libsepol/cil/src/cil_post.c \
libsepol/cil/src/cil_reset_ast.c \
libsepol/cil/src/cil_resolve_ast.c \
libsepol/cil/src/cil_stack.c \
libsepol/cil/src/cil_strpool.c \
libsepol/cil/src/cil_symtab.c \
libsepol/cil/src/cil_tree.c \
libsepol/cil/src/cil_verify.c
libpcre2_src_files := \
pcre/dist2/src/pcre2_auto_possess.c \
pcre/dist2/src/pcre2_compile.c \
pcre/dist2/src/pcre2_config.c \
pcre/dist2/src/pcre2_context.c \
pcre/dist2/src/pcre2_dfa_match.c \
pcre/dist2/src/pcre2_error.c \
pcre/dist2/src/pcre2_find_bracket.c \
pcre/dist2/src/pcre2_maketables.c \
pcre/dist2/src/pcre2_match.c \
pcre/dist2/src/pcre2_match_data.c \
pcre/dist2/src/pcre2_jit_compile.c \
pcre/dist2/src/pcre2_newline.c \
pcre/dist2/src/pcre2_ord2utf.c \
pcre/dist2/src/pcre2_pattern_info.c \
pcre/dist2/src/pcre2_serialize.c \
pcre/dist2/src/pcre2_string_utils.c \
pcre/dist2/src/pcre2_study.c \
pcre/dist2/src/pcre2_substitute.c \
pcre/dist2/src/pcre2_substring.c \
pcre/dist2/src/pcre2_tables.c \
pcre/dist2/src/pcre2_ucd.c \
pcre/dist2/src/pcre2_valid_utf.c \
pcre/dist2/src/pcre2_xclass.c \
pcre/dist2/src/pcre2_chartables.c
common_cflags := \
-Wall -W -Wundef \
-Wshadow -Wmissing-noreturn \
-Wmissing-format-attribute \
-std=gnu99 -O2 -fpic -fPIC \
-pipe -fno-strict-aliasing \
-D_GNU_SOURCE \
-D__BIONIC__ -DANDROID \
-D__ANDROID__
common_ldlibs := \
-lc
common_includes := \
include \
checkpolicy/ \
libsepol/include/ \
libsepol/src/ \
libsepol/cil/include/ \
libsepol/cil/src/ \
pcre/dist2 \
pcre/include_internal \
pcre/include \
libpcre/dist \
libselinux/src \
libsepol/include/sepol \
libselinux/include \
libselinux/include/selinux \
/usr/include/python2.7 \
/usr/include/python3.* \
/usr/local/include
yacc_flags := -x c -std=gnu89
FIND_HOSTOS := $(shell uname -s)
HOST_NAME := $(shell echo $(FIND_HOSTOS) |sed -e s/L/l/ |sed -e s/D/d/ |sed s/W/w/ )
mkdir-android := $(shell mkdir -vp $(addprefix $(LOCAL_PATH)/libselinux/src/, android))
mkdir-include := $(shell mkdir -vp $(addprefix $(LOCAL_PATH)/include/, openssl private packagelistparser))
get-openssl := $(shell wget -qO - "https://android.googlesource.com/platform/external/boringssl/+archive/master/src/include/openssl.tar.gz" -O - | tar -xz -C include/openssl)
get-private := $(shell wget -qO - "https://android.googlesource.com/platform/system/core/+archive/master/libcutils/include/private.tar.gz" -O - | tar -xz -C include/private)
get-log := $(shell wget -qO - "https://android.googlesource.com/platform/system/core/+archive/master/liblog/include.tar.gz" -O - | tar -xz -C include)
ifeq ($(HOST_NAME),darwin)
cmds := \
$(shell wget -qO - "https://android.googlesource.com/platform/external/selinux/+/master/libselinux/include/selinux/android.h?format=text" | \
base64 -D > libselinux/include/selinux/android.h) \
$(shell wget -qO - "https://android.googlesource.com/platform/external/selinux/+/master/libselinux/src/android/android.c?format=text" | \
base64 -D > libselinux/src/android/android.c) \
$(shell wget -qO - "https://android.googlesource.com/platform/external/selinux/+/master/libselinux/src/android/android_host.c?format=text" | \
base64 -D > libselinux/src/android/android_host.c) \
$(shell wget -qO - "https://android.googlesource.com/platform/system/core/+/master/libpackagelistparser/include/packagelistparser/packagelistparser.h?format=text" | \
base64 -D > include/packagelistparser/packagelistparser.h)
else
cmds := \
$(shell wget -qO - "https://android.googlesource.com/platform/external/selinux/+/master/libselinux/include/selinux/android.h?format=text" | \
base64 -d > libselinux/include/selinux/android.h) \
$(shell wget -qO - "https://android.googlesource.com/platform/external/selinux/+/master/libselinux/src/android/android.c?format=text" | \
base64 -d > libselinux/src/android/android.c) \
$(shell wget -qO - "https://android.googlesource.com/platform/external/selinux/+/master/libselinux/src/android/android_host.c?format=text" | \
base64 -d > libselinux/src/android/android_host.c) \
$(shell wget -qO - "https://android.googlesource.com/platform/system/core/+/master/libpackagelistparser/include/packagelistparser/packagelistparser.h?format=text" | \
base64 -d > include/packagelistparser/packagelistparser.h)
endif
libselinux_prepare := $(mkdir-android) $(mkdir-include) $(get-openssl) $(get-private) $(get-log) $(cmds)
checkpolicy_prepare := \
$(shell flex -o checkpolicy/lex.yy.c -l checkpolicy/policy_scan.l) \
$(shell yacc -vd checkpolicy/policy_parse.y -o checkpolicy/y.tab.c) \
$(shell bison -vd checkpolicy/policy_parse.y --defines=checkpolicy/policy_parse.h -o checkpolicy/policy_parse.c)
##
# libpcre2.a
#
include $(CLEAR_VARS)
LOCAL_MODULE := libpcre2
LOCAL_CFLAGS += -DHAVE_CONFIG_H
LOCAL_C_INCLUDES := $(common_includes)
LOCAL_SRC_FILES := $(libpcre2_src_files)
LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)
include $(BUILD_STATIC_LIBRARY)
##
# cil_lexer.a
#
include $(CLEAR_VARS)
LOCAL_MODULE := cil_lexer
LOCAL_MODULE_TAGS := optional
LOCAL_C_INCLUDES := $(common_includes)
LOCAL_CFLAGS := $(yacc_flags) $(common_cflags)
LOCAL_SRC_FILES := libsepol/cil/src/cil_lexer.l
include $(BUILD_STATIC_LIBRARY)
##
# libsepol.a
#
include $(CLEAR_VARS)
LOCAL_MODULE := libsepol
LOCAL_MODULE_TAGES := optional
LOCAL_C_INCLUDES := $(common_includes)
LOCAL_CFLAGS := $(common_cflags)
LOCAL_SRC_FILES := $(common_src_files)
LOCAL_MODULE_CLASS := STATIC_LIBRARIES
include $(BUILD_STATIC_LIBRARY)
##
# chkcon
#
include $(CLEAR_VARS)
LOCAL_MODULE := chkcon
LOCAL_MODULE_TAGS := optional
LOCAL_C_INCLUDES := $(common_includes)
LOCAL_CFLAGS := $(common_cflags)
LOCAL_SRC_FILES := libsepol/utils/chkcon.c
LOCAL_STATIC_LIBRARIES := libsepol
LOCAL_MODULE_CLASS := EXECUTABLES
include $(BUILD_EXECUTABLE)
##
# libselinux_static
#
include $(CLEAR_VARS)
LOCAL_MODULE := libselinux_static
LOCAL_MODULE_TAGS := optional
LOCAL_WHOLE_STATIC_LIBRARIES := libpcre2
LOCAL_CFLAGS := -std=gnu89 -DAUDITD_LOG_TAG=1003 -DUSE_PCRE2 $(common_cflags)
LOCAL_STATIC_LIBRARIES := libpcre2
LOCAL_C_INCLUDES := $(common_includes)
LOCAL_SRC_FILES := $(libselinux_prepare) $(libselinux_src_files) $(libselinux_android_srcs)
include $(BUILD_STATIC_LIBRARY)
##
# sefcontext_compile
#
include $(CLEAR_VARS)
LOCAL_MODULE := sefcontext_compile
LOCAL_CFLAGS += -Wall -Werror -DUSE_PCRE2 -DNO_PERSISTENTLY_STORED_PATTERNS $(common_cflags)
LOCAL_STATIC_LIBRARIES := libselinux_static libpcre2 libsepol
LOCAL_C_INCLUDES := $(common_includes)
LOCAL_SRC_FILES := libselinux/utils/sefcontext_compile.c
LOCAL_MODULE_TAGS := optional
include $(BUILD_EXECUTABLE)
##
# getfilecon
#
include $(CLEAR_VARS)
LOCAL_MODULE := getfilecon
LOCAL_CFLAGS += -Wall -Werror -DUSE_PCRE2 -DNO_PERSISTENTLY_STORED_PATTERNS $(common_cflags)
LOCAL_STATIC_LIBRARIES := libselinux_static libpcre2 libsepol
LOCAL_C_INCLUDES := $(common_includes)
LOCAL_SRC_FILES := libselinux/utils/getfilecon.c
LOCAL_MODULE_TAGS := optional
include $(BUILD_EXECUTABLE)
##
# setfilecon
#
include $(CLEAR_VARS)
LOCAL_MODULE := setfilecon
LOCAL_CFLAGS += -Wall -Werror -DUSE_PCRE2 -DNO_PERSISTENTLY_STORED_PATTERNS $(common_cflags)
LOCAL_STATIC_LIBRARIES := libselinux_static libpcre2 libsepol
LOCAL_C_INCLUDES := $(common_includes)
LOCAL_SRC_FILES := libselinux/utils/setfilecon.c
LOCAL_MODULE_TAGS := optional
include $(BUILD_EXECUTABLE)
##
# checkpolicy
#
include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
$(checkpolicy_prepare) \
checkpolicy/lex.yy.c \
checkpolicy/y.tab.c \
checkpolicy/checkpolicy.c \
checkpolicy/module_compiler.c \
checkpolicy/parse_util.c \
checkpolicy/policy_define.c \
checkpolicy/queue.c
LOCAL_MODULE := checkpolicy
LOCAL_MODULE_TAGS := optional
LOCAL_C_INCLUDES := $(common_includes)
LOCAL_CFLAGS := $(yacc_flags) $(common_cflags)
LOCAL_STATIC_LIBRARIES := libsepol
LOCAL_CFLAGS += -std=gnu99 -fpic -fPIC
LOCAL_YACCFLAGS := -v
include $(BUILD_EXECUTABLE)
##
# checkmodule
#
include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
$(checkpolicy_prepare) \
checkpolicy/lex.yy.c \
checkpolicy/y.tab.c \
checkpolicy/checkmodule.c \
checkpolicy/module_compiler.c \
checkpolicy/parse_util.c \
checkpolicy/policy_define.c \
checkpolicy/queue.c
LOCAL_MODULE := checkmodule
LOCAL_MODULE_TAGS := optional
LOCAL_C_INCLUDES := $(common_includes)
LOCAL_CFLAGS := $(yacc_flags) $(common_cflags)
LOCAL_STATIC_LIBRARIES := libsepol
LOCAL_CFLAGS += -std=gnu99 -fpic -fPIC
LOCAL_YACCFLAGS := -v
include $(BUILD_EXECUTABLE)
##
# dispol
#
include $(CLEAR_VARS)
LOCAL_MODULE := dispol
LOCAL_MODULE_TAGS := optional
LOCAL_C_INCLUDES := $(common_includes)
LOCAL_SRC_FILES := checkpolicy/test/dispol.c
LOCAL_CFLAGS := $(yacc_flags) $(common_cflags)
LOCAL_STATIC_LIBRARIES := libsepol
LOCAL_CFLAGS += -std=gnu99 -fpic -fPIC
LOCAL_MODULE_TAGS := optional
include $(BUILD_EXECUTABLE)
##
# dismod
#
include $(CLEAR_VARS)
LOCAL_MODULE := dismod
LOCAL_MODULE_TAGS := optional
LOCAL_C_INCLUDES := $(common_includes)
LOCAL_SRC_FILES := checkpolicy/test/dismod.c
LOCAL_CFLAGS := $(yacc_flags) $(common_cflags)
LOCAL_STATIC_LIBRARIES := libsepol
LOCAL_CFLAGS += -std=gnu99 -fpic -fPIC
LOCAL_MODULE_TAGS := optional
include $(BUILD_EXECUTABLE)
theres a submodule for libpcre2 so you'll have to use git clone --recursive, AKA
git clone --recursive https://github.com/Surge1223/selinux.git selinux-master
or ideally, just clone SELinux master and cherry-pick the 3 commits that allow building for target devices
then building also depends on the NDK build system reading the jni/Application.mk first, before Android.mk so the NDK build command is
$NDK/ndk-build APP_PROJECT_PATH=. APPLICATION_BULID_SCRIPT=Application.mk
Click to expand...
Click to collapse
The main purpose of me posting this here is so that in the future, if it becomes necessary to create/build tools to deal with the additional restrictions on Android, this can serve as a starting point on building.
No I dont plan on posting binaries. If you're in this thread and you can't use the NDK, then you need to up your game son.
Good job @Surge1223!
Sent from my Samsung Galaxy S8+ using XDA Labs
Great work! @Surge1223
This is an interesting thread
Kudos Surge, subscribed