fork/wezterm
git clone https://git.julia.blue/fork/wezterm
58a2a3062
main
1# Copyright © 2018 Intel Corporation 2 3# Permission is hereby granted, free of charge, to any person obtaining a copy 4# of this software and associated documentation files (the "Software"), to deal 5# in the Software without restriction, including without limitation the rights 6# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7# copies of the Software, and to permit persons to whom the Software is 8# furnished to do so, subject to the following conditions: 9 10# The above copyright notice and this permission notice shall be included in 11# all copies or substantial portions of the Software. 12 13# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19# SOFTWARE. 20 21project ( 22'pixman' , 23[ 'c' ] , 24version :'0.42.2' , 25license :'MIT' , 26meson_version :'>= 0.52.0' , 27default_options :[ 'c_std=gnu99' ,'buildtype=debugoptimized' ] , 28) 29 30config= configuration_data () 31cc= meson .get_compiler ( 'c' ) 32null_dep= dependency ( '' ,required :false ) 33 34add_project_arguments ( 35cc .get_supported_arguments ([ 36'-Wdeclaration-after-statement' , 37'-fno-strict-aliasing' , 38'-fvisibility=hidden' , 39'-Wundef' , 40# -ftrapping-math is the default for gcc, but -fno-trapping-math is the 41# default for clang. The FLOAT_IS_ZERO macro is used to guard against 42# floating-point exceptions, however with -fno-trapping-math, the compiler 43# can reorder floating-point operations so that they occur before the guard. 44# Note, this function is ignored in clang < 10.0.0. 45'-ftrapping-math' 46]) , 47language :[ 'c' ] 48) 49 50# GCC and Clang both ignore -Wno options that they don't recognize, so test for 51# -W<opt>, then add -Wno-<opt> if it's ignored 52foreach opt :[ 'unused-local-typedefs' ] 53if cc .has_argument ( '-W' + opt) 54add_project_arguments ([ '-Wno-' + opt] ,language :[ 'c' ]) 55endif 56endforeach 57 58use_loongson_mmi= get_option ( 'loongson-mmi' ) 59have_loongson_mmi= false 60loongson_mmi_flags= [ '-mloongson-mmi' ] 61if not use_loongson_mmi .disabled () 62if host_machine .cpu_family () == 'mips64' and cc .compiles ( ''' 63#ifndef __mips_loongson_vector_rev 64#error "Loongson Multimedia Instructions are only available on Loongson" 65#endif 66#if defined(__GNUC__) && (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 4)) 67#error "Need GCC >= 4.4 for Loongson MMI compilation" 68#endif 69#include "pixman/loongson-mmintrin.h" 70int main () { 71union { 72__m64 v; 73char c[8]; 74} a = { .c = {1, 2, 3, 4, 5, 6, 7, 8} }; 75int b = 4; 76__m64 c = _mm_srli_pi16 (a.v, b); 77return 0; 78}''' , 79args : loongson_mmi_flags, 80include_directories :include_directories ( '.' ) , 81name :'Loongson MMI Intrinsic Support' ) 82 have_loongson_mmi= true 83endif 84endif 85 86if have_loongson_mmi 87config .set10 ( 'USE_LOONGSON_MMI' ,true ) 88elif use_loongson_mmi .enabled () 89error ( 'Loongson MMI Support unavailable, but required' ) 90endif 91 92use_mmx= get_option ( 'mmx' ) 93have_mmx= false 94mmx_flags= [] 95 96if cc .get_id () == 'msvc' 97 mmx_flags= [ '/w14710' ,'/w14714' ,'/wd4244' ] 98elif cc .get_id () == 'sun' 99 mmx_flags= [ '-xarch=sse' ] 100else 101 mmx_flags= [ '-mmmx' ,'-Winline' ] 102endif 103if not use_mmx .disabled () 104if host_machine .cpu_family () == 'x86_64' orcc .get_id () == 'msvc' 105 have_mmx= true 106elif host_machine .cpu_family () == 'x86' and cc .compiles ( ''' 107#include <mmintrin.h> 108#include <stdint.h> 109 110/* Check support for block expressions */ 111#define _mm_shuffle_pi16(A, N) \ 112({ \ 113__m64 ret; \ 114\ 115/* Some versions of clang will choke on K */ \ 116asm ("pshufw %2, %1, %0\n\t" \ 117: "=y" (ret) \ 118: "y" (A), "K" ((const int8_t)N) \ 119); \ 120\ 121ret; \ 122}) 123 124int main () { 125__m64 v = _mm_cvtsi32_si64 (1); 126__m64 w; 127 128w = _mm_shuffle_pi16(v, 5); 129 130/* Some versions of clang will choke on this */ 131asm ("pmulhuw %1, %0\n\t" 132: "+y" (w) 133: "y" (v) 134); 135 136return _mm_cvtsi64_si32 (v); 137}''' , 138args : mmx_flags, 139name :'MMX Intrinsic Support' ) 140 have_mmx= true 141endif 142endif 143 144if have_mmx 145# Inline assembly do not work on X64 MSVC, so we use 146# compatibility intrinsics there 147if cc .get_id () != 'msvc' orhost_machine .cpu_family () != 'x86_64' 148config .set10 ( 'USE_X86_MMX' ,true ) 149endif 150elif use_mmx .enabled () 151error ( 'MMX Support unavailable, but required' ) 152endif 153 154use_sse2= get_option ( 'sse2' ) 155have_sse2= false 156sse2_flags= [] 157if cc .get_id () == 'sun' 158 sse2_flags= [ '-xarch=sse2' ] 159elif cc .get_id () != 'msvc' 160 sse2_flags= [ '-msse2' ,'-Winline' ] 161endif 162if not use_sse2 .disabled () 163if host_machine .cpu_family () == 'x86' 164if cc .compiles ( ''' 165#if defined(__GNUC__) && (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 2)) 166# if !defined(__amd64__) && !defined(__x86_64__) 167# error "Need GCC >= 4.2 for SSE2 intrinsics on x86" 168# endif 169#endif 170#include <mmintrin.h> 171#include <xmmintrin.h> 172#include <emmintrin.h> 173int param; 174int main () { 175__m128i a = _mm_set1_epi32 (param), b = _mm_set1_epi32 (param + 1), c; 176c = _mm_xor_si128 (a, b); 177return _mm_cvtsi128_si32(c); 178}''' , 179args : sse2_flags, 180name :'SSE2 Intrinsic Support' ) 181 have_sse2= true 182endif 183elif host_machine .cpu_family () == 'x86_64' 184 have_sse2= true 185endif 186endif 187 188if have_sse2 189config .set10 ( 'USE_SSE2' ,true ) 190elif use_sse2 .enabled () 191error ( 'sse2 Support unavailable, but required' ) 192endif 193 194use_ssse3= get_option ( 'ssse3' ) 195have_ssse3= false 196ssse3_flags= [] 197if cc .get_id () != 'msvc' 198 ssse3_flags= [ '-mssse3' ,'-Winline' ] 199endif 200 201# x64 pre-2010 MSVC compilers crashes when building the ssse3 code 202if not use_ssse3 .disabled () and not ( cc .get_id () == 'msvc' and cc .version () .version_compare ( '<16' ) and host_machine .cpu_family () == 'x86_64' ) 203if host_machine .cpu_family () .startswith ( 'x86' ) 204if cc .compiles ( ''' 205#include <mmintrin.h> 206#include <xmmintrin.h> 207#include <emmintrin.h> 208int param; 209int main () { 210__m128i a = _mm_set1_epi32 (param), b = _mm_set1_epi32 (param + 1), c; 211c = _mm_xor_si128 (a, b); 212return _mm_cvtsi128_si32(c); 213}''' , 214args : ssse3_flags, 215name :'SSSE3 Intrinsic Support' ) 216 have_ssse3= true 217endif 218endif 219endif 220 221if have_ssse3 222config .set10 ( 'USE_SSSE3' ,true ) 223elif use_ssse3 .enabled () 224error ( 'ssse3 Support unavailable, but required' ) 225endif 226 227use_vmx= get_option ( 'vmx' ) 228have_vmx= false 229vmx_flags= [ '-maltivec' ,'-mabi=altivec' ] 230if not use_vmx .disabled () 231if host_machine .cpu_family () .startswith ( 'ppc' ) 232if cc .compiles ( ''' 233#include <altivec.h> 234int main () { 235vector unsigned int v = vec_splat_u32 (1); 236v = vec_sub (v, v); 237return 0; 238}''' , 239args : vmx_flags, 240name :'VMX/Altivec Intrinsic Support' ) 241 have_vmx= true 242endif 243endif 244endif 245 246if have_vmx 247config .set10 ( 'USE_VMX' ,true ) 248elif use_vmx .enabled () 249error ( 'vmx Support unavailable, but required' ) 250endif 251 252use_armv6_simd= get_option ( 'arm-simd' ) 253have_armv6_simd= false 254if not use_armv6_simd .disabled () 255if host_machine .cpu_family () == 'arm' 256if cc .compiles ( files ( 'arm-simd-test.S' ) ,name :'ARMv6 SIMD Intrinsic Support' ) 257 have_armv6_simd= true 258endif 259endif 260endif 261 262if have_armv6_simd 263config .set10 ( 'USE_ARM_SIMD' ,true ) 264elif use_armv6_simd .enabled () 265error ( 'ARMv6 SIMD Support unavailable, but required' ) 266endif 267 268use_neon= get_option ( 'neon' ) 269have_neon= false 270if not use_neon .disabled () 271if host_machine .cpu_family () == 'arm' 272if cc .compiles ( files ( 'neon-test.S' ) ,name :'NEON Intrinsic Support' ) 273 have_neon= true 274endif 275endif 276endif 277 278if have_neon 279config .set10 ( 'USE_ARM_NEON' ,true ) 280elif use_neon .enabled () 281error ( 'NEON Support unavailable, but required' ) 282endif 283 284use_a64neon= get_option ( 'a64-neon' ) 285have_a64neon= false 286if not use_a64neon .disabled () 287if host_machine .cpu_family () == 'aarch64' 288if cc .compiles ( files ( 'a64-neon-test.S' ) ,name :'NEON A64 Intrinsic Support' ) 289 have_a64neon= true 290endif 291endif 292endif 293 294if have_a64neon 295config .set10 ( 'USE_ARM_A64_NEON' ,true ) 296elif use_a64neon .enabled () 297error ( 'A64 NEON Support unavailable, but required' ) 298endif 299 300use_iwmmxt= get_option ( 'iwmmxt' ) 301have_iwmmxt= false 302iwmmxt_flags= [ '-flax-vector-conversions' ,'-Winline' ] 303if not use_iwmmxt .disabled () 304if get_option ( 'iwmmxt2' ) 305 iwmmxt_flags+= '-march=iwmmxt2' 306else 307 iwmmxt_flags+= '-march=iwmmxt' 308endif 309 310if host_machine .cpu_family () == 'arm' 311if cc .compiles ( ''' 312#ifndef __IWMMXT__ 313#error "IWMMXT not enabled (with -march=iwmmxt)" 314#endif 315#if defined(__GNUC__) && (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 8)) 316#error "Need GCC >= 4.8 for IWMMXT intrinsics" 317#endif 318#include <mmintrin.h> 319int main () { 320union { 321__m64 v; 322char c[8]; 323} a = { .c = {1, 2, 3, 4, 5, 6, 7, 8} }; 324int b = 4; 325__m64 c = _mm_srli_si64 (a.v, b); 326} 327''' , 328args : iwmmxt_flags, 329name :'IWMMXT Intrinsic Support' ) 330 have_iwmmxt= true 331endif 332endif 333endif 334 335if have_iwmmxt 336config .set10 ( 'USE_ARM_IWMMXT' ,true ) 337elif use_iwmmxt .enabled () 338error ( 'IWMMXT Support unavailable, but required' ) 339endif 340 341use_mips_dspr2= get_option ( 'mips-dspr2' ) 342have_mips_dspr2= false 343mips_dspr2_flags= [ '-mdspr2' ] 344if not use_mips_dspr2 .disabled () 345if host_machine .cpu_family () == 'mips32' 346if cc .compiles ( ''' 347#if !(defined(__mips__) && __mips_isa_rev >= 2) 348#error MIPS DSPr2 is currently only available on MIPS32r2 platforms. 349#endif 350int 351main () 352{ 353int c = 0, a = 0, b = 0; 354__asm__ __volatile__ ( 355"precr.qb.ph %[c], %[a], %[b] \n\t" 356: [c] "=r" (c) 357: [a] "r" (a), [b] "r" (b) 358); 359return c; 360}''' , 361args : mipds_dspr2_flags, 362name :'DSPr2 Intrinsic Support' ) 363 have_mips_dspr2= true 364endif 365endif 366endif 367 368if have_mips_dspr2 369config .set10 ( 'USE_MIPS_DSPR2' ,true ) 370elif use_mips_dspr2 .enabled () 371error ( 'MIPS DSPr2 Support unavailable, but required' ) 372endif 373 374use_gnu_asm= get_option ( 'gnu-inline-asm' ) 375if not use_gnu_asm .disabled () 376if cc .compiles ( ''' 377int main () { 378/* Most modern architectures have a NOP instruction, so this is a fairly generic test. */ 379asm volatile ( "\tnop\n" : : : "cc", "memory" ); 380return 0; 381} 382''' , 383name :'GNU Inline ASM support.' ) 384config .set10 ( 'USE_GCC_INLINE_ASM' ,true ) 385elif use_gnu_asm .enabled () 386error ( 'GNU inline assembly support missing but required.' ) 387endif 388endif 389 390if get_option ( 'timers' ) 391config .set ( 'PIXMAN_TIMERS' ,1 ) 392endif 393if get_option ( 'gnuplot' ) 394config .set ( 'PIXMAN_GNUPLOT' ,1 ) 395endif 396 397if cc .get_id () != 'msvc' 398 dep_openmp= dependency ( 'openmp' ,required :get_option ( 'openmp' )) 399if dep_openmp .found () 400config .set10 ( 'USE_OPENMP' ,true ) 401elif meson .version () .version_compare ( '<0.51.0' ) 402# In versions of meson before 0.51 the openmp dependency can still 403# inject arguments in the the auto case when it is not found, the 404# detection does work correctly in that case however, so we just 405# replace dep_openmp with null_dep to work around this. 406 dep_openmp= null_dep 407endif 408else 409# the MSVC implementation of openmp is not compliant enough for our 410# uses here, so we disable it here. 411# Please see: https://stackoverflow.com/questions/12560243/using-threadprivate-directive-in-visual-studio 412 dep_openmp= null_dep 413endif 414 415dep_gtk= dependency ( 'gtk+-3.0' ,required :get_option ( 'gtk' )) 416dep_glib= dependency ( 'glib-2.0' ,required :get_option ( 'gtk' )) 417 418dep_png= null_dep 419if not get_option ( 'libpng' ) .disabled () 420 dep_png= dependency ( 'libpng' ,required :false ) 421 422# We need to look for the right library to link to for libpng, 423# when looking for libpng manually 424foreach png_ver :[ '16' ,'15' ,'14' ,'13' ,'12' ,'10' ] 425if not dep_png .found () 426 dep_png= cc .find_library ( 'libpng @ 0 @ ' .format ( png_ver) ,has_headers :[ 'png.h' ] ,required :false ) 427endif 428endforeach 429 430if get_option ( 'libpng' ) .enabled () and not dep_png .found () 431error ( 'libpng support requested but libpng library not found' ) 432endif 433endif 434 435if dep_png .found () 436config .set ( 'HAVE_LIBPNG' ,1 ) 437endif 438dep_m= cc .find_library ( 'm' ,required :false ) 439dep_threads= dependency ( 'threads' ) 440 441# MSVC-style compilers do not come with pthreads, so we must link 442# to it explicitly, currently pthreads-win32 is supported 443pthreads_found= false 444 445if dep_threads .found () and cc .has_header ( 'pthread.h' ) 446if cc .get_argument_syntax () == 'msvc' 447 pthread_lib= null_dep 448foreach pthread_type :[ 'VC3' ,'VSE3' ,'VCE3' ,'VC2' ,'VSE2' ,'VCE2' ] 449if not pthread_lib .found () 450 pthread_lib= cc .find_library ( 'pthread @ 0 @ ' .format ( pthread_type) ,required :false ) 451endif 452endforeach 453if pthread_lib .found () 454 pthreads_found= true 455 dep_threads= pthread_lib 456endif 457else 458 pthreads_found= true 459endif 460endif 461 462if pthreads_found 463config .set ( 'HAVE_PTHREADS' ,1 ) 464endif 465 466funcs= [ 'sigaction' ,'alarm' ,'mprotect' ,'getpagesize' ,'mmap' ,'getisax' ,'gettimeofday' ] 467# mingw claimes to have posix_memalign, but it doesn't 468if host_machine .system () != 'windows' 469 funcs+= 'posix_memalign' 470endif 471 472foreach f : funcs 473if cc .has_function ( f) 474config .set ( 'HAVE_ @ 0 @ ' .format ( f .to_upper ()) ,1 ) 475endif 476endforeach 477 478# This is only used in one test, that defines _GNU_SOURCE 479if cc .has_function ( 'feenableexcept' , 480prefix :'#define _GNU_SOURCE\n#include <fenv.h>' , 481dependencies : dep_m) 482config .set ( 'HAVE_FEENABLEEXCEPT' ,1 ) 483endif 484 485if cc .has_header_symbol ( 'fenv.h' ,'FE_DIVBYZERO' ) 486config .set ( 'HAVE_FEDIVBYZERO' ,1 ) 487endif 488 489foreach h :[ 'sys/mman.h' ,'fenv.h' ,'unistd.h' ] 490if cc .check_header ( h) 491config .set ( 'HAVE_ @ 0 @ ' .format ( h .underscorify () .to_upper ()) ,1 ) 492endif 493endforeach 494 495use_tls= get_option ( 'tls' ) 496have_tls= '' 497if not use_tls .disabled () 498# gcc on Windows only warns that __declspec(thread) isn't supported, 499# passing -Werror=attributes makes it fail. 500if ( host_machine .system () == 'windows' and 501cc .compiles ( 'int __declspec(thread) foo;' , 502args :cc .get_supported_arguments ([ '-Werror=attributes' ]) , 503name :'TLS via __declspec(thread)' )) 504 have_tls= '__declspec(thread)' 505elif cc .compiles ( 'int __thread foo;' ,name :'TLS via __thread' ) 506 have_tls= '__thread' 507endif 508endif 509 510if have_tls!= '' 511config .set ( 'TLS' , have_tls) 512elif use_tls .enabled () 513error ( 'Compiler TLS Support unavailable, but required' ) 514endif 515 516if cc .links ( ''' 517static int x = 1; 518static void __attribute__((constructor)) constructor_function () { x = 0; } 519int main (void) { return x; } 520''' , 521name :'__attribute__((constructor))' ) 522config .set ( 'TOOLCHAIN_SUPPORTS_ATTRIBUTE_CONSTRUCTOR' ,1 ) 523endif 524 525if cc .links ( 526' __float128 a = 1.0Q, b = 2.0Q; int main (void) { return a + b; }' , 527name :'Has float128 support' ) 528config .set ( 'HAVE_FLOAT128' ,1 ) 529endif 530 531if cc .has_function ( 'clz' ) 532config .set ( 'HAVE_BUILTIN_CLZ' ,1 ) 533endif 534 535if cc .links ( ''' 536unsigned int __attribute__ ((vector_size(16))) e, a, b; 537int main (void) { e = a - ((b << 27) + (b >> (32 - 27))) + 1; return e[0]; } 538''' , 539name :'Support for GCC vector extensions' ) 540config .set ( 'HAVE_GCC_VECTOR_EXTENSIONS' ,1 ) 541endif 542 543if host_machine .endian () == 'big' 544config .set ( 'WORDS_BIGENDIAN' ,1 ) 545endif 546 547config .set ( 'SIZEOF_LONG' ,cc .sizeof ( 'long' )) 548 549# Required to make pixman-private.h 550config .set ( 'PACKAGE' ,'foo' ) 551 552version_conf= configuration_data () 553split= meson .project_version () .split ( '.' ) 554version_conf .set ( 'PIXMAN_VERSION_MAJOR' , split[ 0 ]) 555version_conf .set ( 'PIXMAN_VERSION_MINOR' , split[ 1 ]) 556version_conf .set ( 'PIXMAN_VERSION_MICRO' , split[ 2 ]) 557 558add_project_arguments ( '-DHAVE_CONFIG_H' ,language :[ 'c' ]) 559 560subdir ( 'pixman' ) 561 562if not get_option ( 'tests' ) .disabled () 563subdir ( 'test' ) 564subdir ( 'demos' ) 565endif 566 567pkg= import ( 'pkgconfig' ) 568pkg .generate ( libpixman, 569name :'Pixman' , 570filebase :'pixman-1' , 571description :'The pixman library (version 1)' , 572subdirs :'pixman-1' , 573version :meson .project_version () , 574)