[FFmpeg-cvslog] configure: Do not unconditionally add -D_POSIX_C_SOURCE to CPPFLAGS.

Diego Biurrun git at videolan.org
Fri May 13 04:45:58 CEST 2011


ffmpeg | branch: master | Diego Biurrun <diego at biurrun.de> | Wed May 11 17:52:51 2011 +0200| [046f081b46c8479820409cf8f530b988221bd15b] | committer: Diego Biurrun

configure: Do not unconditionally add -D_POSIX_C_SOURCE to CPPFLAGS.

Adding _POSIX_C_SOURCE to CPPFLAGS globally produces all sorts of problems
since it causes certain system functions to be hidden on some (BSD) systems.
The solution is to only add the flag on systems that really require it, i.e.
glibc-based ones.

This change makes BSD systems compile out-of-the-box without the need for
adding specific flags manually.  It also allows dropping a number of flags
set manually on a file-per-file basis, but were only present to work around
breakage introduced by the presence of _POSIX_C_SOURCE.

Also add _XOPEN_SOURCE to CPPFLAGS for glibc systems.  We use XSI extensions
in several places already, so it is preferable to define it globally instead
of littering source files with individual #defines only needed for glibc.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=046f081b46c8479820409cf8f530b988221bd15b
---

 configure                    |    6 +++---
 doc/general.texi             |    8 --------
 ffmpeg.c                     |    3 ---
 ffplay.c                     |    2 --
 ffserver.c                   |    2 --
 libavcodec/libxvidff.c       |    3 ---
 libavdevice/bktr.c           |    4 ----
 libavdevice/x11grab.c        |    2 --
 libavformat/applehttp.c      |    1 -
 libavformat/applehttpproto.c |    1 -
 libavformat/avio.c           |    3 +--
 libavformat/os_support.c     |    1 -
 libavformat/rtpdec.c         |    3 ---
 libavformat/udp.c            |    2 +-
 libavutil/ppc/cpu.c          |    2 --
 libswscale/utils.c           |    2 --
 16 files changed, 5 insertions(+), 40 deletions(-)

diff --git a/configure b/configure
index 955a568..40f30dd 100755
--- a/configure
+++ b/configure
@@ -1664,7 +1664,7 @@ LIB_INSTALL_EXTRA_CMD='$$(RANLIB) "$(LIBDIR)/$(LIBNAME)"'
 
 CC_O='-o $@'
 
-host_cflags='-D_ISOC99_SOURCE -D_POSIX_C_SOURCE=200112 -O3 -g -Wall'
+host_cflags='-D_ISOC99_SOURCE -O3 -g -Wall'
 host_libs='-lm'
 
 target_path='$(CURDIR)'
@@ -2316,7 +2316,7 @@ if test "$?" != 0; then
     die "C compiler test failed."
 fi
 
-add_cppflags -D_ISOC99_SOURCE -D_POSIX_C_SOURCE=200112
+add_cppflags -D_ISOC99_SOURCE
 check_cflags -std=c99
 check_cc -D_FILE_OFFSET_BITS=64 <<EOF && add_cppflags -D_FILE_OFFSET_BITS=64
 #include <stdlib.h>
@@ -2364,7 +2364,6 @@ case $target_os in
         disable symver
         oss_indev_extralibs="-lossaudio"
         oss_outdev_extralibs="-lossaudio"
-        add_cppflags -D_XOPEN_SOURCE=600
         ;;
     openbsd)
         enable malloc_aligned
@@ -2457,6 +2456,7 @@ case $target_os in
         enable dos_paths
         ;;
     linux)
+        add_cppflags -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600
         enable dv1394
         ;;
     irix*)
diff --git a/doc/general.texi b/doc/general.texi
index 5348227..ce531cc 100644
--- a/doc/general.texi
+++ b/doc/general.texi
@@ -785,14 +785,6 @@ to configure.
 BSD make will not build Libav, you need to install and use GNU Make
 (@file{gmake}).
 
- at subsubsection FreeBSD, DragonFly BSD
-
-These systems will not compile out-of-the-box due to broken system headers.
-Passing @code{--extra-cflags=-D__BSD_VISIBLE} to configure will work
-around the problem. This may have unexpected sideeffects, so use it at
-your own risk. If you care about FreeBSD, please make an attempt at
-getting the system headers fixed.
-
 @subsection (Open)Solaris
 
 GNU Make is required to build Libav, so you have to invoke (@file{gmake}),
diff --git a/ffmpeg.c b/ffmpeg.c
index 5ab3c7a..b5ff4cf 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -19,9 +19,6 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-/* needed for usleep() */
-#define _XOPEN_SOURCE 600
-
 #include "config.h"
 #include <ctype.h>
 #include <string.h>
diff --git a/ffplay.c b/ffplay.c
index 07727b6..e820c60 100644
--- a/ffplay.c
+++ b/ffplay.c
@@ -19,8 +19,6 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#define _XOPEN_SOURCE 600
-
 #include "config.h"
 #include <inttypes.h>
 #include <math.h>
diff --git a/ffserver.c b/ffserver.c
index fe030b9..b4613af 100644
--- a/ffserver.c
+++ b/ffserver.c
@@ -19,8 +19,6 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#define _XOPEN_SOURCE 600
-
 #include "config.h"
 #if !HAVE_CLOSESOCKET
 #define closesocket close
