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