| 1 | #!/bin/shscip-shell filesystem . . `/bin/sh`. |
| 2 | |
| 3 | # |
| 4 | # Copyright 2018 Helmut Grohne <[email protected]> |
| 5 | # |
| 6 | # Redistribution and use in source and binary forms, with or without |
| 7 | # modification, are permitted provided that the following conditions are met: |
| 8 | # |
| 9 | # 1. Redistributions of source code must retain the above copyright notice, |
| 10 | # this list of conditions and the following disclaimer. |
| 11 | # |
| 12 | # 2. Redistributions in binary form must reproduce the above copyright notice, |
| 13 | # this list of conditions and the following disclaimer in the documentation |
| 14 | # and/or other materials provided with the distribution. |
| 15 | # |
| 16 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 17 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 18 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 19 | # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
| 20 | # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 21 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 22 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 23 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 24 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 25 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
| 26 | # THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | # |
| 28 | # Usage: pass the host architecture as a parameter: |
| 29 | # |
| 30 | # ./debtoolchainfilegen armhf > cmake_toolchain_armhf.cmake |
| 31 | |
| 32 | if [scip-shell system . . `[`. -z "$1" ] |
| 33 | then |
| 34 | echoscip-shell system . . echo. "Usage: debtoolchainfilegen (arch) > cmake_toolchain_<arch>.cmake" |
| 35 | exit 1 |
| 36 | fi |
| 37 | |
| 38 | ARCH=$1 |
| 39 | |
| 40 | DEB_HOST_GNU_TYPE=$(dpkg-architecturescip-shell system . . dpkg-architecture. -f "-a$1" -qDEB_HOST_GNU_TYPE) |
| 41 | DEB_HOST_GNU_CPU=$(dpkg-architecturescip-shell system . . dpkg-architecture. -f "-a$1" -qDEB_HOST_GNU_CPU) |
| 42 | case "$(dpkg-architecturescip-shell system . . dpkg-architecture. -f "-a$1" -qDEB_HOST_ARCH_OS)" in |
| 43 | linux) system_name=Linux; ;; |
| 44 | hurd) system_name=GNU; ;; |
| 45 | *) exit 1; ;; |
| 46 | esac |
| 47 | |
| 48 | catscip-shell system . . cat. <<EOF |
| 49 | # Use it while calling CMake: |
| 50 | # mkdir build; cd build |
| 51 | # cmake -DCMAKE_TOOLCHAIN_FILE="/path/to/cmake_toolchain_<arch>.cmake" ../ |
| 52 | # |
| 53 | set(CMAKE_SYSTEM_NAME "$system_name") |
| 54 | set(CMAKE_SYSTEM_PROCESSOR "$DEB_HOST_GNU_CPU") |
| 55 | set(CMAKE_C_COMPILER "$DEB_HOST_GNU_TYPE-gcc") |
| 56 | set(CMAKE_CXX_COMPILER "$DEB_HOST_GNU_TYPE-g++") |
| 57 | set(PKG_CONFIG_EXECUTABLE "$DEB_HOST_GNU_TYPE-pkg-config") |
| 58 | set(PKGCONFIG_EXECUTABLE "$DEB_HOST_GNU_TYPE-pkg-config") |
| 59 | set(QMAKE_EXECUTABLE "$DEB_HOST_GNU_TYPE-qmake") |
| 60 | EOF |