2022-08-27  Juan Manuel Guerrero <juan.guerrero@gmx.de>


	* configure: Various DJGPP specific adjustments.

	* Makefile: Added SHELL variable.






diff -aprNU1 ffmpeg-5.1.2.orig/configure ffmpeg-5.1.2/configure
--- ffmpeg-5.1.2.orig/configure	2022-08-31 18:58:24 +0000
+++ ffmpeg-5.1.2/configure	2022-11-25 19:17:00 +0000
@@ -3871,2 +3871,12 @@ striptype="direct"
 target_os_default=$(tolower $(uname -s))
+case $target_os_default in
+    *-dos|freedos|opendos)
+        # DJGPP specific.
+        # The added stuff does only work with a DJGPP installation.
+        if [ "x${DJDIR}" != "x" ]; then
+            target_os_default=djgpp-dos
+            target_os=djgpp-dos
+        fi
+        ;;
+esac
 host_os=$target_os_default
@@ -3878,2 +3888,5 @@ if test "$target_os_default" = aix; then
     nm_default="nm -g -X32_64"
+elif test "$target_os_default" = djgpp-dos; then
+    arch_default="i386"
+    cxx_default="gpp"
 else
@@ -3979,2 +3992,21 @@ else
         die "Out of tree builds are impossible with config.h in source dir."
+
+#    if test "$target_os_default" = djgpp-dos; then
+#        # DJGPP specific.
+#        # The configure script writes absolute paths into Makefiles
+#        # making them useless for DJGPP installations for which the
+#        # package has not been configured for.
+#        abs_builddir=$(pwd)
+#        djgpp_abs_top_builddir_drive=$(echo ${abs_builddir} | sed -e 's%:[/\\]*.*$%%;s%^/dev/\([A-z]\)/.*$%\1%')
+#        djgpp_abs_top_srcdir_drive=$(echo ${source_path} | sed -e 's%:[/\\]*.*$%%;s%^/dev/\([A-z]\)/.*$%\1%')
+#
+#        if [ "x${djgpp_abs_top_builddir_drive}" == "x${djgpp_abs_top_srcdir_drive}" ]; then
+#            # builddir and srcdir are on the same partition.
+#
+#            # Convert absolute srcdir paths to relative ones.
+#            djgpp_relative_prefix=$(echo ${source_path} | sed -e 's%^[A-z]:%%;s%^/dev/[A-z]%%;s%^%.%;s%[/\\][A-z0-9._+-]\+%/..%g;s%[/\\]$%%')
+#            djgpp_source_path=$(echo ${source_path} | sed -e "s%^[A-z]:%%;s%^/dev/[A-z]%%;s%^%${djgpp_relative_prefix}%")
+#            source_path=${djgpp_source_path}
+#        fi
+#    fi
 fi
