diff --git a/Makefile b/Makefile
index 41ef2af86497a325f94fb00c428df50b2cbe4a60..8d2d7113ca0f9ed6eb2141d666c93b20e05a6ceb 100644
--- a/Makefile
+++ b/Makefile
@@ -7,7 +7,11 @@ include config.mak
 VPATH=$(SRC_PATH)
 
 CFLAGS= $(OPTFLAGS) -Wall -g -I. -I$(SRC_PATH) -I$(SRC_PATH)/libavcodec -I$(SRC_PATH)/libav -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_GNU_SOURCE
+ifeq ($(CONFIG_DARWIN),yes)
+LDFLAGS+= -g -d
+else
 LDFLAGS+= -g -Wl,--warn-common
+endif
 
 ifeq ($(TARGET_GPROF),yes)
 CFLAGS+=-p
diff --git a/configure b/configure
index 480eedcd6f6d96dd5eabb2f0b38c2721bf331400..09cda4212f3234b8434b155664375f808123f0b3 100755
--- a/configure
+++ b/configure
@@ -35,6 +35,9 @@ case "$cpu" in
   alpha)
     cpu="alpha"
   ;;
+  "Power Macintosh")
+    cpu="powerpc"
+  ;;
   *)
     cpu="unknown"
   ;;
@@ -81,6 +84,14 @@ audio_oss="yes"
 extralibs="-lpoll -lgnugetopt -lm"
 make="gmake"
 ;;
+Darwin)
+v4l="no"
+audio_oss="no"
+CFLAGS="-no-cpp-precomp -pipe -O3 -fomit-frame-pointer"
+SHFLAGS=-dynamic
+extralibs=""
+darwin=yes
+;;
 *) ;;
 esac
 
@@ -442,6 +453,11 @@ if test "$win32" = "yes" ; then
   echo "CONFIG_WIN32=yes" >> config.mak
 fi
 
+if test "$darwin" = "yes"; then
+  echo "#define CONFIG_DARWIN 1"  >> $TMPH
+  echo "CONFIG_DARWIN=yes" >> config.mak
+fi
+
 if test "$_malloc_h" = "yes" ; then
   echo "#define HAVE_MALLOC_H 1" >> $TMPH
 else
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 05072caecb0f66c0becb4e176f738e7295106d9f..dc56f58425b33472d3149d52a935588a908fbd5b 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -82,7 +82,7 @@ tests: apiexample cpuid_test $(TESTS)
 
 $(LIB): $(OBJS)
 	rm -f $@
-	$(AR) rc $@ $(OBJS)
+	$(AR) rcs $@ $(OBJS)
 
 $(SLIB): $(OBJS)
 	$(CC) $(SHFLAGS) -o $@ $(OBJS) $(EXTRALIBS)
@@ -127,7 +127,7 @@ imgresample-test: imgresample.c
 
 dct-test: dct-test.o jfdctfst.o i386/fdct_mmx.o \
           fdctref.o jrevdct.o i386/idct_mmx.o
-	$(CC) -o $@ $^
+	$(CC) -o $@ $^ -lm
 
 motion-test: motion_test.o $(LIB)
 	$(CC) -o $@ $^
diff --git a/tests/regression.sh b/tests/regression.sh
index 03427f0009feeeda5da1666607608091ebd24d25..b122629c16b6550904d6df745602e494d9057f5f 100755
--- a/tests/regression.sh
+++ b/tests/regression.sh
@@ -50,7 +50,7 @@ function do_ffmpeg ()
     echo $ffmpeg -bitexact $*
     $ffmpeg -bitexact -benchmark $* > $datadir/bench.tmp
     md5sum $f >> $logfile
-    expr match "`cat $datadir/bench.tmp`" '.*utime=\(.*s\)' > $datadir/bench2.tmp
+    expr "`cat $datadir/bench.tmp`" : '.*utime=\(.*s\)' > $datadir/bench2.tmp
     echo `cat $datadir/bench2.tmp` $f >> $benchfile
 }