After a bit more googl'ing, I found the official GNU answer .
In short, there are two recommended approaches:
Use Gnulib (the "new" way)
Using the command gnulib-tool, one of them imports getoptto compile it as a subset of the GNU library by making several settings for a single file configure.acand Makefile.am.
Use sources getopt_long("old")
Import the sources getopt_long getopt.c, getopt1.cand gnugetopt.huse the macro adl_func_getopt_long.m4to check for existence getopt_longon the platform and, if necessary, compile the imported sources.
source
share