* This patch should tell lib-src/Makefile
   that it can use regex and getopt from GNU LibC
                -- Stepan Kasal <kasal@suse.cz>

--- lib-src/Makefile.in
+++ lib-src/Makefile.in	2007-05-15 17:48:45.509066296 +0200
@@ -248,6 +248,8 @@ LOADLIBES=LIBS_SYSTEM LIBS_MACHINE LIB_S
    the information in ../src/config.h.  */
 ALL_CFLAGS = C_SWITCH_SYSTEM C_SWITCH_MACHINE -DHAVE_CONFIG_H \
    -I. -I../src -I${srcdir} -I${srcdir}/../src ${LDFLAGS} ${CPPFLAGS} ${CFLAGS}
+ETAGS_CFLAGS = C_SWITCH_SYSTEM C_SWITCH_MACHINE -DHAVE_CONFIG_H \
+   -I. -I${srcdir} ${LDFLAGS} ${CPPFLAGS} ${CFLAGS}
 LINK_CFLAGS = C_SWITCH_SYSTEM C_SWITCH_MACHINE -DHAVE_CONFIG_H \
    -I. -I../src -I${srcdir} -I${srcdir}/../src ${LDFLAGS} ${CFLAGS}
 CPP_CFLAGS = C_SWITCH_SYSTEM C_SWITCH_MACHINE -DHAVE_CONFIG_H \
@@ -394,12 +396,17 @@ getopt.h: getopt_.h
 	cp $(srcdir)/getopt_.h $@-t
 	mv $@-t $@
 
+#ifdef GETOPT_IN_LIBC
+GETOPTOBJS =
+GETOPTDEPS =
+#else
 GETOPTOBJS = @GETOPTOBJS@
 GETOPTDEPS = $(GETOPTOBJS) $(GETOPT_H)
 getopt.o: ${srcdir}/getopt.c $(GETOPT_H) ${srcdir}/gettext.h
 	${CC} -c ${CPP_CFLAGS} ${srcdir}/getopt.c
 getopt1.o: ${srcdir}/getopt1.c $(GETOPT_H)
 	${CC} -c ${CPP_CFLAGS} ${srcdir}/getopt1.c
+#endif
 
 #ifdef REGEXP_IN_LIBC
 REGEXPOBJ =
@@ -413,7 +420,7 @@ regex.o: $(srcdir)/../src/regex.c $(srcd
 	${CC} -c ${BASE_CFLAGS} -DCONFIG_BROKETS -DINHIBIT_STRING_HEADER ${srcdir}/../src/regex.c
 
 etags${EXEEXT}: ${srcdir}/etags.c $(GETOPTDEPS) $(REGEXPDEPS) ../src/config.h
-	$(CC) ${ALL_CFLAGS} -DEMACS_NAME="\"GNU Emacs"\" -DVERSION="\"${version}\"" ${srcdir}/etags.c $(GETOPTOBJS) $(REGEXPOBJ) $(LOADLIBES) -o etags
+	$(CC) ${ETAGS_CFLAGS} -DEMACS_NAME="\"GNU Emacs"\" -DVERSION="\"${version}\"" ${srcdir}/etags.c $(GETOPTOBJS) $(REGEXPOBJ) $(LOADLIBES) -o etags
 
 ebrowse${EXEEXT}: ${srcdir}/ebrowse.c $(GETOPTDEPS) ../src/config.h
 	$(CC) ${ALL_CFLAGS} -DVERSION="\"${version}\"" ${srcdir}/ebrowse.c $(GETOPTOBJS) $(LOADLIBES) -o ebrowse
@@ -421,7 +428,7 @@ ebrowse${EXEEXT}: ${srcdir}/ebrowse.c $(
 /* We depend on etags to assure that parallel makes don\'t write two
    etags.o files on top of each other.  */
 ctags${EXEEXT}: etags${EXEEXT}
-	$(CC) ${ALL_CFLAGS} -DCTAGS -DEMACS_NAME="\"GNU Emacs"\" -DVERSION="\"${version}\"" ${srcdir}/etags.c $(GETOPTOBJS) $(REGEXPOBJ) $(LOADLIBES) -o ctags
+	$(CC) ${ETAGS_CFLAGS} -DCTAGS -DEMACS_NAME="\"GNU Emacs"\" -DVERSION="\"${version}\"" ${srcdir}/etags.c $(GETOPTOBJS) $(REGEXPOBJ) $(LOADLIBES) -o ctags
 
 profile${EXEEXT}: ${srcdir}/profile.c ../src/config.h
 	$(CC) ${ALL_CFLAGS} ${srcdir}/profile.c $(LOADLIBES) -o profile
--- lib-src/etags.c
+++ lib-src/etags.c	2001-10-24 18:13:46.000000000 +0200
@@ -94,7 +94,7 @@ char pot_etags_version[] = "@(#) pot rev
 #endif
 
 #ifdef HAVE_CONFIG_H
-# include <config.h>
+# include <../src/config.h>
   /* On some systems, Emacs defines static as nothing for the sake
      of unexec.  We don't want that here since we don't use unexec. */
 # undef static
--- src/s/gnu-linux.h
+++ src/s/gnu-linux.h	2001-10-24 18:13:46.000000000 +0200
@@ -337,7 +337,11 @@ Boston, MA 02110-1301, USA.  */
 /* However, sometimes they disagree with the src/regex.h that comes with Emacs,
    and that can make trouble in etags.c because it gets the regex.h from Emacs
    and the function definitions in libc.  So turn this off.  */
-/* #define REGEXP_IN_LIBC */
+/* Why should etags.c include ../src/regex.h ??  Turn this on. */
+#define REGEXP_IN_LIBC
+
+/* ... and we also have getopt in the GNU C-library. */
+#define GETOPT_IN_LIBC
 
 /* Use BSD process groups, but use setpgid() instead of setpgrp() to
    actually set a process group. */