Browse code

Separate C preprocessor flags into CPPFLAGS variable

Originally committed as revision 19404 to svn://svn.ffmpeg.org/ffmpeg/trunk

Måns Rullgård authored on 2009/07/12 22:29:32
Showing 2 changed files
... ...
@@ -18,16 +18,17 @@ endif
18 18
 
19 19
 ALLFFLIBS = avcodec avdevice avfilter avformat avutil postproc swscale
20 20
 
21
-CFLAGS := -DHAVE_AV_CONFIG_H -I$(BUILD_ROOT_REL) -I$(SRC_PATH) $(OPTFLAGS)
21
+CPPFLAGS += -DHAVE_AV_CONFIG_H -I$(BUILD_ROOT_REL) -I$(SRC_PATH)
22
+CFLAGS := $(OPTFLAGS)
22 23
 
23 24
 %.o: %.c
24
-	$(CC) $(CFLAGS) $(LIBOBJFLAGS) -c -o $@ $<
25
+	$(CC) $(CPPFLAGS) $(CFLAGS) $(LIBOBJFLAGS) -c -o $@ $<
25 26
 
26 27
 %.o: %.S
27
-	$(AS) $(CFLAGS) $(LIBOBJFLAGS) -c -o $@ $<
28
+	$(AS) $(CPPFLAGS) $(CFLAGS) $(LIBOBJFLAGS) -c -o $@ $<
28 29
 
29 30
 %.ho: %.h
30
-	$(CC) $(CFLAGS) $(LIBOBJFLAGS) -Wno-unused -c -o $@ -x c $<
31
+	$(CC) $(CPPFLAGS) $(CFLAGS) $(LIBOBJFLAGS) -Wno-unused -c -o $@ -x c $<
31 32
 
32 33
 %.d: %.c
33 34
 	$(DEPEND_CMD) > $@
... ...
@@ -511,6 +511,10 @@ append(){
511 511
     eval "$var=\"\$$var $*\""
512 512
 }
513 513
 
514
+add_cppflags(){
515
+    append CPPFLAGS "$@"
516
+}
517
+
514 518
 add_cflags(){
515 519
     append CFLAGS "$@"
516 520
 }
... ...
@@ -532,21 +536,21 @@ check_cc(){
532 532
     log check_cc "$@"
533 533
     cat > $TMPC
534 534
     log_file $TMPC
535
-    check_cmd $cc $CFLAGS "$@" -c -o $TMPO $TMPC
535
+    check_cmd $cc $CPPFLAGS $CFLAGS "$@" -c -o $TMPO $TMPC
536 536
 }
537 537
 
538 538
 check_cpp(){
539 539
     log check_cpp "$@"
540 540
     cat > $TMPC
541 541
     log_file $TMPC
542
-    check_cmd $cc $CFLAGS "$@" -E -o $TMPO $TMPC
542
+    check_cmd $cc $CPPFLAGS "$@" -E -o $TMPO $TMPC
543 543
 }
544 544
 
545 545
 check_as(){
546 546
     log check_as "$@"
547 547
     cat > $TMPC
548 548
     log_file $TMPC
549
-    check_cmd $as $CFLAGS "$@" -c -o $TMPO $TMPC
549
+    check_cmd $as $CPPFLAGS $CFLAGS "$@" -c -o $TMPO $TMPC
550 550
 }
551 551
 
