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 == "linux") { 41 defines = [ 42 "__linux__", 43 "__LINUX__", 44 ] 45 } 46} 47 48config("werror") { 49 cflags = [ "-Werror" ] 50 cflags_cc = cflags 51} 52 53config("common") { 54 defines = [ "_XOPEN_SOURCE=700" ] 55 cflags = [ 56 "-fno-common", 57 "-fno-builtin", 58 "-fno-strict-aliasing", 59 "-Wall", 60 ] 61 cflags_cc = cflags 62 cflags += [ "-fsigned-char" ] 63} 64 65config("security") { 66 defines = [ "_FORTIFY_SOURCE=2" ] 67 68 cflags = [ "-fstack-protector-all" ] 69 cflags_cc = cflags 70 71 ldflags = [ 72 "-Wl,-z,now", 73 "-Wl,-z,relro", 74 "-Wl,-z,noexecstack", 75 ] 76} 77 78config("exceptions") { 79 cflags_cc = [ "-fexceptions" ] 80 cflags_objcc = cflags_cc 81} 82 83config("no_exceptions") { 84 cflags_cc = [ "-fno-exceptions" ] 85 cflags_objcc = cflags_cc 86 ldflags = cflags_cc 87} 88 89config("stack_protector") { 90 cflags = [ "-fstack-protector-all" ] 91 cflags_cc = cflags 92} 93 94config("static_pie_config") { 95 cflags = [ "-fPIE" ] 96 cflags_cc = cflags 97} 98 99config("shared_library_config") { 100 cflags = [ "-fPIC" ] 101 cflags_cc = cflags 102} 103 104config("pie_executable_config") { 105 ldflags = [ "-pie" ] 106} 107 108config("ohos_clang") { 109 if (ohos_kernel_type == "linux") { 110 defines = [ 111 "_LIBCPP_HAS_MUSL_LIBC", 112 "__BUILD_LINUX_WITH_CLANG", 113 ] 114 } 115 ldflags = [ 116 "-fuse-ld=lld", 117 "--rtlib=compiler-rt", 118 ] 119} 120 121config("release") { 122 defines = [ "OHOS_RELEASE" ] 123} 124 125config("debug") { 126 defines = [ "OHOS_DEBUG" ] 127} 128 129config("clang_opt") { 130 cflags = [ 131 "-Oz", 132 "-flto", 133 ] 134 cflags_cc = cflags 135} 136 137config("gcc_opt") { 138 cflags = [ "-Os" ] 139 cflags_cc = cflags 140} 141 142config("default_link_path") { 143 ldflags = [ 144 "-L.", 145 "-Wl,-rpath-link=.", 146 ] 147} 148 149config("board_config") { 150 cflags = [] 151 cflags_cc = [] 152 ldflags = [] 153 include_dirs = [] 154 defines = [] 155 cflags += board_cflags 156 cflags_cc += board_cxx_flags 157 ldflags += board_ld_flags 158 include_dirs += board_include_dirs 159 if (defined(board_macro_defines)) { 160 defines += board_macro_defines 161 } 162} 163 164config("board_exe_ld_flags") { 165 ldflags = [] 166 if (defined(board_exe_ld_flags)) { 167 ldflags += board_exe_ld_flags 168 } 169} 170