Advertisement
pbeeler

Untitled

Mar 19th, 2015
267
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.16 KB | None | 0 0
  1. # Copyright (C) 2014-2015 The SaberMod Project
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. #
  15.  
  16. # Written for SaberMod toolchains
  17. # TARGET_SM_AND can be set before this file to override the default of gcc 4.8 for ROM.
  18. # This is to avoid hardcoding the gcc versions for the ROM and kernels.
  19.  
  20. ifndef TARGET_SM_AND
  21. $(warning ********************************************************************************)
  22. $(warning * TARGET_SM_AND not defined.)
  23. $(warning * Defaulting to gcc 4.8 for ROM.)
  24. $(warning * To change this set TARGET_SM_AND in device trees before common.mk is called.)
  25. $(warning * This is required for arm64 devices for the kernel TARGET_SM_KERNEL := SM-4.9)
  26. $(warning ********************************************************************************)
  27. TARGET_SM_AND := 4.8
  28. endif
  29.  
  30. ifdef TARGET_SM_KERNEL
  31. TARGET_SM_KERNEL_DEFINED := true
  32. else
  33. $(warning ********************************************************************************)
  34. $(warning * TARGET_SM_KERNEL not defined.)
  35. $(warning * This needs to be set in device trees before common.mk is called for inline kernel building.)
  36. $(warning * Skipping kernel bits.)
  37. $(warning ********************************************************************************)
  38. TARGET_SM_KERNEL_DEFINED := false
  39. endif
  40.  
  41. # Set GCC colors
  42. export GCC_COLORS := 'error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'
  43.  
  44. # Find host os
  45. UNAME := $(shell uname -s)
  46.  
  47. ifeq ($(strip $(UNAME)),Linux)
  48. HOST_OS := linux
  49. endif
  50.  
  51. # Only use these compilers on linux host.
  52. ifeq ($(strip $(HOST_OS)),linux)
  53.  
  54. ifeq ($(strip $(TARGET_ARCH)),arm)
  55.  
  56. TARGET_ARCH_LIB_PATH := $(ANDROID_BUILD_TOP)/prebuilts/gcc/$(HOST_PREBUILT_TAG)/arm/arm-linux-androideabi-$(TARGET_SM_AND)/lib/gcc/arm-linux-androideabi/$(TARGET_LIB_VERSION).x-sabermod
  57.  
  58. # Path to ROM toolchain
  59. SM_AND_PATH := prebuilts/gcc/$(HOST_PREBUILT_TAG)/arm/arm-linux-androideabi-$(TARGET_SM_AND)
  60. SM_AND := $(shell $(SM_AND_PATH)/bin/arm-linux-androideabi-gcc --version)
  61.  
  62. # Find strings in version info
  63. ifneq ($(filter %sabermod,$(SM_AND)),)
  64. SM_AND_NAME := $(filter %sabermod,$(SM_AND))
  65. SM_AND_DATE := $(filter 20140% 20141% 20150% 20151%,$(SM_AND))
  66. SM_AND_STATUS := $(filter (release) (prerelease) (experimental),$(SM_AND))
  67. SM_AND_VERSION := $(SM_AND_NAME)-$(SM_AND_DATE)-$(SM_AND_STATUS)
  68.  
  69. # Write version info to build.prop
  70. PRODUCT_PROPERTY_OVERRIDES += \
  71. ro.sm.android=$(SM_AND_VERSION)
  72.  
  73. OPT1 := (graphite)
  74.  
  75. # Graphite flags and friends
  76. GRAPHITE_FLAGS := \
  77. -fgraphite \
  78. -fgraphite-identity \
  79. -floop-flatten \
  80. -floop-parallelize-all \
  81. -ftree-loop-linear \
  82. -floop-interchange \
  83. -floop-strip-mine \
  84. -floop-block
  85.  
  86. # Legacy gcc doesn't understand this flag
  87. ifneq ($(strip $(USE_LEGACY_GCC)),true)
  88. GRAPHITE_FLAGS += \
  89. -Wno-error=maybe-uninitialized
  90. endif
  91. endif
  92.  
  93. # Skip kernel bits if TARGET_SM_KERNEL is not defined.
  94. ifeq ($(strip $(TARGET_SM_KERNEL_DEFINED)),true)
  95.  
  96. # Path to kernel toolchain
  97. SM_KERNEL_PATH := prebuilts/gcc/$(HOST_PREBUILT_TAG)/arm/arm-eabi-$(TARGET_SM_KERNEL)
  98. SM_KERNEL := $(shell $(SM_KERNEL_PATH)/bin/arm-eabi-gcc --version)
  99.  
  100. ifneq ($(filter %sabermod,$(SM_KERNEL)),)
  101. SM_KERNEL_NAME := $(filter %sabermod,$(SM_KERNEL))
  102. SM_KERNEL_DATE := $(filter 20140% 20141% 20150% 20151%,$(SM_KERNEL))
  103. SM_KERNEL_STATUS := $(filter (release) (prerelease) (experimental),$(SM_KERNEL))
  104. SM_KERNEL_VERSION := $(SM_KERNEL_NAME)-$(SM_KERNEL_DATE)-$(SM_KERNEL_STATUS)
  105.  
  106. # Write version info to build.prop
  107. PRODUCT_PROPERTY_OVERRIDES += \
  108. ro.sm.kernel=$(SM_KERNEL_VERSION)
  109.  
  110. # Graphite flags for kernel
  111. export GRAPHITE_KERNEL_FLAGS := \
  112. -fgraphite \
  113. -fgraphite-identity \
  114. -floop-flatten \
  115. -floop-parallelize-all \
  116. -ftree-loop-linear \
  117. -floop-interchange \
  118. -floop-strip-mine \
  119. -floop-block
  120. endif
  121. endif
  122. endif
  123.  
  124. ifeq ($(strip $(TARGET_ARCH)),arm64)
  125.  
  126. TARGET_ARCH_LIB_PATH := $(ANDROID_BUILD_TOP)/prebuilts/gcc/$(HOST_PREBUILT_TAG)/aarch64/aarch64-linux-android-$(TARGET_SM_AND)/lib/gcc/aarch64-linux-android/$(TARGET_LIB_VERSION).x-aosp-sabermod
  127.  
  128. # Path to toolchain
  129. SM_AND_PATH := prebuilts/gcc/$(HOST_PREBUILT_TAG)/aarch64/aarch64-linux-android-$(TARGET_SM_AND)
  130. SM_AND := $(shell $(SM_AND_PATH)/bin/aarch64-linux-android-gcc --version)
  131.  
  132. # Find strings in version info
  133. ifneq ($(filter %sabermod,$(SM_AND)),)
  134. SM_AND_NAME := $(filter %sabermod,$(SM_AND))
  135. SM_AND_DATE := $(filter 20140% 20141% 20150% 20151%,$(SM_AND))
  136. SM_AND_STATUS := $(filter (release) (prerelease) (experimental),$(SM_AND))
  137. SM_AND_VERSION := $(SM_AND_NAME)-$(SM_AND_DATE)-$(SM_AND_STATUS)
  138.  
  139. # Write version info to build.prop
  140. PRODUCT_PROPERTY_OVERRIDES += \
  141. ro.sm.android=$(SM_AND_VERSION)
  142.  
  143. OPT1 := (graphite)
  144.  
  145. # Graphite flags and friends
  146. GRAPHITE_FLAGS := \
  147. -fgraphite \
  148. -fgraphite-identity \
  149. -floop-flatten \
  150. -floop-parallelize-all \
  151. -ftree-loop-linear \
  152. -floop-interchange \
  153. -floop-strip-mine \
  154. -floop-block
  155.  
  156. # Legacy gcc doesn't understand this flag
  157. ifneq ($(strip $(USE_LEGACY_GCC)),true)
  158. GRAPHITE_FLAGS += \
  159. -Wno-error=maybe-uninitialized
  160. endif
  161. endif
  162.  
  163. # Skip kernel bits if TARGET_SM_KERNEL is not defined.
  164. ifeq ($(strip $(TARGET_SM_KERNEL_DEFINED)),true)
  165.  
  166. # Path to kernel toolchain
  167. SM_KERNEL_PATH := prebuilts/gcc/$(HOST_PREBUILT_TAG)/aarch64/aarch64-linux-android-$(TARGET_SM_KERNEL)
  168. SM_KERNEL := $(shell $(SM_KERNEL_PATH)/bin/aarch64-linux-android-gcc --version)
  169.  
  170. ifneq ($(filter %sabermod,$(SM_KERNEL)),)
  171. SM_KERNEL_NAME := $(filter %sabermod,$(SM_KERNEL))
  172. SM_KERNEL_DATE := $(filter 20140% 20141% 20150% 20151%,$(SM_KERNEL))
  173. SM_KERNEL_STATUS := $(filter (release) (prerelease) (experimental),$(SM_KERNEL))
  174. SM_KERNEL_VERSION := $(SM_KERNEL_NAME)-$(SM_KERNEL_DATE)-$(SM_KERNEL_STATUS)
  175.  
  176. # Write version info to build.prop
  177. PRODUCT_PROPERTY_OVERRIDES += \
  178. ro.sm.kernel=$(SM_KERNEL_VERSION)
  179.  
  180. # Graphite flags for kernel
  181. export GRAPHITE_KERNEL_FLAGS := \
  182. -fgraphite \
  183. -fgraphite-identity \
  184. -floop-flatten \
  185. -floop-parallelize-all \
  186. -ftree-loop-linear \
  187. -floop-interchange \
  188. -floop-strip-mine \
  189. -floop-block
  190. endif
  191. endif
  192. endif
  193.  
  194. # Add extra libs for the compilers to use
  195. export LD_LIBRARY_PATH := $(TARGET_ARCH_LIB_PATH):$(LD_LIBRARY_PATH)
  196. export LIBRARY_PATH := $(TARGET_ARCH_LIB_PATH):$(LIBRARY_PATH)
  197.  
  198. # Force disable some modules that are not compatible with graphite flags.
  199. # Add more modules if needed for devices in a device make file somewhere with
  200. # LOCAL_DISABLE_GRAPHITE:=
  201.  
  202. # Check if there's already something set in a device make file somewhere.
  203. ifndef LOCAL_DISABLE_GRAPHITE
  204. LOCAL_DISABLE_GRAPHITE := \
  205. libunwind \
  206. libFFTEm \
  207. libicui18n \
  208. libskia \
  209. libvpx \
  210. libmedia_jni \
  211. libstagefright_mp3dec \
  212. libart \
  213. mdnsd \
  214. libwebrtc_spl \
  215. third_party_WebKit_Source_core_webcore_svg_gyp \
  216. libjni_filtershow_filters \
  217. libavformat \
  218. libavcodec \
  219. skia_skia_library_gyp \
  220. libSR_Core \
  221. libwebviewchromium \
  222. third_party_libvpx_libvpx_gyp \
  223. ui_gl_gl_gyp
  224. else
  225. LOCAL_DISABLE_GRAPHITE += \
  226. libunwind \
  227. libFFTEm \
  228. libicui18n \
  229. libskia \
  230. libvpx \
  231. libmedia_jni \
  232. libstagefright_mp3dec \
  233. libart \
  234. mdnsd \
  235. libwebrtc_spl \
  236. third_party_WebKit_Source_core_webcore_svg_gyp \
  237. libjni_filtershow_filters \
  238. libavformat \
  239. libavcodec \
  240. skia_skia_library_gyp \
  241. libSR_Core \
  242. libwebviewchromium \
  243. third_party_libvpx_libvpx_gyp \
  244. ui_gl_gl_gyp
  245. endif
  246.  
  247. # O3 optimizations
  248. # To enable this set O3_OPTIMIZATIONS=true in a device makefile somewhere.
  249. ifeq ($(strip $(O3_OPTIMIZATIONS)),true)
  250. OPT2 := (max)
  251.  
  252. # Disable some modules that break with -O3
  253. # Add more modules if needed for devices in a device make file somewhere with
  254. # LOCAL_DISABLE_O3 :=
  255.  
  256. # Check if there's already something set in a device make file somewhere.
  257. ifndef LOCAL_DISABLE_O3
  258. LOCAL_DISABLE_O3 := \
  259. libaudioflinger \
  260. libwebviewchromium \
  261. skia_skia_library_gyp
  262. else
  263. LOCAL_DISABLE_O3 += \
  264. libaudioflinger \
  265. libwebviewchromium \
  266. skia_skia_library_gyp
  267. endif
  268.  
  269. # -O3 flags and friends
  270. O3_FLAGS := \
  271. -O3 \
  272. -Wno-error=array-bounds \
  273. -Wno-error=strict-overflow
  274. else
  275. OPT2:=
  276.  
  277. endif
  278.  
  279. # posix thread optimizations
  280. # To enable this set ENABLE_PTHREAD=true in a device makefile somewhere.
  281. ifeq ($(strip $(ENABLE_PTHREAD)),true)
  282. OPT3 := (pthread)
  283.  
  284. # Disable some modules that break with -pthread
  285. # Add more modules if needed for devices in a device make file somewhere with
  286. # LOCAL_DISABLE_PTHREAD :=
  287.  
  288. # Check if there's already something set in a device make file somewhere.
  289. ifndef LOCAL_DISABLE_PTHREAD
  290. LOCAL_DISABLE_PTHREAD := \
  291. libc_netbsd
  292. else
  293. LOCAL_DISABLE_PTHREAD += \
  294. libc_netbsd
  295. endif
  296. else
  297. OPT3:=
  298. endif
  299.  
  300. # Write gcc optimizations to build.prop
  301. GCC_OPTIMIZATION_LEVELS := $(OPT1)$(OPT2)$(OPT3)
  302. ifneq ($(GCC_OPTIMIZATION_LEVELS),)
  303. PRODUCT_PROPERTY_OVERRIDES += \
  304. ro.sm.flags=$(GCC_OPTIMIZATION_LEVELS)
  305. endif
  306.  
  307. # General flags for gcc 4.9 to allow compilation to complete.
  308. # Commented out for now since there's no common (non-device specific) modules to list here.
  309. # Add more modules if needed for devices in a device make file somewhere with
  310. # MAYBE_UNINITIALIZED :=
  311.  
  312. # Check if there's already something set in a device make file somewhere.
  313. # ifndef MAYBE_UNINITIALIZED
  314. # MAYBE_UNINITIALIZED :=
  315. # else
  316. # MAYBE_UNINITIALIZED +=
  317. # endif
  318.  
  319. else
  320. $(warning ********************************************************************************)
  321. $(warning * SaberMod currently only works on linux host systems.)
  322. $(warning ********************************************************************************)
  323. endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement