Skip to content
  • jsquyres's avatar
    This is a horrible compromise just for the sake of getting beta4 out the · 37ea15a1
    jsquyres authored
    door, and it's a more complicated issue than one would think,
    so read everything before you draw any conclusions.  :-)
    
    The issues:
    
    It is not a good idea to double-instantiate functions/variables that
    the underlsying OS already provides.  getopt() and friends are a good
    example of this.  However, some systems don't have the getopt-kinds of
    functionality that is used in the tools (i.e., some do, some don't).
    Hence, we include the GNU
    definitions of getopt(), getopt_long(), and their associated global
    variables.  GNU libc systems will effectively nullify our included
    copies due to clever #if statements in the files.  POSIX systems that
    have getopt() (but not getopt_long()) will have a double instantiation
    of getopt() and the global variables.  This appears to not cause any
    problems (but it still isn't Right).
    
    The short-term solution:
    
    Copy getopt.c, getopt.h, and getopt1.c into each of the directories in
    the vorbis-tools tree, and let each tool compile and link their own
    local copies.  We do this because we know *it works*, and we need to get
    beta4 out the door.  This commit copies them into
    vorbis-tools/vorbiscomment (they were already in oggenc and ogg123).
    
    The long-term solution:
    
    After beta4 is out the door and we have time for proper testing, we'll
    remove the getopt* files from each tool directory and create a new
    directory named "support/", and put them in there.  But with a few
    caveats.
    
    - getopt() will be commented out.  We don't use it, anyway -- we only
    use getopt_long() (getopt() is not used to implement getopt_long()).
    - tests will be added in configure to check for getopt() on the local
    system.  If it's already there, we won't instantiate the global
    variables in getopt.c (since the OS already provides them).
    - there's still indecision on whether to name the included copy of
    getopt.h to be something different (e.g,. "ov_getopt.h") to prevent a
    name clash with the OS's copy (if it has one).  To be decided later...
    - the relevant .c files will be compiled into a static convenience
    library, libvtsupport.a.
    - each of the tool directories will "-l$(top_builddir)/support
    -lvtsupport" when linking their binaries
    - if other functions come up like this (that exist on some systems but
    not on others), we can add them into libvtsupport.a.
    
    svn path=/trunk/vorbis-tools/; revision=1319
    37ea15a1