package:
  name: ctng-compiler-activation
  version: {{ ctng_gcc }}

source:
  path: .

build:
  number: 0
  skip: True  # [not linux]

requirements:
  build:
    # this dep is for us to be able to use gcc -dumpmachine to get the CBUILD value
    - gcc_impl_{{ target_platform }}

outputs:
  - name: gcc_{{ ctng_target_platform }}
    script: install-gcc.sh
    requirements:
      run:
        - gcc_impl_{{ target_platform }} {{ ctng_gcc }}.*
        - gcc_impl_{{ ctng_target_platform }} {{ ctng_gcc }}.*
        # for activation of binutils env vars
        - {{ pin_subpackage("binutils_" ~ ctng_target_platform, exact=True) }}
        - sysroot_{{ target_platform }}
        - sysroot_{{ ctng_target_platform }}
    run_exports:
      strong:
        - libgcc-ng >={{ ctng_gcc }}
    test:
      requires:
        - sysroot_{{ ctng_target_platform }} {{ conda_glibc_ver }}
      files:
        - tests
      commands:
        - echo {{ ctng_target_platform_u }}
        - echo {{ linux_machine }}
        - ${CC} ${CFLAGS} -Wall tests/aligned_alloc.c -c -o c_aligned.o -v
        - ${CC} ${LDFLAGS} c_aligned.o -o c_aligned     # [target_platform == ctng_target_platform]
        - ./c_aligned                                   # [target_platform == ctng_target_platform]
        # CONDA_BUILD_SYSROOT is defined for clang++ to find correct C++ headers, see issue 8
        - test -z "${CONDA_BUILD_SYSROOT+x}" && echo "CONDA_BUILD_SYSROOT is not set" && exit 1
        - test -d ${CONDA_BUILD_SYSROOT} || exit 1
    about:
      summary: GNU C Compiler (activation scripts)
      home: https://github.com/conda-forge/ctng-compiler-activation-feedstock
      license: BSD-3-Clause
      license_file: LICENSE

  - name: gxx_{{ ctng_target_platform }}
    script: install-g++.sh
    requirements:
      run:
        - gxx_impl_{{ target_platform }} {{ ctng_gcc }}.*
        - gxx_impl_{{ ctng_target_platform }} {{ ctng_gcc }}.*
        # for activation of gcc env vars
        - {{ pin_subpackage("gcc_" ~ ctng_target_platform, exact=True) }}
        # for activation of binutils env vars
        - {{ pin_subpackage("binutils_" ~ ctng_target_platform, exact=True) }}
        - sysroot_{{ ctng_target_platform }}
    test:
      requires:
        - sysroot_{{ ctng_target_platform }} {{ conda_glibc_ver }}
      files:
        - tests
      commands:
        - ${CXX} ${CXXFLAGS} -Wall tests/aligned_alloc.cpp -c -o cpp_aligned.o
        - ${CXX} ${LDFLAGS} cpp_aligned.o -o cpp_aligned    # [target_platform == ctng_target_platform]
        - ./cpp_aligned                                     # [target_platform == ctng_target_platform]
        - test -z "${CONDA_BUILD_SYSROOT+x}" && echo "CONDA_BUILD_SYSROOT is not set" && exit 1
        - test -d ${CONDA_BUILD_SYSROOT} || exit 1
    run_exports:
      strong:
        - libstdcxx-ng >={{ ctng_gcc }}
        # Because transitive run_exports do not work:
        - libgcc-ng >={{ ctng_gcc }}
    about:
      summary: GNU C++ Compiler (activation scripts)
      home: https://github.com/conda-forge/ctng-compiler-activation-feedstock
      license: BSD-3-Clause
      license_file: LICENSE

  - name: gfortran_{{ ctng_target_platform }}
    script: install-gfortran.sh
    requirements:
      host:
        # So that pin_compatible has something to work with:
        - libgfortran{{ libgfortran_soname }} {{ ctng_gcc }}.*
        - libgfortran-ng
      run:
        - gfortran_impl_{{ ctng_target_platform }} {{ ctng_gcc }}.*
        # for activation of gcc env vars:
        - {{ pin_subpackage("gcc_" ~ ctng_target_platform, exact=True) }}
        # for activation of binutils env vars:
        - {{ pin_subpackage("binutils_" ~ ctng_target_platform, exact=True) }}
        - sysroot_{{ ctng_target_platform }}
    run_exports:
      strong:
        - libgfortran{{ libgfortran_soname }} >={{ ctng_gcc }}
        - libgfortran-ng
        # Because transitive run_exports do not work:
        - libgcc-ng >={{ ctng_gcc }}
    test:
      requires:
        - cmake >=3.11  # [x86_64 or aarch64 or ppc64le]
        - make          # [x86_64 or aarch64 or ppc64le]
        - sysroot_{{ ctng_target_platform }} {{ conda_glibc_ver }}
      commands:
        - ${FC} --version
        - pushd tests/fortomp
        - sh test_fort.sh       # [target_platform == ctng_target_platform and (x86_64 or aarch64 or ppc64le)]
      files:
        - tests/fortomp/*
    about:
      summary: GNU Fortran Compiler (activation scripts)
      home: https://github.com/conda-forge/ctng-compiler-activation-feedstock
      license: BSD-3-Clause
      license_file: LICENSE

  - name: binutils_{{ ctng_target_platform }}
    version: "{{ ctng_binutils }}"
    script: install-binutils.sh
    requirements:
      run:
        - binutils_impl_{{ ctng_target_platform }} {{ ctng_binutils }}.*
        - sysroot_{{ target_platform }}
        - sysroot_{{ ctng_target_platform }}
    test:
      requires:
        - sysroot_{{ ctng_target_platform }} {{ conda_glibc_ver }}
      commands:
        - test -f $LD
    about:
      summary: The GNU Binutils are a collection of binary tools (activation scripts)
      home: https://github.com/conda-forge/ctng-compiler-activation-feedstock
      license: BSD-3-Clause
      license_file: LICENSE

  - name: gcc_bootstrap_{{ ctng_target_platform }}
    version: "{{ ctng_gcc }}"
    requirements:
      host:
        - binutils_impl_{{ ctng_target_platform }} {{ ctng_binutils }}.*
        - gfortran_impl_{{ ctng_target_platform }} {{ ctng_gcc }}.*
        - gxx_impl_{{ ctng_target_platform }} {{ ctng_gcc }}.*
        - gcc_impl_{{ ctng_target_platform }} {{ ctng_gcc }}.*
    build:
      binary_relocation: False
      detect_binary_files_with_prefix: False
      always_include_files:
        - bin/
        - etc/
        - lib64/
        - lib/
        - libexec/
        - share/
        - {{ ctng_cpu_arch }}-{{ ctng_vendor }}-linux-gnu/
    test:
      commands:
        - test -f $PREFIX/bin/{{ ctng_cpu_arch }}-{{ ctng_vendor }}-linux-gnu-cc
    about:
      summary: GCC bootstrap compilers for building deps
      home: https://github.com/conda-forge/ctng-compiler-activation-feedstock
      license: GPL
      license_file: GPL_LICENSE

about:
  summary: Activation scripts for gcc, g++, gfortran and binutils
  home: https://github.com/conda-forge/ctng-compiler-activation-feedstock
  license: BSD-3-Clause
  license_file: LICENSE

extra:
  recipe-maintainers:
    - isuruf
    - beckermr
