1# Copyright (c) 2020 Huawei Device Co., Ltd. 2# Licensed under the Apache License, Version 2.0 (the "License"); 3# you may not use this file except in compliance with the License. 4# You may obtain a copy of the License at 5# 6# http://www.apache.org/licenses/LICENSE-2.0 7# 8# Unless required by applicable law or agreed to in writing, software 9# distributed under the License is distributed on an "AS IS" BASIS, 10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11# See the License for the specific language governing permissions and 12# limitations under the License. 13 14config("cpu_arch") { 15 cflags = target_arch_cflags 16 cflags_cc = cflags 17 ldflags = cflags 18 asmflags = cflags 19} 20 21config("language_c") { 22 cflags_c = [ "-std=c99" ] 23} 24 25config("language_cpp") { 26 cflags_cc = [ "-std=c++11" ] 27} 28 29config("kernel_macros") { 30 if (ohos_kernel_type == "liteos_a") { 31 defines = [ 32 "__LITEOS__", 33 "__LITEOS_A__", 34 ] 35 } else if (ohos_kernel_type == "liteos_m") { 36 defines = [ 37 "__LITEOS__", 38 "__LITEOS_M__", 39 ] 40 } else if (ohos_kernel_type == "uniproton") { 41 defines = [ 42 "__uniproton__", 43 "__UNIPROTON__", 44 ] 45 } else if (ohos_kernel_type == "linux") { 46 defines = [ 47 "__linux__", 48 "__LINUX__", 49 ] 50 } 51} 52 53config("werror") { 54 cflags = [ "-Werror" ] 55 cflags_cc = cflags 56} 57 58config("common") { 59 defines = [ "_XOPEN_SOURCE=700" ] 60 cflags = [ 61 "-fno-common", 62 "-fno-builtin", 63 "-fno-strict-aliasing", 64 "-Wall", 65 ] 66 if (ohos_kernel_type == "linux") { 67 cflags += [ 68 "-funwind-tables", 69 "-fasynchronous-unwind-tables", 70 ] 71 } 72 cflags_cc = cflags 73 cflags += [ "-fsigned-char" ] 74} 75 76config("security") { 77 defines = [ "_FORTIFY_SOURCE=2" ] 78 79 cflags = [ "-fstack-protector-all" ] 80 cflags_cc = cflags 81 82 ldflags = [ 83 "-Wl,-z,now", 84 "-Wl,-z,relro", 85 "-Wl,-z,noexecstack", 86 ] 87} 88 89config("exceptions") { 90 cflags_cc = [ "-fexceptions" ] 91 cflags_objcc = cflags_cc 92} 93 94config("no_exceptions") { 95 cflags_cc = [ "-fno-exceptions" ] 96 cflags_objcc = cflags_cc 97 ldflags = cflags_cc 98} 99 100config("stack_protector") { 101 cflags = [ "-fstack-protector-all" ] 102 cflags_cc = cflags 103} 104 105config("static_pie_config") { 106 cflags = [ "-fPIE" ] 107 cflags_cc = cflags 108} 109 110config("shared_library_config") { 111 cflags = [ "-fPIC" ] 112 cflags_cc = cflags 113} 114 115config("pie_executable_config") { 116 ldflags = [ "-pie" ] 117} 118 119config("ohos_clang") { 120 if (ohos_kernel_type == "linux") { 121 defines = [ 122 "_LIBCPP_HAS_MUSL_LIBC", 123 "__BUILD_LINUX_WITH_CLANG", 124 ] 125 } 126 ldflags = [ 127 "-fuse-ld=lld", 128 "--rtlib=compiler-rt", 129 ] 130} 131 132config("release") { 133 defines = [ "OHOS_RELEASE" ] 134} 135 136config("debug") { 137 defines = [ "OHOS_DEBUG" ] 138} 139 140config("clang_opt") { 141 cflags = [ 142 "-Oz", 143 "-flto", 144 ] 145 cflags_cc = cflags 146} 147 148config("gcc_opt") { 149 cflags = [ "-Os" ] 150 cflags_cc = cflags 151} 152 153config("default_link_path") { 154 ldflags = [ 155 "-L.", 156 "-Wl,-rpath-link=.", 157 ] 158} 159 160config("board_config") { 161 cflags = [] 162 cflags_cc = [] 163 ldflags = [] 164 include_dirs = [] 165 defines = [] 166 asmflags = [] 167 cflags += board_cflags 168 cflags_cc += board_cxx_flags 169 ldflags += board_ld_flags 170 include_dirs += board_include_dirs 171 if (defined(board_macro_defines)) { 172 defines += board_macro_defines 173 } 174 if (defined(board_asmflags)) { 175 asmflags += board_asmflags 176 } 177} 178 179config("board_exe_ld_flags") { 180 ldflags = [] 181 if (defined(board_exe_ld_flags)) { 182 ldflags += board_exe_ld_flags 183 } 184} 185