How to use "options" to add compile flags in a PKGBUILD?

Hey all,
How do I properly add compile flags in a PKGBUILD?

I’m trying to install MiKTeX installed from AUR. However due to the the standard compile flag -Werror=format-security set in /etc/makepkg.conf the project fails to compile.
I wanted to try to add the compile flag with -Wno-error=format-security in the PKGBUILD by adding: options=('buildflags=" -Wno-error=format-security")

However, I always get an error saying that the options contains an unknown option… According to man pages of PKGBUILD it is possible, so I assume I just couldn’t figure out the proper syntax.

I can’t find a good example on how to use that opiton and I tried various variations including options=('buildflags="CFLAGS=\" -Wno-error=format-security\"") and many more, but I can’t get it to accept the options.

PS: Unfortunately, Arch Linux and derivatives are not officially supported (yet) by MiKTeX and therefore, the MiKTeX programmers won’t accept bug reports from these distributions. I (and some others) might have to go with that workaround for that reason.

That’s not a vaild value for the options() array, see makepkg.conf(5) — Arch manual pages

Edit the PKGBUILD and add -Wno-error=format-security as a build flag to the cmake line to override the default CFLAGS:

cmake \
  -Wno-error=format-security \
  -DCMAKE_INSTALL_PREFIX=/opt/miktex \
  -DWITH_UI_QT=ON \
  -DUSE_SYSTEM_POPPLER=TRUE \
  -DUSE_SYSTEM_POPPLER_QT5=TRUE \
  ..
2 Likes

Thank you!
That solved the error of the misformatted PKGBUILD.

Apparently, I misunderstood the manual pages…
Unfortunately, adding -Wno-error=format-security won’t overwrite -Werror=format-security specified in makepkg.conf. However, completely disabling buildflags by adding options=("!buildflags") allows the package to compile sucessfully.

Hmm, I had a tickle in the back of my mind that it might not work, but I ignored it. :man_facepalming:

Try adding this as the first line in the build() function instead:

export CFLAGS="${CFLAGS} -Wno-error=format-security"

I tried that, but it still fails to compile due to the -Werror=format-security. Even putting the new flag in front of the old flags doesn’t work:

    export CFLAGS="-Wno-error=format-security ${CFLAGS}"

It appears that the presence of -Werrorhas a higher priority than -Wno-error, which makes sense.

I guess, the only way that is left would be to try to use string substitution. I’m not sure if that’s a good solution, but I guess I’ll give it a try on Wednesday.

Interesting, didn’t realize it couldn’t be overridden with either way I proposed. I thought I’ve been able to override build flags before like that. I know I have with Meson projects, but that’s a different animal.

If you find a way to override that flag, let me know.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.