test/missing
author Patrice Mandin <patmandin@gmail.com>
Thu, 19 Jan 2006 21:28:52 +0000
changeset 1257 448a9a64537b
parent 729 dac996d69abb
permissions -rwxr-xr-x
[PATCH] SDL_GetVideoMode() does not find best mode, part 2

Following commit 1.51, I come accross a problem when SDL must choose between
several video modes that could suit the one asked.

If I ask 320x240 with this list:
768x480 768x240 640x400 640x200 384x480 384x240 320x400 320x200

The smallest selectables modes are 384x240 and 320x400. And SDL choose the later
in this list, but 384x240 is more suitable. So I added a check to compare
the pixel count (surface) of modes, and select the one which has the smallest
pixel count.

In my example, 384x240 has 92160 pixels, and 320x400 has 128000 pixels. So now
SDL will choose 384x240 for the asked 320x240 mode.
slouken@0
     1
#! /bin/sh
slouken@0
     2
# Common stub for a few missing GNU programs while installing.
slouken@729
     3
# Copyright (C) 1996, 1997, 1999, 2000, 2002 Free Software Foundation, Inc.
slouken@729
     4
# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
slouken@0
     5
slouken@0
     6
# This program is free software; you can redistribute it and/or modify
slouken@0
     7
# it under the terms of the GNU General Public License as published by
slouken@0
     8
# the Free Software Foundation; either version 2, or (at your option)
slouken@0
     9
# any later version.
slouken@0
    10
slouken@0
    11
# This program is distributed in the hope that it will be useful,
slouken@0
    12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
slouken@0
    13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
slouken@0
    14
# GNU General Public License for more details.
slouken@0
    15
slouken@0
    16
# You should have received a copy of the GNU General Public License
slouken@0
    17
# along with this program; if not, write to the Free Software
slouken@0
    18
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
slouken@0
    19
# 02111-1307, USA.
slouken@0
    20
slouken@729
    21
# As a special exception to the GNU General Public License, if you
slouken@729
    22
# distribute this file as part of a program that contains a
slouken@729
    23
# configuration script generated by Autoconf, you may include it under
slouken@729
    24
# the same distribution terms that you use for the rest of that program.
slouken@729
    25
slouken@0
    26
if test $# -eq 0; then
slouken@0
    27
  echo 1>&2 "Try \`$0 --help' for more information"
slouken@0
    28
  exit 1
slouken@0
    29
fi
slouken@0
    30
slouken@729
    31
run=:
slouken@729
    32
slouken@729
    33
# In the cases where this matters, `missing' is being run in the
slouken@729
    34
# srcdir already.
slouken@729
    35
if test -f configure.ac; then
slouken@729
    36
  configure_ac=configure.ac
slouken@729
    37
else
slouken@729
    38
  configure_ac=configure.in
slouken@729
    39
fi
slouken@729
    40
slouken@729
    41
case "$1" in
slouken@729
    42
--run)
slouken@729
    43
  # Try to run requested program, and just exit if it succeeds.
slouken@729
    44
  run=
slouken@729
    45
  shift
slouken@729
    46
  "$@" && exit 0
slouken@729
    47
  ;;
slouken@729
    48
esac
slouken@729
    49
slouken@729
    50
# If it does not exist, or fails to run (possibly an outdated version),
slouken@729
    51
# try to emulate it.
slouken@0
    52
case "$1" in
slouken@0
    53
slouken@0
    54
  -h|--h|--he|--hel|--help)
slouken@0
    55
    echo "\
slouken@0
    56
$0 [OPTION]... PROGRAM [ARGUMENT]...
slouken@0
    57
slouken@0
    58
Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
slouken@0
    59
error status if there is no known handling for PROGRAM.
slouken@0
    60
slouken@0
    61
Options:
slouken@0
    62
  -h, --help      display this help and exit
slouken@0
    63
  -v, --version   output version information and exit
slouken@729
    64
  --run           try to run the given command, and emulate it if it fails
slouken@0
    65
slouken@0
    66
