Browse code

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.

Diego Biurrun authored on 2011/05/12 00:52:51
Showing 16 changed files
... ...
@@ -1664,7 +1664,7 @@ LIB_INSTALL_EXTRA_CMD='$$(RANLIB) "$(LIBDIR)/$(LIBNAME)"'
1664 1664
 
1665 1665
 CC_O='-o $@'
1666 1666
 
1667
-host_cflags='-D_ISOC99_SOURCE -D_POSIX_C_SOURCE=200112 -O3 -g -Wall'
1667
+host_cflags='-D_ISOC99_SOURCE -O3 -g -Wall'
1668 1668
 host_libs='-lm'
1669 1669
 
1670 1670
 target_path='$(CURDIR)'
... ...
@@ -2316,7 +2316,7 @@ if test "$?" != 0; then
2316 2316
     die "C compiler test failed."
2317 2317
 fi
2318 2318
 
2319
-add_cppflags -D_ISOC99_SOURCE -D_POSIX_C_SOURCE=200112
2319
+add_cppflags -D_ISOC99_SOURCE
2320 2320
 check_cflags -std=c99
2321 2321
 check_cc -D_FILE_OFFSET_BITS=64 <<EOF && add_cppflags -D_FILE_OFFSET_BITS=64
2322 2322
 #include <stdlib.h>
... ...
@@ -2364,7 +2364,6 @@ case $target_os in
2364 2364
         disable symver
2365 2365
         oss_indev_extralibs="-lossaudio"
2366 2366
         oss_outdev_extralibs="-lossaudio"
2367
-        add_cppflags -D_XOPEN_SOURCE=600
2368 2367
         ;;
2369 2368
     openbsd)
2370 2369
         enable malloc_aligned
... ...
@@ -2457,6 +2456,7 @@ case $target_os in
2457 2457
         enable dos_paths
2458 2458
         ;;
2459 2459
     linux)
2460
+        add_cppflags -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600
2460 2461
         enable dv1394
2461 2462
         ;;
2462 2463
     irix*)
... ...
@@ -785,14 +785,6 @@ to configure.
785 785
 BSD make will not build Libav, you need to install and use GNU Make
786 786
 (@file{gmake}).
787 787
 
788
-@subsubsection FreeBSD, DragonFly BSD
789
-
790
-These systems will not compile out-of-the-box due to broken system headers.
791
-Passing @code{--extra-cflags=-D__BSD_VISIBLE} to configure will work
792
-around the problem. This may have unexpected sideeffects, so use it at
793
-your own risk. If you care about FreeBSD, please make an attempt at
794
-getting the system headers fixed.
795
-
796 788
 @subsection (Open)Solaris
797 789
 
798 790
 GNU Make is required to build Libav, so you have to invoke (@file{gmake}),
... ...
@@ -19,9 +19,6 @@
19 19
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 20
  */
21 21
 
22
-/* needed for usleep() */
23
-#define _XOPEN_SOURCE 600
24
-
25 22
 #include "config.h"
26 23
 #include <ctype.h>
27 24
 #include <string.h>
... ...
@@ -19,8 +19,6 @@
19 19
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 20
  */
21 21
 
22
-#define _XOPEN_SOURCE 600
23
-
24 22
 #include "config.h"
25 23
 #include <inttypes.h>
26 24
 #include <math.h>
... ...
@@ -19,8 +19,6 @@
19 19
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 20
  */
21 21
 
22
-#define _XOPEN_SOURCE 600
23
-
24 22
 #include "config.h"
25 23
 #if !HAVE_CLOSESOCKET
26 24
 #define closesocket close
... ...
@@ -25,9 +25,6 @@
25 25
  * @author Adam Thayer (krevnik@comcast.net)
26 26
  */
27 27
 
28
-/* needed for mkstemp() */
29
-#define _XOPEN_SOURCE 600
30
-
31 28
 #include <xvid.h>
