c - Bundling getopt_long() with my own code? -


i have own c project on github. want add long-option support using gnu getopt_long() (which has it's own git repository). believe there 4 ways can this:

  1. use git submodule.
  2. use git subtree.
  3. import source of current (2.22.6) snapshot own git repository.
  4. import only getopt_long() source files of getopt.c, getopt1.c, , gnugetopt.h.

the advantage of 1 , 2 track getopt_long(). advantages of 3 , 4 if git repository of getopt_long() moves, wont break repository and it's simpler do.

is there recommended "gnu way" this?

after bit more googl'ing, found the official gnu answer.

briefly, there 2 recommended approaches:

use gnulib (the "new" way)

using gnulib-tool command, 1 imports getopt compile subset of gnu library making few tweaks one's configure.ac , makefile.am files.

use getopt_long sources (the "old" way)

import getopt_long sources of getopt.c, getopt1.c, , gnugetopt.h , use adl_func_getopt_long.m4 macro test existence of getopt_long on platform , compile imported sources if necessary.


Comments