Supported PROGRAM values:
slouken@0
    67
  aclocal      touch file \`aclocal.m4'
slouken@0
    68
  autoconf     touch file \`configure'
slouken@0
    69
  autoheader   touch file \`config.h.in'
slouken@0
    70
  automake     touch all \`Makefile.in' files
slouken@0
    71
  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
slouken@0
    72
  flex         create \`lex.yy.c', if possible, from existing .c
slouken@729
    73
  help2man     touch the output file
slouken@0
    74
  lex          create \`lex.yy.c', if possible, from existing .c
slouken@0
    75
  makeinfo     touch the output file
slouken@729
    76
  tar          try tar, gnutar, gtar, then tar without non-portable flags
slouken@0
    77
  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]"
slouken@0
    78
    ;;
slouken@0
    79
slouken@0
    80
  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
slouken@729
    81
    echo "missing 0.4 - GNU automake"
slouken@0
    82
    ;;
slouken@0
    83
slouken@0
    84
  -*)
slouken@0
    85
    echo 1>&2 "$0: Unknown \`$1' option"
slouken@0
    86
    echo 1>&2 "Try \`$0 --help' for more information"
slouken@0
    87
    exit 1
slouken@0
    88
    ;;
slouken@0
    89
slouken@729
    90
  aclocal*)
slouken@729
    91
    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
slouken@729
    92
       # We have it, but it failed.
slouken@729
    93
       exit 1
slouken@729
    94
    fi
slouken@729
    95
slouken@0
    96
    echo 1>&2 "\
slouken@0
    97
WARNING: \`$1' is missing on your system.  You should only need it if
slouken@729
    98
         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
slouken@0
    99
         to install the \`Automake' and \`Perl' packages.  Grab them from
slouken@0
   100
         any GNU archive site."
slouken@0
   101
    touch aclocal.m4
slouken@0
   102
    ;;
slouken@0
   103
slouken@0
   104
  autoconf)
slouken@729
   105
    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
slouken@729
   106
       # We have it, but it failed.
slouken@729
   107
       exit 1
slouken@729
   108
    fi
slouken@729
   109
slouken@0
   110
    echo 1>&2 "\
slouken@0
   111
WARNING: \`$1' is missing on your system.  You should only need it if
slouken@729
   112
         you modified \`${configure_ac}'.  You might want to install the
slouken@0
   113
         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
slouken@0
   114
         archive site."
slouken@0
   115
    touch configure
slouken@0
   116
    ;;
slouken@0
   117
slouken@0
   118
  autoheader)
slouken@729
   119
    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
slouken@729
   120
       # We have it, but it failed.
slouken@729
   121
       exit 1
slouken@729
   122
    fi
slouken@729
   123
slouken@0
   124
    echo 1>&2 "\
slouken@0
   125
WARNING: \`$1' is missing on your system.  You should only need it if
slouken@729
   126
         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
slouken@0
   127
         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
slouken@0
   128
         from any GNU archive site."
slouken@729
   129
    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
slouken@0
   130
    test -z "$files" && files="config.h"
slouken@0
   131
    touch_files=
slouken@0
   132
    for f in $files; do
slouken@0
   133
      case "$f" in
slouken@0
   134
      *:*) touch_files="$touch_files "`echo "$f" |
slouken@0
   135
				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
slouken@0
   136
      *) touch_files="$touch_files $f.in";;
slouken@0
   137
      esac
slouken@0
   138
    done
slouken@0
   139
    touch $touch_files
slouken@0
   140
    ;;
slouken@0
   141
slouken@729
   142
  automake*)
slouken@729
   143
    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
slouken@729
   144
       # We have it, but it failed.
slouken@729
   145
       exit 1
slouken@729
   146
    fi
slouken@729
   147
slouken@0
   148
    echo 1>&2 "\
slouken@0
   149
