Determine flags that were given for packages installed with homebrew

Solution 1:

When a package is built from source the flags that were used to build are shown when you do brew info <package>.

In this case: brew info emacs | grep "Built from source"

Solution 2:

There is a file in /usr/local/Cellar underneath each package that is called INSTALL_RECEIPT.json, e.g. for gawk:

/usr/local/Cellar/gawk/4.1.3/INSTALL_RECEIPT.json

that defines how the package was installed. I think the correct way to access it is with

brew info --json=v1 <packagename>

e.g.

brew info --json=v1 gnuplot

That spews out loads of stuff, but if you send it through jq (JSON Processor - handily available via homebrew) you can select out the options you used to install the package like this (checking the gnuplot package):

brew info --json=v1 gnuplot | jq '.[].installed[0].used_options'
[
    "--with-qt"
]

which tells me I installed gnuplot using:

brew install --with-qt gnuplot