@@ -4512,4 +4544,10 @@ tmpfile(){
     tmp="${FFTMPDIR}/test"$2
-    (set -C; exec > $tmp) 2> /dev/null ||
-        die "Unable to create temporary file in $FFTMPDIR."
+    if test "$target_os_default" = djgpp-dos; then
+        # The original code below does only work
+        # on Win98SE and later but not on plain DOS.
+        touch $tmp
+    else
+        (set -C; exec > $tmp) 2> /dev/null ||
+            die "Unable to create temporary file in $FFTMPDIR."
+    fi
     eval $1=$tmp
@@ -4534,3 +4572,5 @@ unset -f mktemp
 
-chmod +x $TMPE
+if [ "x${DJDIR}" = "x" ]; then
+    chmod +x $TMPE
+fi
 
@@ -5333,2 +5373,5 @@ elif enabled sparc; then
 elif enabled x86; then
+    if test "$target_os_default" = djgpp-dos && test "$cpu" = generic; then
+       cpu="i386"
+    fi
 
@@ -5651,2 +5694,23 @@ case $target_os in
         enable dos_paths
+        # Do never treat MS-DOS/DJGPP as 64 bit architecture!
+        if test "$target_os_default" = djgpp-dos; then
+            subarch=x86_32 && enable x86_32 && disable x86_64
+            cpuflags="-mtune=i586"
+            add_cflags $cpuflags
+            cpuflags="-march=i386 -mtune=i586"
+            CPPFLAGS=$(echo ${CPPFLAGS} | sed "s/ -D_LARGEFILE_SOURCE//;/ -D_FILE_OFFSET_BITS=/s/=64/=32/")
+            if [ -d "${WATT_ROOT}" ]; then
+                # If the checks shall work then wat3211b
+                # or later must have been installed.
+
+                # Ensure that always WATT-32 include path is added.
+                # The WATT_ROOT environment variable must be set.
+                CPPFLAGS="$CPPFLAGS -I/dev/env/WATT_ROOT/inc"
+
+                # Ensure that always WATT-32 library path is added.
+                # The WATT_ROOT environment variable must be set.
+                LIBS="$LIBS -L/dev/env/WATT_ROOT/lib -lwatt"
+                network_extralibs="-L/dev/env/WATT_ROOT/lib -lwatt"
+            fi
+        fi
         ;;
@@ -5721,3 +5785,3 @@ $ln_s "$link_dest" "$link_name"
 touch "$link_dest/test_file"
-if [ "$source_path" != "." ] && [ "$source_path" != "src" ] && ([ ! -d src ] || [ -L src ]) && [ -e "$link_name/test_file" ]; then
+if [ "$target_os_default" != "djgpp-dos" ] && [ "$source_path" != "." ] && [ "$source_path" != "src" ] && ([ ! -d src ] || [ -L src ]) && [ -e "$link_name/test_file" ]; then
     # create link to source path
@@ -6101,3 +6165,9 @@ elif enabled x86; then
     # base pointer is cleared in the inline assembly code.
-    check_exec_crash <<EOF && enable ebp_available
+    # This check does not work for MS-DOS/DJGPP.  The crash
+    # cannot be catched.
+    if test "$target_os_default" = djgpp-dos; then
+        enable rdtsc
+        disable ebp_available
+    else
+        check_exec_crash <<EOF && enable ebp_available
 volatile int i=0;
@@ -6106,2 +6176,3 @@ return i;
 EOF
+    fi
 
@@ -6796,2 +6867,6 @@ enabled makeinfo \
     && enable makeinfo_html || disable makeinfo_html
+#if test "$target_os_default" = djgpp-dos; then
+#    # The DJGPP port of makeinfo supports html builds.
+#    enable makeinfo_html
+#fi
 disabled makeinfo_html && texi2html --help 2> /dev/null | grep -q 'init-file' && enable texi2html || disable texi2html
@@ -7009,3 +7084,5 @@ check_cflags -Wdisabled-optimization
 check_cflags -Wpointer-arith
+if [ "x${DJDIR}" = "x" ]; then
 check_cflags -Wredundant-decls
+fi
 check_cflags -Wwrite-strings
@@ -7313,3 +7390,3 @@ haiku)
 *-dos|freedos|opendos)
-    if test_cpp_condition sys/version.h "defined(__DJGPP__) && __DJGPP__ == 2 && __DJGPP_MINOR__ == 5"; then
+    if test_cpp_condition sys/version.h "defined(__DJGPP__) && __DJGPP__ == 2 && __DJGPP_MINOR__ >= 5"; then
         disable memalign
diff -aprNU1 ffmpeg-5.1.2.orig/Makefile ffmpeg-5.1.2/Makefile
--- ffmpeg-5.1.2.orig/Makefile	2022-07-22 17:58:38 +0000
+++ ffmpeg-5.1.2/Makefile	2022-11-25 18:23:42 +0000
@@ -1 +1,3 @@
+SHELL = /bin/sh
+
 MAIN_MAKEFILE=1