WARNING: \`$1' is missing on your system.  You should only need it if
slouken@729
   150
         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
slouken@0
   151
         You might want to install the \`Automake' and \`Perl' packages.
slouken@0
   152
         Grab them from any GNU archive site."
slouken@0
   153
    find . -type f -name Makefile.am -print |
slouken@0
   154
	   sed 's/\.am$/.in/' |
slouken@0
   155
	   while read f; do touch "$f"; done
slouken@0
   156
    ;;
slouken@0
   157
slouken@729
   158
  autom4te)
slouken@729
   159
    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
slouken@729
   160
       # We have it, but it failed.
slouken@729
   161
       exit 1
slouken@729
   162
    fi
slouken@729
   163
slouken@729
   164
    echo 1>&2 "\
slouken@729
   165
WARNING: \`$1' is needed, and you do not seem to have it handy on your
slouken@729
   166
         system.  You might have modified some files without having the
slouken@729
   167
         proper tools for further handling them.
slouken@729
   168
         You can get \`$1Help2man' as part of \`Autoconf' from any GNU
slouken@729
   169
         archive site."
slouken@729
   170
slouken@729
   171
    file=`echo "$*" | sed -n 's/.*--output[ =]*\([^ ]*\).*/\1/p'`
slouken@729
   172
    test -z "$file" && file=`echo "$*" | sed -n 's/.*-o[ ]*\([^ ]*\).*/\1/p'`
slouken@729
   173
    if test -f "$file"; then
slouken@729
   174
	touch $file
slouken@729
   175
    else
slouken@729
   176
	test -z "$file" || exec >$file
slouken@729
   177
	echo "#! /bin/sh"
slouken@729
   178
	echo "# Created by GNU Automake missing as a replacement of"
slouken@729
   179
	echo "#  $ $@"
slouken@729
   180
	echo "exit 0"
slouken@729
   181
	chmod +x $file
slouken@729
   182
	exit 1
slouken@729
   183
    fi
slouken@729
   184
    ;;
slouken@729
   185
slouken@0
   186
  bison|yacc)
slouken@0
   187
    echo 1>&2 "\
slouken@0
   188
WARNING: \`$1' is missing on your system.  You should only need it if
slouken@0
   189
         you modified a \`.y' file.  You may need the \`Bison' package
slouken@0
   190
         in order for those modifications to take effect.  You can get
slouken@0
   191
         \`Bison' from any GNU archive site."
slouken@0
   192
    rm -f y.tab.c y.tab.h
slouken@0
   193
    if [ $# -ne 1 ]; then
slouken@0
   194
        eval LASTARG="\${$#}"
slouken@0
   195
	case "$LASTARG" in
slouken@0
   196
	*.y)
slouken@0
   197
	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
slouken@0
   198
	    if [ -f "$SRCFILE" ]; then
slouken@0
   199
	         cp "$SRCFILE" y.tab.c
slouken@0
   200
	    fi
slouken@0
   201
	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
slouken@0
   202
	    if [ -f "$SRCFILE" ]; then
slouken@0
   203
	         cp "$SRCFILE" y.tab.h
slouken@0
   204
	    fi
slouken@0
   205
	  ;;
slouken@0
   206
	esac
slouken@0
   207
    fi
slouken@0
   208
    if [ ! -f y.tab.h ]; then
slouken@0
   209
	echo >y.tab.h
slouken@0
   210
    fi
slouken@0
   211
    if [ ! -f y.tab.c ]; then
slouken@0
   212
	echo 'main() { return 0; }' >y.tab.c
slouken@0
   213
    fi
slouken@0
   214
    ;;
slouken@0
   215
slouken@0
   216
  lex|flex)
slouken@0
   217
    echo 1>&2 "\
slouken@0
   218
WARNING: \`$1' is missing on your system.  You should only need it if
slouken@0
   219
         you modified a \`.l' file.  You may need the \`Flex' package
slouken@0
   220
         in order for those modifications to take effect.  You can get
slouken@0
   221
         \`Flex' from any GNU archive site."
slouken@0
   222
    rm -f lex.yy.c
slouken@0
   223
    if [ $# -ne 1 ]; then
slouken@0
   224
        eval LASTARG="\${$#}"
slouken@0
   225
	case "$LASTARG" in
slouken@0
   226
	*.l)
slouken@0
   227
	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
slouken@0
   228
	    if [ -f "$SRCFILE" ]; then
slouken@0
   229
	         cp "$SRCFILE" lex.yy.c
slouken@0
   230
	    fi
slouken@0
   231
	  ;;
slouken@0
   232
	esac
slouken@0
   233
    fi
slouken@0
   234
    if [ ! -f lex.yy.c ]; then
slouken@0
   235
	echo 'main() { return 0; }' >lex.yy.c
slouken@0
   236
    fi
slouken@0
   237
    ;;
slouken@0
   238
slouken@729
   239
  help2man)
slouken@729
   240
    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
slouken@729
   241
       # We have it, but it failed.
slouken@729
   242
       exit 1
slouken@729
   243
    fi
slouken@729
   244
slouken@729
   245
    echo 1>&2 "\
slouken@729
   246
WARNING: \`$1' is missing on your system.  You should only need it if
slouken@729
   247
	 you modified a dependency of a manual page.  You may need the
slouken@729
   248
	 \`Help2man' package in order for those modifications to take
slouken@729
   249
	 effect.  You can get \`Help2man' from any GNU archive site."
slouken@729
   250
slouken@729
   251
    file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
slouken@729
   252
    if test -z "$file"; then
slouken@729
   253
	file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'`
