diff --git a/README b/README index d450a86..ecdcda2 100644 --- a/README +++ b/README @@ -109,9 +109,7 @@ wordsplit API, install wordsplit.h to $(pkgincludedir), e.g. Modify the VPATH variable in your Makefile.am: - VPATH += $(srcdir)/wordsplit - -Notice the use of "+=": it is necessary for the vpath builds to work. + VPATH = $(srcdir):$(srcdir)/wordsplit Add wordsplit.c to the nodist_program_SOURCES variable: @@ -129,7 +127,7 @@ An example Makefile.am: program_SOURCES = main.c nodist_program_SOURCES = wordsplit.c - VPATH += $(srcdir)/wordsplit + VPATH = $(srcdir):$(srcdir)/wordsplit EXTRA_DIST = wordsplit/wordsplit.c wordsplit/wordsplit.h AM_CPPFLAGS = -I$(srcdir)/wordsplit @@ -137,7 +135,7 @@ It is also possible to use LDADD as shown in the example below: program_SOURCES = main.c LDADD = wordsplit.o - VPATH += $(srcdir)/wordsplit + VPATH = $(srcdir):$(srcdir)/wordsplit EXTRA_DIST = wordsplit/wordsplit.c wordsplit/wordsplit.h AM_CPPFLAGS = -I$(srcdir)/wordsplit @@ -153,10 +151,14 @@ already has an autotest-based testsuite. ** Additional files -To build the auxiliary tool wsp, you will need an additional file, -wordsplit-version.h. Normally, it should contain only a definition -of the macro or variable WORDSPLIT_VERSION. The following shell -fragment can be used to create it: +To build the auxiliary tool wsp, it is recommended to define the +WORDSPLIT_VERSION macro to the actual version of the wordsplit +package. There are two ways of doing so. First, you can define +WORDSPLIT_VERSION in your config.h or pass its definition via the +AM_CPPFLAGS variable. Secondly, you can create an additional file, +wordsplit-version.h, containing its definition and define the +HAVE_WORDSPLIT_VERSION_H macro to make sure it is included. The +following shell fragment can be used to create the header: version=$(cd wordsplit; git describe) cat > wordsplit-version.h <'; } > \ + echo "#define WORDSPLIT_VERSION \"$wsversion\""; } > \ > $(srcdir)/wordsplit-version.h + AM_CPPFLAGS += -DHAVE_WORDSPLIT_VERSION_H noinst_PROGRAMS += wsp wsp_SOURCES = nodist_wsp_SOURCES = wsp.c wsp.o: $(srcdir)/wordsplit-version.h - VPATH += $(top_srcdir)/libmailutils/wordsplit + VPATH = $(srcdir):$(top_srcdir)/wordsplit * History diff --git a/wsp.c b/wsp.c index 913a777..38420b3 100644 --- a/wsp.c +++ b/wsp.c @@ -22,7 +22,11 @@ #include #include #include -#include "wordsplit-version.h" +#ifndef WORDSPLIT_VERSION +# ifdef HAVE_WORDSPLIT_VERSION_H +# include "wordsplit-version.h" +# endif +#endif #include "wordsplit.h" extern char **environ; @@ -96,6 +100,10 @@ struct wsopt /* Index of the next argument in the argv */ static int wsoptind = -1; +#ifndef WORDSPLIT_VERSION +# define "WORDSPLIT_VERSION not defined" +#endif + void print_version (void) {