[DEVS-ONLY] Compile Android SELinux binaries/libs using SELinux master - Android Software/Hacking General [Developers Only]
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
Related
[Q] makefile
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
ATRIX™ 2 ME865 Kernal downloads Maybe useful
This may be of use to some devs here. but I came across a few links that may be old news or maybe not... here are the files and source RAZR XT910 Developer Edition 698 MB RAZR-XT910-DE_01.6.5.1-167_SPU-15-M2-1-DE .zip http://developer.motorola.com/products/software/ kernel_omap4.tar.gz http://sourceforge.net/projects/me865.motorola/ http://sourceforge.net/projects/me865.motorola/files/ME865/5.5.1-1_GC-109/ PHP: 1. Create a workspace containing "vanilla" gingerbread release from Google. You may need to apply the following change in build repo to prevent the build from aborting when unexpected user tag is found on some modules: diff --git a/core/base_rules.mk b/core/base_rules.mk index 3c11673..ecf611d 100644 --- a/core/base_rules.mk +++ b/core/base_rules.mk @@ -99,7 +99,7 @@ ifneq ($(filter $(LOCAL_MODULE_TAGS),user),) $(warning * PRODUCT_PACKAGES section of) $(warning * build/target/product/core.mk) $(warning * ) - $(error user tag detected on new module - user tags are only supported on legacy modules) + $(warning user tag detected on new module - user tags are only supported on legacy modules) endif endif 2. Overlay Motorola-provided published repos on top of original Google versions. 3. Build user space components: cd <workspace> . build/envsetup.sh lunch generic-user make BOARD_HAVE_BLUETOOTH=true TARGET_BOARD_PLATFORM=omap4 <target> Where is something like out/target/product/generic/system/bin/bluetoothd 4. Building kernel and kernel modules. # set this to the top of your android workspace my_top_dir=.... # set this to where you want kernel intermediates written to kernel_out_dir=... # cross compiler cross=$my_top_dir/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin/arm-eabi- make -j1 -C $my_top_dir/kernel/omap4 ARCH=arm \ CROSS_COMPILE=$cross \ O=$kernel_out_dir \ KBUILD_DEFCONFIG=mapphone_defconfig \ defconfig modules_prepare make -C $my_top_dir/kernel/omap4 ARCH=arm \ CROSS_COMPILE=$cross \ O=$kernel_out_dir \ INSTALL_MOD_PATH=$kernel_out_dir \ modules 2>&1 make -C $my_top_dir/kernel/omap4 ARCH=arm \ CROSS_COMPILE=$cross \ O=$kernel_out_dir \ INSTALL_MOD_PATH=$kernel_out_dir \ modules_install make -C $my_top_dir/kernel/omap4 ARCH=arm \ CROSS_COMPILE=$cross \ O=$kernel_out_dir zImage make PREFIX=$kernel_out_dir CROSS=$cross CROSS_COMPILE=$cross \ PROCFAMILY=OMAP4430 PROJROOT= HOST_PLATFORM=sdc4430 \ KRNLSRC=$my_top_dir/kernel/omap4 KERNEL_DIR=$kernel_out_dir \ -C $my_top_dir/hardware/ti/wlan/wl1283/platforms/os/linux # newly built module in $my_top_dir/hardware/ti/wlan/wl1283/platforms/os/linux/tiwlan_drv.ko make PREFIX=$kernel_out_dir CROSS=$cross CROSS_COMPILE=$cross \ PROCFAMILY=OMAP4430 PROJROOT= HOST_PLATFORM=sdc4430 \ KRNLSRC=$my_top_dir/kernel/omap4 KERNEL_DIR=$kernel_out_dir \ -C $my_top_dir/hardware/ti/wlan/wl1283_softAP/platforms/os/linux # newly built module in $my_top_dir/hardware/ti/wlan/wl1283_softAP/platforms/os/linux/tiap_drv.ko make PREFIX=$kernel_out_dir CROSS=$cross CROSS_COMPILE=$cross \ PROCFAMILY=OMAP4430 PROJROOT= HOST_PLATFORM=sdc4430 \ KRNLSRC=$my_top_dir/kernel/omap4 KERNEL_DIR=$kernel_out_dir \ -C $my_top_dir/kernel/omap4 ARCH=arm \ O=$kernel_out_dir \ M=$my_top_dir/vendor/authentec/safenet/vpndriver modules # newly built module in $my_top_dir/vendor/authentec/safenet/vpndriver/vpnclient.ko 5. Building lbl: make -f motorola/external/lbl/Makefile all \ LBL_OUT=out/target/product/generic/obj/PARTITIONS/lbl_intermediates HOST_PREBUILT_TAG=linux-x86
[Q] Error while compiling AOKP (Help needed)
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
[Q] Add GApps to AOSP build
Hi all, I had a look at other threads but am still lost. I'm building AOSP for a variscite board and would like to include the gapps at build time. So I've downloaded the zip and in device/variscite/varsom/varsom.mk I added PRODUCT_COPY_FILES += \ $(foreach f,$(wildcard vendor/google/addon.d/*),$(f):system/addon.d/$(notdir $(f))) \ $(foreach f,$(wildcard vendor/google/framework/*),$(f):system/framework/$(notdir $(f))) \ $(foreach f,$(wildcard vendor/google/lib/*),$(f):system/lib/$(notdir $(f))) \ vendor/google/etc/g.prop:system/etc/g.prop \ $(foreach f,$(wildcard vendor/google/etc/permissions/*),$(f):system/etc/permissions/$(notdir $(f))) \ $(foreach f,$(wildcard vendor/google/etc/preferred-apps/*),$(f):system/etc/preferred-apps/$(notdir $(f))) \ The thing is I'm stuck as to how I copy the apks in system/app. When I add them to PRODUCT_COPY_FILES it throws an error saying I should use BUILD_PREBUILT but I'm not sure what I means, thanks for any help!
CM 12.1 Linaro -O3 build
And so I build a optimized cm 12.1 with linaro toolchain and -O3 flag. (from this thread http://forum.xda-developers.com/mi-4i/development/wip-cyanogenmod-12-1-xiaomi-mi-4i-t3152134) Standard CM disclaimers apply if you want to use this build Steps : 1. Add this to your local manifest (make directory .repo/local_manifests under the source directory) <?xml version="1.0" encoding="UTF-8"?> <manifest> <project path="kernel/xiaomi/ferrari" name="dh-harald/android_kernel_xiaomi_ferrari" /> <project path="device/xiaomi/ferrari" name="dh-harald/android_device_xiaomi_ferrari" /> <project path="vendor/xiaomi/ferrari" name="dh-harald/android_vendor_xiaomi_ferrari" /> <project path="device/qcom/common" name="CyanogenMod/android_device_qcom_common" /> <project path="external/mm-dash" name="CyanogenMod/android_external_mm-dash" /> <project path="hardware/qcom/fm" name="CyanogenMod/android_hardware_qcom_fm" /> </manifest> Then execute the command "repo sync" to get the source code. 2. Execute the following commands (under the source directory) to get the linaro toolchain git clone https://android.git.linaro.org/git-.../aarch64/aarch64-linux-android-4.9-linaro.git prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-linaro-4.9 git clone https://android-git.linaro.org/git-...x86/arm/arm-linux-androideabi-4.9-linaro.git/ prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-linaro-4.9 3. Make the following changes diff --git a/core/clang/config.mk b/core/clang/config.mk index 9c11797..67a545e 100644 --- a/core/clang/config.mk +++ b/core/clang/config.mk @@ -31,8 +31,8 @@ endif # Clang flags for all host or target rules CLANG_CONFIG_EXTRA_ASFLAGS := -CLANG_CONFIG_EXTRA_CFLAGS := -CLANG_CONFIG_EXTRA_CPPFLAGS := +CLANG_CONFIG_EXTRA_CFLAGS := -O3 +CLANG_CONFIG_EXTRA_CPPFLAGS := -O3 CLANG_CONFIG_EXTRA_LDFLAGS := CLANG_CONFIG_EXTRA_CFLAGS += \ @@ -40,7 +40,7 @@ CLANG_CONFIG_EXTRA_CFLAGS += \ # Help catch common 32/64-bit errors. CLANG_CONFIG_EXTRA_CFLAGS += \ - -Werror=int-conversion + -Werror=int-conversion # Workaround for ccache with clang. # See http://petereisentraut.blogspot.com/2011/05/ccache-and-clang.html. @@ -49,6 +49,7 @@ CLANG_CONFIG_EXTRA_CFLAGS += \ CLANG_CONFIG_UNKNOWN_CFLAGS := \ -funswitch-loops \ + -O3 \ -fno-tree-sra \ -finline-limit=64 \ -Wno-psabi \ @@ -61,14 +62,14 @@ CLANG_CONFIG_UNKNOWN_CFLAGS := \ # Clang flags for all host rules CLANG_CONFIG_HOST_EXTRA_ASFLAGS := -CLANG_CONFIG_HOST_EXTRA_CFLAGS := -CLANG_CONFIG_HOST_EXTRA_CPPFLAGS := +CLANG_CONFIG_HOST_EXTRA_CFLAGS := -O3 +CLANG_CONFIG_HOST_EXTRA_CPPFLAGS := -O3 CLANG_CONFIG_HOST_EXTRA_LDFLAGS := # Clang flags for all target rules CLANG_CONFIG_TARGET_EXTRA_ASFLAGS := -CLANG_CONFIG_TARGET_EXTRA_CFLAGS := -nostdlibinc -CLANG_CONFIG_TARGET_EXTRA_CPPFLAGS := -nostdlibinc +CLANG_CONFIG_TARGET_EXTRA_CFLAGS := -nostdlibinc -O3 +CLANG_CONFIG_TARGET_EXTRA_CPPFLAGS := -nostdlibinc -O3 CLANG_CONFIG_TARGET_EXTRA_LDFLAGS := # HOST config @@ -98,7 +99,7 @@ CLANG_CONFIG_EXTRA_TARGET_C_INCLUDES := $(LLVM_PREBUILTS_HEADER_PATH) $(TARGET_O # Address sanitizer clang config ADDRESS_SANITIZER_RUNTIME_LIBRARY := libclang_rt.asan_$(TARGET_ARCH)_android -ADDRESS_SANITIZER_CONFIG_EXTRA_CFLAGS := -fsanitize=address -fno-omit-frame-pointer +ADDRESS_SANITIZER_CONFIG_EXTRA_CFLAGS := -fsanitize=address -fno-omit-frame-pointer -O3 ADDRESS_SANITIZER_CONFIG_EXTRA_LDFLAGS := -Wl,-u,__asan_preinit ADDRESS_SANITIZER_CONFIG_EXTRA_SHARED_LIBRARIES := libdl $(ADDRESS_SANITIZER_RUNTIME_LIBRARY) ADDRESS_SANITIZER_CONFIG_EXTRA_STATIC_LIBRARIES := libasan diff --git a/core/combo/TARGET_linux-arm.mk b/core/combo/TARGET_linux-arm.mk index 95b1804..de703fe 100644 --- a/core/combo/TARGET_linux-arm.mk +++ b/core/combo/TARGET_linux-arm.mk @@ -38,7 +38,7 @@ endif $(combo_2nd_arch_prefix)TARGET_NDK_GCC_VERSION := 4.8 ifeq ($(strip $(TARGET_GCC_VERSION_EXP)),) -$(combo_2nd_arch_prefix)TARGET_GCC_VERSION := 4.8 +$(combo_2nd_arch_prefix)TARGET_GCC_VERSION := linaro-4.9 else $(combo_2nd_arch_prefix)TARGET_GCC_VERSION := $(TARGET_GCC_VERSION_EXP) endif @@ -67,14 +67,14 @@ $(combo_2nd_arch_prefix)TARGET_STRIP := $($(combo_2nd_arch_prefix)TARGET_TOOLS_P $(combo_2nd_arch_prefix)TARGET_NO_UNDEFINED_LDFLAGS := -Wl,--no-undefined -$(combo_2nd_arch_prefix)TARGET_arm_CFLAGS := -O2 \ +$(combo_2nd_arch_prefix)TARGET_arm_CFLAGS := -O3 \ -fomit-frame-pointer \ -fstrict-aliasing \ -funswitch-loops # Modules can choose to compile some source as thumb. $(combo_2nd_arch_prefix)TARGET_thumb_CFLAGS := -mthumb \ - -Os \ + -O3 \ -fomit-frame-pointer \ -fno-strict-aliasing @@ -96,6 +96,7 @@ android_config_h := $(call select-android-config-h,linux-arm) $(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS += \ -msoft-float \ + -O3 \ -ffunction-sections \ -fdata-sections \ -funwind-tables \ @@ -127,7 +128,7 @@ endif # in their exported C++ functions). Also, GCC 4.5 has already # removed the warning from the compiler. # -$(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS += -Wno-psabi +$(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS += -Wno-psabi -O3 $(combo_2nd_arch_prefix)TARGET_GLOBAL_LDFLAGS += \ -Wl,-z,noexecstack \ @@ -140,12 +141,12 @@ $(combo_2nd_arch_prefix)TARGET_GLOBAL_LDFLAGS += \ $(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS += -mthumb-interwork -$(combo_2nd_arch_prefix)TARGET_GLOBAL_CPPFLAGS += -fvisibility-inlines-hidden +$(combo_2nd_arch_prefix)TARGET_GLOBAL_CPPFLAGS += -fvisibility-inlines-hidden -O3 # More flags/options can be added here $(combo_2nd_arch_prefix)TARGET_RELEASE_CFLAGS := \ -DNDEBUG \ - -g \ + -O3 \ -Wstrict-aliasing=2 \ -fgcse-after-reload \ -frerun-cse-after-loop \ diff --git a/core/combo/TARGET_linux-arm64.mk b/core/combo/TARGET_linux-arm64.mk index df6c127..2d1de81 100644 --- a/core/combo/TARGET_linux-arm64.mk +++ b/core/combo/TARGET_linux-arm64.mk @@ -38,7 +38,7 @@ endif TARGET_NDK_GCC_VERSION := 4.9 ifeq ($(strip $(TARGET_GCC_VERSION_EXP)),) -TARGET_GCC_VERSION := 4.9 +TARGET_GCC_VERSION := linaro-4.9 else TARGET_GCC_VERSION := $(TARGET_GCC_VERSION_EXP) endif @@ -68,7 +68,7 @@ TARGET_STRIP := $(TARGET_TOOLS_PREFIX)strip$(HOST_EXECUTABLE_SUFFIX) TARGET_NO_UNDEFINED_LDFLAGS := -Wl,--no-undefined TARGET_GLOBAL_CFLAGS += \ - -fno-strict-aliasing \ + -O3 -fno-strict-aliasing \ android_config_h := $(call select-android-config-h,linux-arm64) @@ -113,12 +113,12 @@ TARGET_GLOBAL_LDFLAGS += \ -Wl,-maarch64linux \ $(arch_variant_ldflags) -TARGET_GLOBAL_CPPFLAGS += -fvisibility-inlines-hidden +TARGET_GLOBAL_CPPFLAGS += -fvisibility-inlines-hidden -O3 # More flags/options can be added here TARGET_RELEASE_CFLAGS := \ -DNDEBUG \ - -O2 -g \ + -O3 \ -Wstrict-aliasing=2 \ -fgcse-after-reload \ -frerun-cse-after-loop \ diff --git a/core/combo/arch/arm64/armv8-a.mk b/core/combo/arch/arm64/armv8-a.mk index 642fe91..9b959b6 100644 --- a/core/combo/arch/arm64/armv8-a.mk +++ b/core/combo/arch/arm64/armv8-a.mk @@ -8,6 +8,6 @@ endif # Leave the flag so devices that need the workaround but don't fit in # the check above can still enable it. ifeq ($(TARGET_CPU_CORTEX_A53),true) -arch_variant_ldflags := -Wl,--fix-cortex-a53-843419 \ +#arch_variant_ldflags := -Wl,--fix-cortex-a53-843419 \ -Wl,--fix-cortex-a53-835769 endif diff --git a/core/combo/select.mk b/core/combo/select.mk index ec10dd2..ec5781f 100644 --- a/core/combo/select.mk +++ b/core/combo/select.mk @@ -49,9 +49,9 @@ $(combo_var_prefix)HAVE_STRLCPY := 0 $(combo_var_prefix)HAVE_STRLCAT := 0 $(combo_var_prefix)HAVE_KERNEL_MODULES := 0 -$(combo_var_prefix)GLOBAL_CFLAGS := -fno-exceptions -Wno-multichar -$(combo_var_prefix)RELEASE_CFLAGS := -O2 -g -fno-strict-aliasing -$(combo_var_prefix)GLOBAL_CPPFLAGS := +$(combo_var_prefix)GLOBAL_CFLAGS := -fno-exceptions -Wno-multichar -O3 +$(combo_var_prefix)RELEASE_CFLAGS := -O3 -fno-strict-aliasing +$(combo_var_prefix)GLOBAL_CPPFLAGS := -O3 $(combo_var_prefix)GLOBAL_LDFLAGS := $(combo_var_prefix)GLOBAL_ARFLAGS := crsPD $(combo_var_prefix)GLOBAL_LD_DIRS := diff --git a/core/config.mk b/core/config.mk index ddc4007..0ef7cea 100644 --- a/core/config.mk +++ b/core/config.mk @@ -113,8 +113,8 @@ SHOW_COMMANDS:= $(filter showcommands,$(MAKECMDGOALS)) # ############################################################### # These can be changed to modify both host and device modules. -COMMON_GLOBAL_CFLAGS:= -DANDROID -fmessage-length=0 -W -Wall -Wno-unused -Winit-self -Wpointer-arith -COMMON_RELEASE_CFLAGS:= -DNDEBUG -UDEBUG +COMMON_GLOBAL_CFLAGS:= -DANDROID -fmessage-length=0 -W -Wall -Wno-unused -Winit-self -Wpointer-arith -O3 +COMMON_RELEASE_CFLAGS:= -DNDEBUG -UDEBUG -O3 COMMON_GLOBAL_CPPFLAGS:= $(COMMON_GLOBAL_CFLAGS) -Wsign-promo COMMON_RELEASE_CPPFLAGS:= $(COMMON_RELEASE_CFLAGS) 4. execute the command "brunch cm_ferrari-user" Steps use this build. 1. Builds can be downloaded from here - cm-12.1-20150803-UNOFFICIAL-ferrari.zip http://d-h.st/tmmW cm-12.1-20150806-UNOFFICIAL-ferrari.zip http://d-h.st/raM0 cm-12.1-20150811-UNOFFICIAL-ferrari.zip http://d-h.st/9PFq cm-12.1-20150815-UNOFFICIAL-ferrari.zip http://d-h.st/YAnS cm-12.1-20150827-UNOFFICIAL-ferrari.zip http://d-h.st/cIZg cm-12.1-20150916-UNOFFICIAL-ferrari.zip http://d-h.st/jqbq cm-12.1-20150924-UNOFFICIAL-ferrari.zip http://d-h.st/YcOn cm-12.1-20151009-UNOFFICIAL-ferrari.zip http://d-h.st/Vmp3 2. Download any 64bit gapps. 3. Install twrp and these two files. I used the sensor patch from this thread http://forum.xda-developers.com/mi-4i/development/wip-cyanogenmod-12-1-xiaomi-mi-4i-t3152134 I have attached the AnTuTu benchmark score
whats battery like?
just installed it ...looks good...
What kernel is used? Does the kernel in CM 12.1 run the CPUs always at max rate?
fattymcdirty said: What kernel is used? Does the kernel in CM 12.1 run the CPUs always at max rate? Click to expand... Click to collapse Nope if he didn't modify it under settings->performance you can change the governor of your kernel. Remember that Performance keeps frequency at maximum,while Powersave keeps frequency at minimum. Sent from my LG-E400 using XDA Free mobile app
And does a CM 12.1 build run more fluid than MIUI on the Mi4i?
fattymcdirty said: And does a CM 12.1 build run more fluid than MIUI on the Mi4i? Click to expand... Click to collapse Certainly. MIUI is visibly beatiful. But it takes a lot of RAM. I recommend using CM for it doesn't take as much RAM as MIUI and has good looks,too. Sent from my LG-E400 using XDA Free mobile app
Nice!! Downloading now... Btw, which gapps do you recommend for your build, @shyamk?
Do we benefit from O3 flags if we use another kernel? Or do we have to use the kernel from this Rom to have all the goodness?
rob rich said: Do we benefit from O3 flags if we use another kernel? Or do we have to use the kernel from this Rom to have all the goodness? Click to expand... Click to collapse You need to keep the same kernel,for its compiled with the o3 flag. You might wanna change to a kernel whose been compiled with O3 flags too,though. Sent from my LG-E400 using XDA Free mobile app
The kernel is the same as the previous thread -- stock ferrari kernel. Any gapps would do. The only difference between this image and the one in the other thread is that I have used linaro and -O3. Nothing else
@shyamk i really hope you are giving us updates from time to time, this is so smooth thanks
how to root this rom.. i cannot found any root option at developer option thanks
I will keep building this ROM as and when there is an update in the other thread, or when I find sometime, whichever is earlier. Yes, I did notice that the root is missing from developer options. Let me look into it later in the day when I can find sometime. Shyam
How does this preform to the original cm12.1 in terms of speed/battery life?
reza36 said: how to root this rom.. i cannot found any root option at developer option thanks Click to expand... Click to collapse Download the flashable ZIP of superSU from here http://download.chainfire.eu/supersu and flash it in recovery
Running the ROM, no bugs so far.... we need to flash the sensor patch from dh.harald after flashing this ROM too...
I use thermal and cpu config from this post http://forum.xda-developers.com/showpost.php?p=62180597&postcount=790
Hi guys, Shyamk, great job, but what is linaro ando 03 where does it helps ... stupid me i dont know.. thanks
vrtsvas said: Hi guys, Shyamk, great job, but what is linaro ando 03 where does it helps ... stupid me i dont know.. thanks Click to expand... Click to collapse Do you know that Google is your friend?