I am running on a CentOS 5.7 system.
I downloaded a source package and a .spec file from someone else. I am trying to build a RPM from the source using a vanilla command like:
% rpmbuild -ba ~/rpmbuild/SPECS/foo.spec
...
Configuration summary:
======================
Host type................: x86_64-redhat-linux-gnu
CC.......................: gcc
CFLAGS...................: -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -Werror
Package..................: sudosh2
Version..................: 1.0.4
Installation prefix......: /usr
Man directory............: /usr/share/man
sysconfdir...............: /etc
recording input..........: no
However, this build is failing. The code is a little sloppy and is generating some warnings. Some part of this toolchain is enabling -Werror
flag, which makes "all warnings into errors." Thus, the build fails with an error:
gcc -DHAVE_CONFIG_H -I. -I.. -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -Werror -MT parse.o -MD -MP -MF .deps/parse.Tpo -c -o parse.o parse.c
cc1: warnings being treated as errors
sudosh.c: In function 'main':
sudosh.c:486: warning: unused variable 'written'
sudosh.c:112: warning: unused variable 'found'
cc1: warnings being treated as errors
parse.c: In function 'parse':
parse.c:20: warning: unused variable 'y'
parse.c:14: warning: unused variable 'opt'
parse.c:14: warning: unused variable 'cmt'
parse.c:14: warning: unused variable 'arg'
parse.c:10: warning: unused variable 'i'
parse.c:10: warning: unused variable 'line_number'
make[2]: *** [sudosh.o] Error 1
I know the proper fix is for the author to fix the code, but I want to work around this problem in the short term. I need a working RPM.
It looks like either ./configure
or autoconf
is automatically adding the -Werror
flag. How can I disable the -Werror
flags for my builds, short of editing the Makefile myself?
Update in response to @pwan's answer:
The .spec file is pretty generic, and doesn't specify any special flags:
%build
%configure \
--program-prefix="%{?_program_prefix}"
%{__make} %{?_smp_mflags}