32 29
 #include <unistd.h>
33 30
 #include "avcodec.h"
... ...
@@ -24,10 +24,6 @@
24 24
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
25 25
  */
26 26
 
27
-#define _BSD_SOURCE 1
28
-#define _NETBSD_SOURCE
29
-#define _XOPEN_SOURCE 600
30
-
31 27
 #include "libavformat/avformat.h"
32 28
 #if HAVE_DEV_BKTR_IOCTL_METEOR_H && HAVE_DEV_BKTR_IOCTL_BT848_H
33 29
 # include <dev/bktr/ioctl_meteor.h>
... ...
@@ -35,8 +35,6 @@
35 35
  * and Edouard Gomez <ed.gomez@free.fr>.
36 36
  */
37 37
 
38
-#define _XOPEN_SOURCE 600
39
-
40 38
 #include "config.h"
41 39
 #include "libavformat/avformat.h"
42 40
 #include <time.h>
... ...
@@ -25,7 +25,6 @@
25 25
  * http://tools.ietf.org/html/draft-pantos-http-live-streaming
26 26
  */
27 27
 
28
-#define _XOPEN_SOURCE 600
29 28
 #include "libavutil/avstring.h"
30 29
 #include "libavutil/intreadwrite.h"
31 30
 #include "libavutil/opt.h"
... ...
@@ -25,7 +25,6 @@
25 25
  * http://tools.ietf.org/html/draft-pantos-http-live-streaming
26 26
  */
27 27
 
28
-#define _XOPEN_SOURCE 600
29 28
 #include "libavutil/avstring.h"
30 29
 #include "avformat.h"
31 30
 #include "internal.h"
... ...
@@ -19,9 +19,8 @@
19 19
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 20
  */
21 21
 
22
-/* needed for usleep() */
23
-#define _XOPEN_SOURCE 600
24 22
 #include <unistd.h>
23
+
25 24
 #include "libavutil/avstring.h"
26 25
 #include "libavutil/opt.h"
27 26
 #include "os_support.h"
... ...
@@ -22,7 +22,6 @@
22 22
 
23 23
 /* needed by inet_aton() */
24 24
 #define _SVID_SOURCE
25
-#define _DARWIN_C_SOURCE
26 25
 
27 26
 #include "config.h"
28 27
 #include "avformat.h"
... ...
@@ -19,9 +19,6 @@
19 19
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 20
  */
21 21
 
22
-/* needed for gethostname() */
23
-#define _XOPEN_SOURCE 600
24
-
25 22
 #include "libavcodec/get_bits.h"
26 23
 #include "avformat.h"
27 24
 #include "mpegts.h"
... ...
@@ -25,7 +25,7 @@
25 25
  */
26 26
 
27 27
 #define _BSD_SOURCE     /* Needed for using struct ip_mreq with recent glibc */
28
-#define _DARWIN_C_SOURCE /* Needed for using IP_MULTICAST_TTL on OS X */
28
+
29 29
 #include "avformat.h"
30 30
 #include "avio_internal.h"
31 31
 #include "libavutil/parseutils.h"
... ...
@@ -17,10 +17,8 @@
17 17
  */
18 18
 
19 19
 #ifdef __APPLE__
20
-#undef _POSIX_C_SOURCE
21 20
 #include <sys/sysctl.h>
22 21
 #elif defined(__OpenBSD__)
23
-#undef _POSIX_C_SOURCE
24 22
 #include <sys/param.h>
25 23
 #include <sys/sysctl.h>
26 24
 #include <machine/cpu.h>
... ...
@@ -18,8 +18,6 @@
18 18
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 19
  */
20 20
 
21
-#define _SVID_SOURCE //needed for MAP_ANONYMOUS
22
-#define _DARWIN_C_SOURCE // needed for MAP_ANON
23 21
 #include <inttypes.h>
24 22
 #include <string.h>
25 23
 #include <math.h>