Home | History | Annotate | Line # | Download | only in Configurations
      1  1.1  christos #! /usr/bin/env perl
      2  1.1  christos # -*- mode: perl; -*-
      3  1.1  christos # Copyright 2016-2018 The OpenSSL Project Authors. All Rights Reserved.
      4  1.1  christos #
      5  1.1  christos # Licensed under the OpenSSL license (the "License").  You may not use
      6  1.1  christos # this file except in compliance with the License.  You can obtain a copy
      7  1.1  christos # in the file LICENSE in the source distribution or at
      8  1.1  christos # https://www.openssl.org/source/license.html
      9  1.1  christos 
     10  1.1  christos # This is a collection of extra attributes to be used as input for creating
     11  1.1  christos # shared libraries, currently on any Unix variant, including Unix like
     12  1.1  christos # environments on Windows.
     13  1.1  christos 
     14  1.1  christos sub detect_gnu_ld {
     15  1.1  christos     my @lines =
     16  1.1  christos         `$config{CROSS_COMPILE}$config{CC} -Wl,-V /dev/null 2>&1`;
     17  1.1  christos     return grep /^GNU ld/, @lines;
     18  1.1  christos }
     19  1.1  christos sub detect_gnu_cc {
     20  1.1  christos     my @lines =
     21  1.1  christos         `$config{CROSS_COMPILE}$config{CC} -v 2>&1`;
     22  1.1  christos     return grep /gcc/, @lines;
     23  1.1  christos }
     24  1.1  christos 
     25  1.1  christos my %shared_info;
     26  1.1  christos %shared_info = (
     27  1.1  christos     'gnu-shared' => {
     28  1.1  christos         shared_ldflag         => '-shared -Wl,-Bsymbolic',
     29  1.1  christos         shared_sonameflag     => '-Wl,-soname=',
     30  1.1  christos     },
     31  1.1  christos     'linux-shared' => sub {
     32  1.1  christos         return {
     33  1.1  christos             %{$shared_info{'gnu-shared'}},
     34  1.1  christos             shared_defflag    => '-Wl,--version-script=',
     35  1.1  christos         };
     36  1.1  christos     },
     37  1.1  christos     'bsd-gcc-shared' => sub { return $shared_info{'linux-shared'}; },
     38  1.1  christos     'bsd-shared' => sub {
     39  1.1  christos         return $shared_info{'gnu-shared'} if detect_gnu_ld();
     40  1.1  christos         return {
     41  1.1  christos             shared_ldflag     => '-shared -nostdlib',
     42  1.1  christos         };
     43  1.1  christos     },
     44  1.1  christos     'darwin-shared' => {
     45  1.1  christos         module_ldflags        => '-bundle',
     46  1.1  christos         shared_ldflag         => '-dynamiclib -current_version $(SHLIB_VERSION_NUMBER) -compatibility_version $(SHLIB_VERSION_NUMBER)',
     47  1.1  christos         shared_sonameflag     => '-install_name $(INSTALLTOP)/$(LIBDIR)/',
     48  1.1  christos     },
     49  1.1  christos     'cygwin-shared' => {
     50  1.1  christos         shared_ldflag         => '-shared -Wl,--enable-auto-image-base',
     51  1.1  christos         shared_impflag        => '-Wl,--out-implib=',
     52  1.1  christos     },
     53  1.1  christos     'mingw-shared' => sub {
     54  1.1  christos         return {
     55  1.1  christos             %{$shared_info{'cygwin-shared'}},
     56  1.1  christos             # def_flag made to empty string so  it still generates
     57  1.1  christos             # something
     58  1.1  christos             shared_defflag    => '',
     59  1.1  christos         };
     60  1.1  christos     },
     61  1.1  christos     'alpha-osf1-shared' => sub {
     62  1.1  christos         return $shared_info{'gnu-shared'} if detect_gnu_ld();
     63  1.1  christos         return {
     64  1.1  christos             module_ldflags    => '-shared -Wl,-Bsymbolic',
     65  1.1  christos             shared_ldflag     => '-shared -Wl,-Bsymbolic -set_version $(SHLIB_VERSION_NUMBER)',
     66  1.1  christos         };
     67  1.1  christos     },
     68  1.1  christos     'svr3-shared' => sub {
     69  1.1  christos         return $shared_info{'gnu-shared'} if detect_gnu_ld();
     70  1.1  christos         return {
     71  1.1  christos             shared_ldflag     => '-G',
     72  1.1  christos             shared_sonameflag => '-h ',
     73  1.1  christos         };
     74  1.1  christos     },
     75  1.1  christos     'svr5-shared' => sub {
     76  1.1  christos         return $shared_info{'gnu-shared'} if detect_gnu_ld();
     77  1.1  christos         return {
     78  1.1  christos             shared_ldflag     => detect_gnu_cc() ? '-shared' : '-G',
     79  1.1  christos             shared_sonameflag => '-h ',
     80  1.1  christos         };
     81  1.1  christos     },
     82  1.1  christos );
     83