slouken@729
   254
    fi
slouken@729
   255
    if [ -f "$file" ]; then
slouken@729
   256
	touch $file
slouken@729
   257
    else
slouken@729
   258
	test -z "$file" || exec >$file
slouken@729
   259
	echo ".ab help2man is required to generate this page"
slouken@729
   260
	exit 1
slouken@729
   261
    fi
slouken@729
   262
    ;;
slouken@729
   263
slouken@0
   264
  makeinfo)
slouken@729
   265
    if test -z "$run" && (makeinfo --version) > /dev/null 2>&1; then
slouken@729
   266
       # We have makeinfo, but it failed.
slouken@729
   267
       exit 1
slouken@729
   268
    fi
slouken@729
   269
slouken@0
   270
    echo 1>&2 "\
slouken@0
   271
WARNING: \`$1' is missing on your system.  You should only need it if
slouken@0
   272
         you modified a \`.texi' or \`.texinfo' file, or any other file
slouken@0
   273
         indirectly affecting the aspect of the manual.  The spurious
slouken@0
   274
         call might also be the consequence of using a buggy \`make' (AIX,
slouken@0
   275
         DU, IRIX).  You might want to install the \`Texinfo' package or
slouken@0
   276
         the \`GNU make' package.  Grab either from any GNU archive site."
slouken@0
   277
    file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
slouken@0
   278
    if test -z "$file"; then
slouken@0
   279
      file=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
slouken@0
   280
      file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $file`
slouken@0
   281
    fi
slouken@0
   282
    touch $file
slouken@0
   283
    ;;
slouken@0
   284
slouken@729
   285
  tar)
slouken@729
   286
    shift
slouken@729
   287
    if test -n "$run"; then
slouken@729
   288
      echo 1>&2 "ERROR: \`tar' requires --run"
slouken@729
   289
      exit 1
slouken@729
   290
    fi
slouken@729
   291
slouken@729
   292
    # We have already tried tar in the generic part.
slouken@729
   293
    # Look for gnutar/gtar before invocation to avoid ugly error
slouken@729
   294
    # messages.
slouken@729
   295
    if (gnutar --version > /dev/null 2>&1); then
slouken@729
   296
       gnutar "$@" && exit 0
slouken@729
   297
    fi
slouken@729
   298
    if (gtar --version > /dev/null 2>&1); then
slouken@729
   299
       gtar "$@" && exit 0
slouken@729
   300
    fi
slouken@729
   301
    firstarg="$1"
slouken@729
   302
    if shift; then
slouken@729
   303
	case "$firstarg" in
slouken@729
   304
	*o*)
slouken@729
   305
	    firstarg=`echo "$firstarg" | sed s/o//`
slouken@729
   306
	    tar "$firstarg" "$@" && exit 0
slouken@729
   307
	    ;;
slouken@729
   308
	esac
slouken@729
   309
	case "$firstarg" in
slouken@729
   310
	*h*)
slouken@729
   311
	    firstarg=`echo "$firstarg" | sed s/h//`
slouken@729
   312
	    tar "$firstarg" "$@" && exit 0
slouken@729
   313
	    ;;
slouken@729
   314
	esac
slouken@729
   315
    fi
slouken@729
   316
slouken@729
   317
    echo 1>&2 "\
slouken@729
   318
WARNING: I can't seem to be able to run \`tar' with the given arguments.
slouken@729
   319
         You may want to install GNU tar or Free paxutils, or check the
slouken@729
   320
         command line arguments."
slouken@729
   321
    exit 1
slouken@729
   322
    ;;
slouken@729
   323
slouken@0
   324
  *)
slouken@0
   325
    echo 1>&2 "\
slouken@0
   326
WARNING: \`$1' is needed, and you do not seem to have it handy on your
slouken@0
   327
         system.  You might have modified some files without having the
slouken@0
   328
         proper tools for further handling them.  Check the \`README' file,
slouken@0
   329
         it often tells you about the needed prerequirements for installing
slouken@0
   330
         this package.  You may also peek at any GNU archive site, in case
slouken@0
   331
         some other package would contain this missing \`$1' program."
slouken@0
   332
    exit 1
slouken@0
   333
    ;;
slouken@0
   334
esac
slouken@0
   335
slouken@0
   336
exit 0