You are not logged in.

#1 2017-05-27 14:14:45

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,595
Website

Redefine CFLAGS from /etc/makepkg.conf in PKGBUILD [SOLVED]

I would like to modify a PKGBUILD to redefine both CFLAGS and CXXFLAGS defined in /etc/makepkg,conf and am looking for the most elegant way to do it.  I basically want to take the march value from the Arch default and pass a CPU-specific one to it when I build a particular package locally.  What seems to work fine is to just unset them and redefine them like the below, but I'm wondering if there is a way I can treat them as an array or the like and simply redefine the march value without the unset stuff.  Does that make sense?

...
build() {
 unset CFLAGS CXXFLAGS
 export CFLAGS="-march=haswell -O2 -pipe -fstack-protector-strong -fdiagnostics-color"
 exportCXXFLAGS="${CFLAGS}"
 cd "$pkgname-$pkgver"
 ...

...perhaps a substitution wherein the target is the source... is that strategically flawed?

CFLAGS=${CFLAGS/x86-64/haswell}

Last edited by graysky (2017-05-27 15:42:46)


CPU-optimized Linux-ck packages @ Repo-ck  • AUR packagesZsh and other configs

Offline

#2 2017-05-27 15:02:56

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,449
Website

Re: Redefine CFLAGS from /etc/makepkg.conf in PKGBUILD [SOLVED]

Why do you need to remove anything - just append the value(s) you want.  Gcc will only use the last march specified:

export CFLAGS+=" -march=whatever"

"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#3 2017-05-27 15:07:53

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,595
Website

Re: Redefine CFLAGS from /etc/makepkg.conf in PKGBUILD [SOLVED]

I didn't realize the last value is the one honored.  Will test to verify and mark when done.  Thanks.


CPU-optimized Linux-ck packages @ Repo-ck  • AUR packagesZsh and other configs

Offline

Board footer

Powered by FluxBB