简体   繁体   中英

How to override dpkg-buildflags CFLAGS?

I got a package with:

$ apt-get source <pkg-name>

and now I am trying to build it with:

$ dpkg-buildpackage -uc -us -j8

At the beginning of the output, there is stated:

dpkg-buildpackage: export CFLAGS from dpkg-buildflags (origin: vendor): -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security
dpkg-buildpackage: export CPPFLAGS from dpkg-buildflags (origin: vendor): -D_FORTIFY_SOURCE=2
dpkg-buildpackage: export CXXFLAGS from dpkg-buildflags (origin: vendor): -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security
dpkg-buildpackage: export FFLAGS from dpkg-buildflags (origin: vendor): -g -O2
dpkg-buildpackage: export LDFLAGS from dpkg-buildflags (origin: vendor): -Wl,-Bsymbolic-functions -Wl,-z,relro

I would like to override these CFLAGS (also, the LDFLAGS). I have tried exporting the CFLAGS envvar, the same way we do with plain configure, at no avail. How can I override these values?

the package you are trying to rebuild, sets (read: overrides) the *FLAGS with hardening-specifics flags retrieved from dpkg-buildflags .

if you need to override those flags for your own purposes, you should tell dpkg-buildflags to provide the flags you want, rather than the (hardening) defaults. looking at man dpkg-buildflags , you find the section about environment variables, esp. see DEB_flag_SET and DEB_flag_APPEND

so this should do the trick (fill in your own *FLAGS):

$ DEB_CPPFLAGS_SET="-I/foo/bar/baz" DEB_CFLAGS_SET="-g -O6" DEB_LDFLAGS_SET="-L/fruzzel/frazzel/" dpkg-buildpackage -uc -us -j8 -rfakeroot

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM