开发者

CPPFlags in config.mk

In Arch Linux PKGBUILD for surf browser, there is:

sed -i 's/CPPFLAGS =/CPPFLAGS +=/g' config.mk
sed -i 's/CFLAGS =/CFLAGS +=/g' config.mk
sed -i 's/LDFLAGS =/LDFLAGS +=/g' config.mk

Why must the flags be changed from

CPPFLAGS = -DVERSION=\"${VE开发者_开发问答RSION}\"

to

CPPFLAGS += -DVERSION=\"${VERSION}\"

I've looked into google, but don't see anything there about this. Can someone please explain and tell me where to read more about these flags?


I did quite a lot of googling and found that this pattern (Surf's is here) seems fairly common in Arch Linux PKGBUILD files. Another example was in DWM's PKGBUILD.

Obviously it is patching the config.mk file so that when make is called, the values are appended to the flags instead of overriding the flags (which must already be set elsewhere). So there must be existing settings that need to be retained. This seems to just be done by default by the package builders so it was hard to find the reason.

Looking further I found this bug report relating to DWM's config.mk file, where the author notes that a version of that file was overriding flags set in makepkg.conf which is the main configuration file for makepkg, which allows tuning compilation settings per machine. This seems like a reasonable explanation for what you found. From that page, a default value for CFLAGS would be something like this:

CFLAGS="-march=x86-64 -mtune=generic -O2 -pipe"

So the patched config.mk file would result in the following when building the package:

CFLAGS="-march=x86-64 -mtune=generic -O2 -pipe -std=c99 -pedantic -Wall -Os -I. ....."
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