552 552
 check_asm(){
... ...
@@ -578,6 +582,13 @@ check_ld(){
578 578
     check_cmd $cc $LDFLAGS $flags -o $TMPE $TMPO $extralibs $libs
579 579
 }
580 580
 
581
+check_cppflags(){
582
+    log check_cppflags "$@"
583
+    check_cc "$@" <<EOF && add_cppflags "$@"
584
+int x;
585
+EOF
586
+}
587
+
581 588
 check_cflags(){
582 589
     log check_cflags "$@"
583 590
     check_cc "$@" <<EOF && add_cflags "$@"
... ...
@@ -1235,7 +1246,7 @@ enable stripping
1235 1235
 enable swscale_alpha
1236 1236
 
1237 1237
 # build settings
1238
-add_cflags -D_ISOC99_SOURCE -D_POSIX_C_SOURCE=200112
1238
+add_cppflags -D_ISOC99_SOURCE -D_POSIX_C_SOURCE=200112
1239 1239
 SHFLAGS='-shared -Wl,-soname,$$(@F)'
1240 1240
 FFSERVERLDFLAGS=-Wl,-E
1241 1241
 LIBPREF="lib"
... ...
@@ -1256,7 +1267,7 @@ target_path='.'
1256 1256
 
1257 1257
 # gcc stupidly only outputs the basename of targets with -MM, but we need the
1258 1258
 # full relative path for objects in subdirectories for non-recursive Make.
1259
-DEPEND_CMD='$(CC) $(CFLAGS) -MM $< | sed -e "/^\#.*/d" -e "s,^[[:space:]]*$(*F)\\.o,$(@D)/$(*F).o,"'
1259
+DEPEND_CMD='$(CC) $(CPPFLAGS) -MM $< | sed -e "/^\#.*/d" -e "s,^[[:space:]]*$(*F)\\.o,$(@D)/$(*F).o,"'
1260 1260
 
1261 1261
 # find source path
1262 1262
 source_path="$(dirname "$0")"
... ...
@@ -1456,7 +1467,7 @@ elif $cc -v 2>&1 | grep -q xlc; then
1456 1456
     cc_type=xlc
1457 1457
 elif $cc -V 2>/dev/null | grep -q Compaq; then
1458 1458
     cc_type=ccc
1459
-    DEPEND_CMD='$(CC) $(CFLAGS) -M $< | sed -e "/^\#.*/d" -e "s,^[[:space:]]*$(*F)\\.o,$(@D)/$(*F).o,"'
1459
+    DEPEND_CMD='$(CC) $(CPPFLAGS) -M $< | sed -e "/^\#.*/d" -e "s,^[[:space:]]*$(*F)\\.o,$(@D)/$(*F).o,"'
1460 1460
     debuglevel=3
1461 1461
     add_ldflags -Wl,-z,now # calls to libots crash without this
1462 1462
 elif $cc --vsn 2>/dev/null | grep -q RVCT; then
... ...
@@ -1499,10 +1510,10 @@ if test "$?" != 0; then
1499 1499
 fi
1500 1500
 
1501 1501
 check_cflags -std=c99
1502
-check_cc -D_FILE_OFFSET_BITS=64 <<EOF && add_cflags -D_FILE_OFFSET_BITS=64
1502
+check_cc -D_FILE_OFFSET_BITS=64 <<EOF && add_cppflags -D_FILE_OFFSET_BITS=64
1503 1503
 #include <stdlib.h>
1504 1504
 EOF
1505
-check_cc -D_LARGEFILE_SOURCE <<EOF && add_cflags -D_LARGEFILE_SOURCE
1505
+check_cc -D_LARGEFILE_SOURCE <<EOF && add_cppflags -D_LARGEFILE_SOURCE
1506 1506
 #include <stdlib.h>
1507 1507
 EOF
1508 1508
 
... ...
@@ -1593,7 +1604,8 @@ case $target_os in
1593 1593
     beos|haiku|zeta)
1594 1594
         prefix_default="$HOME/config"
1595 1595
         # helps building libavcodec
1596
-        add_cflags -DPIC -fomit-frame-pointer
1596
+        add_cppflags -DPIC
1597
+        add_cflags -fomit-frame-pointer
1597 1598
         # 3 gcc releases known for BeOS, each with ugly bugs
1598 1599
         gcc_version="$($cc -v 2>&1 | grep version | cut -d ' ' -f3-)"
1599 1600
         case "$gcc_version" in
... ...
@@ -1620,7 +1632,7 @@ case $target_os in
1620 1620
         FFSERVERLDFLAGS=""
1621 1621
         SHFLAGS='-shared -Wl,-h,$$(@F)'
1622 1622
         network_extralibs="-lsocket -lnsl"
1623
-        add_cflags -D__EXTENSIONS__
1623
+        add_cppflags -D__EXTENSIONS__
1624 1624
         ;;
1625 1625
     netbsd)
1626 1626
         oss_indev_extralibs="-lossaudio"
... ...
@@ -2472,6 +2484,7 @@ enabled stripping &&
2472 2472
     echo "STRIP=$strip" >> config.mak ||
2473 2473
     echo "STRIP=echo ignoring strip" >> config.mak
2474 2474
 
2475
+echo "CPPFLAGS?=$CPPFLAGS" >> config.mak
2475 2476
 echo "OPTFLAGS=$CFLAGS" >> config.mak
2476 2477
 echo "LDFLAGS=$LDFLAGS" >> config.mak
2477 2478
 echo "FFSERVERLDFLAGS=$FFSERVERLDFLAGS" >> config.mak