diff --git a/libavcodec/libxvidff.c b/libavcodec/libxvidff.c
index 96ce848..1e887a2 100644
--- a/libavcodec/libxvidff.c
+++ b/libavcodec/libxvidff.c
@@ -25,9 +25,6 @@
  * @author Adam Thayer (krevnik at comcast.net)
  */
 
-/* needed for mkstemp() */
-#define _XOPEN_SOURCE 600
-
 #include <xvid.h>
 #include <unistd.h>
 #include "avcodec.h"
diff --git a/libavdevice/bktr.c b/libavdevice/bktr.c
index ab70a1b..dad5c83 100644
--- a/libavdevice/bktr.c
+++ b/libavdevice/bktr.c
@@ -24,10 +24,6 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#define _BSD_SOURCE 1
-#define _NETBSD_SOURCE
-#define _XOPEN_SOURCE 600
-
 #include "libavformat/avformat.h"
 #if HAVE_DEV_BKTR_IOCTL_METEOR_H && HAVE_DEV_BKTR_IOCTL_BT848_H
 # include <dev/bktr/ioctl_meteor.h>
diff --git a/libavdevice/x11grab.c b/libavdevice/x11grab.c
index aaad729..0e63d09 100644
--- a/libavdevice/x11grab.c
+++ b/libavdevice/x11grab.c
@@ -35,8 +35,6 @@
  * and Edouard Gomez <ed.gomez at free.fr>.
  */
 
-#define _XOPEN_SOURCE 600
-
 #include "config.h"
 #include "libavformat/avformat.h"
 #include <time.h>
diff --git a/libavformat/applehttp.c b/libavformat/applehttp.c
index 822d80b..e3b1500 100644
--- a/libavformat/applehttp.c
+++ b/libavformat/applehttp.c
@@ -25,7 +25,6 @@
  * http://tools.ietf.org/html/draft-pantos-http-live-streaming
  */
 
-#define _XOPEN_SOURCE 600
 #include "libavutil/avstring.h"
 #include "libavutil/intreadwrite.h"
 #include "libavutil/opt.h"
diff --git a/libavformat/applehttpproto.c b/libavformat/applehttpproto.c
index 37b289a..85f3cfc 100644
--- a/libavformat/applehttpproto.c
+++ b/libavformat/applehttpproto.c
@@ -25,7 +25,6 @@
  * http://tools.ietf.org/html/draft-pantos-http-live-streaming
  */
 
-#define _XOPEN_SOURCE 600
 #include "libavutil/avstring.h"
 #include "avformat.h"
 #include "internal.h"
diff --git a/libavformat/avio.c b/libavformat/avio.c
index 0702aff..8881f26 100644
--- a/libavformat/avio.c
+++ b/libavformat/avio.c
@@ -19,9 +19,8 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-/* needed for usleep() */
-#define _XOPEN_SOURCE 600
 #include <unistd.h>
+
 #include "libavutil/avstring.h"
 #include "libavutil/opt.h"
 #include "os_support.h"
diff --git a/libavformat/os_support.c b/libavformat/os_support.c
index 05577b7..a0fcd6c 100644
--- a/libavformat/os_support.c
+++ b/libavformat/os_support.c
@@ -22,7 +22,6 @@
 
 /* needed by inet_aton() */
 #define _SVID_SOURCE
-#define _DARWIN_C_SOURCE
 
 #include "config.h"
 #include "avformat.h"
diff --git a/libavformat/rtpdec.c b/libavformat/rtpdec.c
index 43305a3..4623088 100644
--- a/libavformat/rtpdec.c
+++ b/libavformat/rtpdec.c
@@ -19,9 +19,6 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-/* needed for gethostname() */
-#define _XOPEN_SOURCE 600
-
 #include "libavcodec/get_bits.h"
 #include "avformat.h"
 #include "mpegts.h"
diff --git a/libavformat/udp.c b/libavformat/udp.c
index 62c1c7c..d6522bf 100644
--- a/libavformat/udp.c
+++ b/libavformat/udp.c
@@ -25,7 +25,7 @@
  */
 
 #define _BSD_SOURCE     /* Needed for using struct ip_mreq with recent glibc */
-#define _DARWIN_C_SOURCE /* Needed for using IP_MULTICAST_TTL on OS X */
+
 #include "avformat.h"
 #include "avio_internal.h"
 #include "libavutil/parseutils.h"
diff --git a/libavutil/ppc/cpu.c b/libavutil/ppc/cpu.c
index 6b122ed..0025711 100644
--- a/libavutil/ppc/cpu.c
+++ b/libavutil/ppc/cpu.c
@@ -17,10 +17,8 @@
  */
 
 #ifdef __APPLE__
-#undef _POSIX_C_SOURCE
 #include <sys/sysctl.h>
 #elif defined(__OpenBSD__)
-#undef _POSIX_C_SOURCE
 #include <sys/param.h>
 #include <sys/sysctl.h>
 #include <machine/cpu.h>
diff --git a/libswscale/utils.c b/libswscale/utils.c
index 818d014..e9319fa 100644
--- a/libswscale/utils.c
+++ b/libswscale/utils.c
@@ -18,8 +18,6 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#define _SVID_SOURCE //needed for MAP_ANONYMOUS
-#define _DARWIN_C_SOURCE // needed for MAP_ANON
 #include <inttypes.h>
 #include <string.h>
 #include <math.h>



More information about the ffmpeg-cvslog mailing list