Commit a11081085b9db8ee40236d47849276db71ba0801
1 parent
32b62035
Handle warning flags better
Make --enable-werror work properly on msvc, handle extra warnings flags for msvc in configure.ac instead of hardcoding into make/msvc.mk, separate warnings flags into WFLAGS in autoconf.mk to avoid duplication and to make it easier to override.
Showing
7 changed files
with
55 additions
and
46 deletions
ChangeLog
| @@ -25,6 +25,15 @@ | @@ -25,6 +25,15 @@ | ||
| 25 | 25 | ||
| 26 | 2013-01-24 Jay Berkenbilt <ejb@ql.org> | 26 | 2013-01-24 Jay Berkenbilt <ejb@ql.org> |
| 27 | 27 | ||
| 28 | + * Make --enable-werror work for MSVC, and generally handle warning | ||
| 29 | + options better for that compiler. Warning flags for that compiler | ||
| 30 | + were previous hard-coded into the build with /WX enabled | ||
| 31 | + unconditionally. | ||
| 32 | + | ||
| 33 | + * Split warning flags into WFLAGS in autoconf.mk to make them | ||
| 34 | + easier to override. Before they were repeated in CFLAGS and | ||
| 35 | + CXXFLAGS and were commingled with other compiler flags. | ||
| 36 | + | ||
| 28 | * qpdf --check now does syntactic checks all pages' content | 37 | * qpdf --check now does syntactic checks all pages' content |
| 29 | streams as well as checking overall document structure. Semantic | 38 | streams as well as checking overall document structure. Semantic |
| 30 | errors are still not checked, and there are no plans to add | 39 | errors are still not checked, and there are no plans to add |
autoconf.mk.in
| @@ -12,12 +12,13 @@ docdir=@docdir@ | @@ -12,12 +12,13 @@ docdir=@docdir@ | ||
| 12 | htmldir=@htmldir@ | 12 | htmldir=@htmldir@ |
| 13 | pdfdir=@pdfdir | 13 | pdfdir=@pdfdir |
| 14 | CC=@CC@ | 14 | CC=@CC@ |
| 15 | -CFLAGS=@CFLAGS@ | 15 | +WFLAGS=@WFLAGS@ |
| 16 | +CFLAGS=@CFLAGS@ $(WFLAGS) | ||
| 16 | LDFLAGS=@LDFLAGS@ | 17 | LDFLAGS=@LDFLAGS@ |
| 17 | LIBS=@LIBS@ | 18 | LIBS=@LIBS@ |
| 18 | CPPFLAGS=@CPPFLAGS@ | 19 | CPPFLAGS=@CPPFLAGS@ |
| 19 | CXX=@CXX@ | 20 | CXX=@CXX@ |
| 20 | -CXXFLAGS=@CXXFLAGS@ | 21 | +CXXFLAGS=@CXXFLAGS@ $(WFLAGS) |
| 21 | AR=@AR@ | 22 | AR=@AR@ |
| 22 | RANLIB=@RANLIB@ | 23 | RANLIB=@RANLIB@ |
| 23 | DLLTOOL=@DLLTOOL@ | 24 | DLLTOOL=@DLLTOOL@ |
config-mingw32
| 1 | #!/bin/sh | 1 | #!/bin/sh |
| 2 | -./configure --disable-test-compare-images --enable-external-libs --with-windows-wordsize=32 --with-buildrules=mingw | 2 | +./configure --disable-test-compare-images --enable-external-libs --enable-werror --with-windows-wordsize=32 --with-buildrules=mingw |
| 3 | # As of autoconf 2.69 and gcc 4.6, autoconf's configure fails to | 3 | # As of autoconf 2.69 and gcc 4.6, autoconf's configure fails to |
| 4 | # recognize that defining _FILE_OFFSET_BITS works with mingw32. | 4 | # recognize that defining _FILE_OFFSET_BITS works with mingw32. |
| 5 | # Append to qpdf-config.h rather than passing CPPFLAGS on the | 5 | # Append to qpdf-config.h rather than passing CPPFLAGS on the |
config-mingw64
| 1 | #!/bin/sh | 1 | #!/bin/sh |
| 2 | -./configure --disable-test-compare-images --enable-external-libs --with-windows-wordsize=64 --with-buildrules=mingw \ | 2 | +./configure --disable-test-compare-images --enable-external-libs --enable-werror --with-windows-wordsize=64 --with-buildrules=mingw \ |
| 3 | CC=x86_64-w64-mingw32-gcc \ | 3 | CC=x86_64-w64-mingw32-gcc \ |
| 4 | CXX=x86_64-w64-mingw32-g++ \ | 4 | CXX=x86_64-w64-mingw32-g++ \ |
| 5 | LD=x86_64-w64-mingw32-ld \ | 5 | LD=x86_64-w64-mingw32-ld \ |
config-msvc
| @@ -8,4 +8,4 @@ objdump= | @@ -8,4 +8,4 @@ objdump= | ||
| 8 | if test "$wordsize" = "64"; then | 8 | if test "$wordsize" = "64"; then |
| 9 | objdump=OBJDUMP=x86_64-w64-mingw32-objdump | 9 | objdump=OBJDUMP=x86_64-w64-mingw32-objdump |
| 10 | fi | 10 | fi |
| 11 | -CC=cl CXX="cl -TP -GR" ./configure --disable-test-compare-images --enable-external-libs --with-windows-wordsize=$wordsize --with-buildrules=msvc $objdump | 11 | +CC=cl CXX="cl -TP -GR" ./configure --disable-test-compare-images --enable-external-libs --enable-werror --with-windows-wordsize=$wordsize --with-buildrules=msvc $objdump |
configure.ac
| @@ -175,39 +175,48 @@ AC_ARG_WITH(buildrules, | @@ -175,39 +175,48 @@ AC_ARG_WITH(buildrules, | ||
| 175 | [BUILDRULES=libtool]) | 175 | [BUILDRULES=libtool]) |
| 176 | AC_MSG_RESULT($BUILDRULES) | 176 | AC_MSG_RESULT($BUILDRULES) |
| 177 | 177 | ||
| 178 | -if test "$BUILDRULES" != "msvc"; then | ||
| 179 | - qpdf_USE_WALL=0 | ||
| 180 | - AC_MSG_CHECKING(for whether $CC supports -Wall) | ||
| 181 | - oCFLAGS=$CFLAGS | ||
| 182 | - CFLAGS="$CFLAGS -Wall" | ||
| 183 | - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[int a = 1; int b = a; a = b;]])], | ||
| 184 | - [qpdf_USE_WALL=1],[qpdf_USE_WALL=0]) | ||
| 185 | - if test "$qpdf_USE_WALL" = "1"; then | ||
| 186 | - AC_MSG_RESULT(yes) | ||
| 187 | - CXXFLAGS="$CXXFLAGS -Wall" | ||
| 188 | - else | ||
| 189 | - AC_MSG_RESULT(no) | ||
| 190 | - CFLAGS=$oCFLAGS | ||
| 191 | - fi | 178 | +AC_SUBST(WFLAGS) |
| 179 | +qpdf_USE_EXTRA_WARNINGS=0 | ||
| 180 | +if test "$BUILDRULES" = "msvc"; then | ||
| 181 | + dnl /w14267 makes warning 4267 a level 1 warning. This warning reports | ||
| 182 | + dnl potential issues between size_t, off_t, and non-compatible integer | ||
| 183 | + dnl types. | ||
| 184 | + try_flags="/w14267" | ||
| 185 | +else | ||
| 186 | + try_flags="-Wall" | ||
| 187 | +fi | ||
| 188 | +AC_MSG_CHECKING(for whether $CC supports $try_flags) | ||
| 189 | +oCFLAGS=$CFLAGS | ||
| 190 | +CFLAGS="$CFLAGS $try_flags" | ||
| 191 | +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[int a = 1; int b = a; a = b;]])], | ||
| 192 | + [qpdf_USE_EXTRA_WARNINGS=1],[qpdf_USE_EXTRA_WARNINGS=0]) | ||
| 193 | +CFLAGS=$oCFLAGS | ||
| 194 | +if test "$qpdf_USE_EXTRA_WARNINGS" = "1"; then | ||
| 195 | + AC_MSG_RESULT(yes) | ||
| 196 | + WFLAGS="$try_flags" | ||
| 197 | +else | ||
| 198 | + AC_MSG_RESULT(no) | ||
| 192 | fi | 199 | fi |
| 193 | 200 | ||
| 194 | -if test "$BUILDRULES" != "msvc"; then | ||
| 195 | - AC_MSG_CHECKING(for whether to use -Werror) | ||
| 196 | - AC_ARG_ENABLE(werror, | ||
| 197 | - AS_HELP_STRING([--enable-werror], | ||
| 198 | - [whether to use werror (default is no)]), | ||
| 199 | - [if test "$enableval" = "yes"; then | ||
| 200 | - qpdf_USE_WERROR=1; | ||
| 201 | - else | ||
| 202 | - qpdf_USE_WERROR=0; | ||
| 203 | - fi], [qpdf_USE_WERROR=0]) | ||
| 204 | - if test "$qpdf_USE_WERROR" = "1"; then | ||
| 205 | - AC_MSG_RESULT(yes) | ||
| 206 | - CFLAGS="$CFLAGS -Werror" | ||
| 207 | - CXXFLAGS="$CXXFLAGS -Werror" | ||
| 208 | - else | ||
| 209 | - AC_MSG_RESULT(no) | ||
| 210 | - fi | 201 | +if test "$BUILDRULES" = "msvc"; then |
| 202 | + try_flags="/WX" | ||
| 203 | +else | ||
| 204 | + try_flags="-Werror" | ||
| 205 | +fi | ||
| 206 | +AC_MSG_CHECKING(for whether to use $try_flags) | ||
| 207 | +AC_ARG_ENABLE(werror, | ||
| 208 | + AS_HELP_STRING([--enable-werror], | ||
| 209 | + [whether to treat warnings as errors (default is no)]), | ||
| 210 | + [if test "$enableval" = "yes"; then | ||
| 211 | + qpdf_USE_WERROR=1; | ||
| 212 | + else | ||
| 213 | + qpdf_USE_WERROR=0; | ||
| 214 | + fi], [qpdf_USE_WERROR=0]) | ||
| 215 | +if test "$qpdf_USE_WERROR" = "1"; then | ||
| 216 | + AC_MSG_RESULT(yes) | ||
| 217 | + WFLAGS="$WFLAGS $try_flags" | ||
| 218 | +else | ||
| 219 | + AC_MSG_RESULT(no) | ||
| 211 | fi | 220 | fi |
| 212 | 221 | ||
| 213 | AC_SUBST(QPDF_SKIP_TEST_COMPARE_IMAGES) | 222 | AC_SUBST(QPDF_SKIP_TEST_COMPARE_IMAGES) |
make/msvc.mk
| @@ -19,16 +19,6 @@ endef | @@ -19,16 +19,6 @@ endef | ||
| 19 | CFLAGS := $(filter-out -g,$(CFLAGS)) | 19 | CFLAGS := $(filter-out -g,$(CFLAGS)) |
| 20 | CXXFLAGS := $(filter-out -g,$(CXXFLAGS)) | 20 | CXXFLAGS := $(filter-out -g,$(CXXFLAGS)) |
| 21 | 21 | ||
| 22 | -# /WX makes all warnings errors. | ||
| 23 | -CFLAGS += /WX | ||
| 24 | -CXXFLAGS += /WX | ||
| 25 | - | ||
| 26 | -# /w14267 makes warning 4267 a level 1 warning. This warning reports | ||
| 27 | -# potential issues between size_t, off_t, and non-compatible integer | ||
| 28 | -# types. | ||
| 29 | -CFLAGS += /w14267 | ||
| 30 | -CXXFLAGS += /w14267 | ||
| 31 | - | ||
| 32 | clean:: | 22 | clean:: |
| 33 | $(RM) *.pdb | 23 | $(RM) *.pdb |
| 34 | 24 |