paul@24 | 1 | #!/bin/sh |
paul@24 | 2 | |
paul@144 | 3 | # Customise the configuration of the software for a particular target |
paul@144 | 4 | # platform. |
paul@144 | 5 | # |
paul@144 | 6 | # Copyright (C) 2018, 2023 Paul Boddie <paul@boddie.org.uk> |
paul@144 | 7 | # |
paul@144 | 8 | # This program is free software; you can redistribute it and/or |
paul@144 | 9 | # modify it under the terms of the GNU General Public License as |
paul@144 | 10 | # published by the Free Software Foundation; either version 2 of |
paul@144 | 11 | # the License, or (at your option) any later version. |
paul@144 | 12 | # |
paul@144 | 13 | # This program is distributed in the hope that it will be useful, |
paul@144 | 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
paul@144 | 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
paul@144 | 16 | # GNU General Public License for more details. |
paul@144 | 17 | # |
paul@144 | 18 | # You should have received a copy of the GNU General Public License |
paul@144 | 19 | # along with this program; if not, write to the Free Software |
paul@144 | 20 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, |
paul@144 | 21 | # Boston, MA 02110-1301, USA |
paul@144 | 22 | |
paul@144 | 23 | THISDIR=$(dirname "$0") |
paul@144 | 24 | DIRNAME=$(readlink -f "$THISDIR/..") |
paul@144 | 25 | PROGNAME=$(basename "$0") |
paul@24 | 26 | |
paul@24 | 27 | if [ "$1" = '--help' ] || [ ! "$1" ] ; then |
paul@24 | 28 | cat 1>&2 <<EOF |
paul@40 | 29 | Usage: $PROGNAME [-q] <platform> | <l4 directory> |
paul@24 | 30 | |
paul@28 | 31 | Update platform-specific files for the indicated platform type. If a directory |
paul@28 | 32 | is specified instead, try and obtain a configured platform type and use that |
paul@24 | 33 | to update the files. |
paul@24 | 34 | |
paul@28 | 35 | If a platform type is explicitly indicated, this program will update files in |
paul@28 | 36 | the distribution. They must then be installed using the install program: |
paul@24 | 37 | |
paul@24 | 38 | $THISDIR/install.sh |
paul@28 | 39 | |
paul@28 | 40 | If a directory is specified instead, this program will update installed files, |
paul@28 | 41 | leaving the distribution alone. |
paul@40 | 42 | |
paul@40 | 43 | The -q option silences warnings about the build directory and is used by the |
paul@40 | 44 | installation tool. |
paul@24 | 45 | EOF |
paul@24 | 46 | exit 1 |
paul@24 | 47 | fi |
paul@24 | 48 | |
paul@40 | 49 | if [ "$1" = '-q' ] ; then |
paul@40 | 50 | QUIET="$1" |
paul@40 | 51 | shift 1 |
paul@40 | 52 | else |
paul@40 | 53 | QUIET= |
paul@40 | 54 | fi |
paul@40 | 55 | |
paul@24 | 56 | # Check for a build directory and obtain a platform type. |
paul@24 | 57 | |
paul@28 | 58 | if [ -e "$1" ] ; then |
paul@28 | 59 | |
paul@28 | 60 | # Look for the configuration in a subdirectory. |
paul@28 | 61 | |
paul@28 | 62 | for FILENAME in "$1/"*"/.config.platform" ; do |
paul@28 | 63 | |
paul@28 | 64 | # Test for a valid file since the expansion will yield the pattern |
paul@28 | 65 | # itself if no files match. |
paul@28 | 66 | |
paul@28 | 67 | if [ -e "$FILENAME" ] ; then |
paul@28 | 68 | |
paul@28 | 69 | # Set the platform and the installation as target. |
paul@28 | 70 | |
paul@144 | 71 | PLATFORM=$(grep -e 'CONFIG_PLATFORM_TYPE=' "$FILENAME" | sed 's/^.*=//;s/"//g') |
paul@28 | 72 | TARGETDIR="$1" |
paul@28 | 73 | break |
paul@28 | 74 | else |
paul@40 | 75 | if [ ! "$QUIET" ] ; then |
paul@40 | 76 | cat 1>&2 <<EOF |
paul@28 | 77 | The specified directory does not contain an existing, configured build |
paul@28 | 78 | directory. Make sure that the configuration has been checked with the |
paul@28 | 79 | appropriate tool specifying a platform as argument: |
paul@28 | 80 | |
paul@28 | 81 | $DIRNAME/$PROGNAME <platform> |
paul@28 | 82 | EOF |
paul@40 | 83 | fi |
paul@28 | 84 | exit 1 |
paul@28 | 85 | fi |
paul@28 | 86 | done |
paul@24 | 87 | |
paul@24 | 88 | # Check for a recognised platform type. |
paul@24 | 89 | |
paul@24 | 90 | elif grep -q -F -e "$1" "$DIRNAME/conf/landfall-examples/platforms.txt" ; then |
paul@28 | 91 | |
paul@28 | 92 | # Set the platform and the distribution as target. |
paul@28 | 93 | |
paul@24 | 94 | PLATFORM="$1" |
paul@28 | 95 | TARGETDIR="$DIRNAME" |
paul@24 | 96 | |
paul@24 | 97 | # Show an error for anything else. |
paul@24 | 98 | |
paul@24 | 99 | else |
paul@24 | 100 | cat 1>&2 <<EOF |
paul@24 | 101 | Platform not recognised: $1 |
paul@24 | 102 | EOF |
paul@24 | 103 | exit 1 |
paul@24 | 104 | fi |
paul@24 | 105 | |
paul@40 | 106 | # Handle missing configuration files. This may happen when installing into an |
paul@40 | 107 | # existing directory hierarchy with build products. |
paul@40 | 108 | |
paul@40 | 109 | if [ ! -e "$TARGETDIR/conf/landfall-examples" ] ; then |
paul@40 | 110 | exit 0 |
paul@40 | 111 | fi |
paul@40 | 112 | |
paul@28 | 113 | # Panel configuration file in the target area. |
paul@24 | 114 | |
paul@28 | 115 | PANELCONF="$TARGETDIR/conf/landfall-examples/mips-jz4740-panel.txt" |
paul@24 | 116 | |
paul@24 | 117 | # Determine the required value of the panel configuration. |
paul@24 | 118 | |
paul@24 | 119 | PANELLIB="rom/libpanel_$PLATFORM.so" |
paul@24 | 120 | |
paul@24 | 121 | # Write it to the configuration file. |
paul@24 | 122 | |
paul@24 | 123 | echo -n "$PANELLIB" > "$PANELCONF" |
paul@38 | 124 | |
paul@38 | 125 | # Keypad configuration file in the target area. |
paul@38 | 126 | |
paul@38 | 127 | KEYPADCONF="$TARGETDIR/conf/landfall-examples/input-keypad.txt" |
paul@38 | 128 | |
paul@38 | 129 | # Determine the required value of the panel configuration. |
paul@38 | 130 | |
paul@38 | 131 | KEYPADLIB="rom/libkeypad_$PLATFORM.so" |
paul@38 | 132 | |
paul@38 | 133 | # Write it to the configuration file. |
paul@38 | 134 | |
paul@38 | 135 | echo -n "$KEYPADLIB" > "$KEYPADCONF" |
paul@144 | 136 | |
paul@144 | 137 | # vim: tabstop=4 expandtab shiftwidth=4 |