diff options
author | Michael Paquier | 2012-05-18 20:35:39 +0000 |
---|---|---|
committer | Michael Paquier | 2012-05-18 20:39:54 +0000 |
commit | fdd1475f3512e00aa49ac62b2bc648130ae2c413 (patch) | |
tree | 9ec3a480d632d5c868e33d4459315b38154aa6f0 /src | |
parent | d4411736614888533e65c7dd6e68ddcdadb30a0f (diff) |
Fix make install for vpath installation
Documentation tool used for Postgres-XC documentation compilation
called makesgml is moved to a specific tool repository out of the
documentation folder itself to strengthen independency of this module.
Makefile structure is also reviewed in a couple of places directly
dependant on makesgml like bin/psql.
Some other issues related to the way GTM binaries were installed are
fixed and treated now as consistently as Postgres.
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile | 4 | ||||
-rw-r--r-- | src/bin/psql/Makefile | 4 | ||||
-rw-r--r-- | src/gtm/Makefile | 6 | ||||
-rw-r--r-- | src/pgxc/Makefile | 17 | ||||
-rw-r--r-- | src/pgxc/bin/Makefile | 18 | ||||
-rw-r--r-- | src/pgxc/bin/pgxc_clean/Makefile | 19 | ||||
-rw-r--r-- | src/pgxc/tools/Makefile | 18 | ||||
-rw-r--r-- | src/pgxc/tools/makesgml/Makefile | 37 | ||||
-rw-r--r-- | src/pgxc/tools/makesgml/README | 63 | ||||
-rw-r--r-- | src/pgxc/tools/makesgml/makesgml.c | 379 |
10 files changed, 547 insertions, 18 deletions
diff --git a/src/Makefile b/src/Makefile index 84f96c4969..4d7928395a 100644 --- a/src/Makefile +++ b/src/Makefile @@ -17,6 +17,7 @@ SUBDIRS = \ timezone \ gtm \ interfaces \ + pgxc \ backend \ backend/utils/mb/conversion_procs \ backend/snowball \ @@ -25,8 +26,7 @@ SUBDIRS = \ bin \ pl \ makefiles \ - test/regress \ - pgxc/bin/pgxc_clean + test/regress # There are too many interdependencies between the subdirectories, so # don't attempt parallel make here. diff --git a/src/bin/psql/Makefile b/src/bin/psql/Makefile index 23f3cafd20..107f774026 100644 --- a/src/bin/psql/Makefile +++ b/src/bin/psql/Makefile @@ -18,8 +18,8 @@ include $(top_builddir)/src/Makefile.global REFDOCDIR= $(top_srcdir)/doc-xc/src/sgml/ref -MAKESGMLDIR = $(top_srcdir)/doc-xc/tools/makesgml -SGMLDIR= $(top_srcdir)/doc-xc/src/sgml +MAKESGMLDIR = $(top_builddir)/src/pgxc/tools/makesgml +SGMLDIR= $(top_builddir)/doc-xc/src/sgml override CPPFLAGS := -I. -I$(srcdir) -I$(libpq_srcdir) -I$(top_srcdir)/src/bin/pg_dump $(CPPFLAGS) diff --git a/src/gtm/Makefile b/src/gtm/Makefile index c7779db887..05a962e30d 100644 --- a/src/gtm/Makefile +++ b/src/gtm/Makefile @@ -33,9 +33,9 @@ distclean: clean maintainer-clean: distclean install: all - $(INSTALL_PROGRAM) $(srcdir)/main/gtm$(X) '$(DESTDIR)$(bindir)/gtm$(X)' - $(INSTALL_PROGRAM) $(srcdir)/gtm_ctl/gtm_ctl$(X) '$(DESTDIR)$(bindir)/gtm_ctl$(X)' - $(INSTALL_PROGRAM) $(srcdir)/proxy/gtm_proxy$(X) '$(DESTDIR)$(bindir)/gtm_proxy$(X)' + $(INSTALL_PROGRAM) main/gtm$(X) '$(DESTDIR)$(bindir)/gtm$(X)' + $(INSTALL_PROGRAM) gtm_ctl/gtm_ctl$(X) '$(DESTDIR)$(bindir)/gtm_ctl$(X)' + $(INSTALL_PROGRAM) proxy/gtm_proxy$(X) '$(DESTDIR)$(bindir)/gtm_proxy$(X)' $(INSTALL_DATA) $(srcdir)/main/gtm.conf.sample '$(DESTDIR)$(datadir)/gtm.conf.sample' $(INSTALL_DATA) $(srcdir)/proxy/gtm_proxy.conf.sample '$(DESTDIR)$(datadir)/gtm_proxy.conf.sample' diff --git a/src/pgxc/Makefile b/src/pgxc/Makefile new file mode 100644 index 0000000000..a75fb5fdaa --- /dev/null +++ b/src/pgxc/Makefile @@ -0,0 +1,17 @@ +#---------------------------------------------------------------------------- +# +# Postgres-XC documentation tool makefile +# +# Copyright (c) 2010-2012 Nippon Telegraph and Telephone Corporation +# +# doc-xc/Makefile +# +#---------------------------------------------------------------------------- + +subdir = src/pgxc +top_builddir = ../.. +include $(top_builddir)/src/Makefile.global + +SUBDIRS = bin tools + +$(recurse) diff --git a/src/pgxc/bin/Makefile b/src/pgxc/bin/Makefile new file mode 100644 index 0000000000..3950290b42 --- /dev/null +++ b/src/pgxc/bin/Makefile @@ -0,0 +1,18 @@ +#---------------------------------------------------------------------------- +# +# Postgres-XC documentation tool makefile +# +# Copyright (c) 2010-2012 Nippon Telegraph and Telephone Corporation +# +# doc-xc/Makefile +# +#---------------------------------------------------------------------------- + +subdir = src/pgxc/bin +top_builddir = ../../.. +include $(top_builddir)/src/Makefile.global + +SUBDIRS = pgxc_clean + +all distprep html man install installdirs uninstall clean distclean maintainer-clean maintainer-check: + $(MAKE) -C $(SUBDIRS) $@ diff --git a/src/pgxc/bin/pgxc_clean/Makefile b/src/pgxc/bin/pgxc_clean/Makefile index 8251a04ebe..6a910c3c15 100644 --- a/src/pgxc/bin/pgxc_clean/Makefile +++ b/src/pgxc/bin/pgxc_clean/Makefile @@ -18,22 +18,20 @@ override CPPFLAGS := -I$(libpq_srcdir) $(CPPFLAGS) gtm_builddir = $(top_builddir)/src/gtm OBJS= pgxc_clean.o txninfo.o -EX_OBJS = $(gtm_builddir)/common/assert.o \ - $(gtm_builddir)/client/libgtmclient.a +EX_OBJS = $(gtm_builddir)/common/assert.o \ + $(gtm_builddir)/client/libgtmclient.a -override LDFLAGS += -L$(top_builddir)/src/gtm/client \ +override LDFLAGS := -L$(top_builddir)/src/gtm/client $(LDFLAGS) -# Switch when libxcm and libgtmclient are installed via 'make install' -# LIBS= -lpthread -lxcm -lgtmclient LIBS= -lpthread -all: pgxc_clean - pgxc_clean: $(OBJS) - $(CC) $(CFLAGS) $(OBJS) $(EX_OBJS) $(libpq_pgport) $(LDFLAGS) $(LIBS) -o $@$(X) + $(CC) $(CFLAGS) $(EX_OBJS) $(OBJS) $(libpq_pgport) $(LDFLAGS) $(LIBS) -o $@$(X) + +all: pgxc_clean install: $(all) - $(INSTALL_PROGRAM) pgxc_clean$(X) '$(DESTDIR)$(bindir)'/pgxc_clean$(X) + $(INSTALL_PROGRAM) pgxc_clean$(X) '$(DESTDIR)$(bindir)/pgxc_clean$(X)' installdirs: $(mkinstalldirs) '$(DESTDIR)$(bindir)' @@ -42,5 +40,4 @@ uninstall: rm -f $(addprefix '$(DESTDIR)$(bindir)'/, pgxc_clean$(X)) clean distclean maintainer-clean: - rm -f pgxc_clean$(X) $(OBJS) pgxc_clean.o - + rm -f pgxc_clean$(X) $(OBJS) diff --git a/src/pgxc/tools/Makefile b/src/pgxc/tools/Makefile new file mode 100644 index 0000000000..21b7312337 --- /dev/null +++ b/src/pgxc/tools/Makefile @@ -0,0 +1,18 @@ +#---------------------------------------------------------------------------- +# +# Postgres-XC documentation tool makefile +# +# Copyright (c) 2010-2012 Nippon Telegraph and Telephone Corporation +# +# doc-xc/Makefile +# +#---------------------------------------------------------------------------- + +subdir = src/pgxc/tools +top_builddir = ../../.. +include $(top_builddir)/src/Makefile.global + +SUBDIRS = makesgml + +all distprep html man install installdirs uninstall clean distclean maintainer-clean maintainer-check: + $(MAKE) -C $(SUBDIRS) $@ diff --git a/src/pgxc/tools/makesgml/Makefile b/src/pgxc/tools/makesgml/Makefile new file mode 100644 index 0000000000..d3b50ba090 --- /dev/null +++ b/src/pgxc/tools/makesgml/Makefile @@ -0,0 +1,37 @@ +#---------------------------------------------------------------------------- +# +# Postgres-XC makesgml tool makefile +# +# Copyright(c) 2010-2012 Nippon Telegraph and Telephone Corporation +# +# doc-xc/tools/makesgml/Makefile +# +#----------------------------------------------------------------------------- + +PGFILEDESC = "makesgml - convert .sgmlin to .sgml" +PGAPPICON=win32 + +subdir = src/pgxc/tools/makesgml +top_builddir = ../../../.. +include $(top_builddir)/src/Makefile.global + +override CPPFLAGS := -I. -I$(srcdir) $(CPPFLAGS) + +OBJS = makesgml.o + +makesgml: $(OBJS) + $(CC) $(CFLAGS) $(LDFLAGS) $^ -o $@$(X) + +all distprep html man: makesgml + +install: all installdirs + $(INSTALL_PROGRAM) makesgml$(X) '$(DESTDIR)$(bindir)/makesgml$(X)' + +installdirs: + $(MKDIR_P) '$(DESTDIR)$(bindir)' + +uninstall: + rm -rf '$(DESTDIR)$(bindir)/makesgml$(X)' + +clean distclean maintenance-clean maintainer-clean: + rm -rf makesgml$(X) $(OBJS) diff --git a/src/pgxc/tools/makesgml/README b/src/pgxc/tools/makesgml/README new file mode 100644 index 0000000000..2c3a8b3016 --- /dev/null +++ b/src/pgxc/tools/makesgml/README @@ -0,0 +1,63 @@ +README for SGML construction tool. + +Aug.2, 2011, Koichi Suzuki + +============================================ +This directory contains SGML source file build tool "makesgml". +Please simply compile and place the binary to the directory of your +choice. + +As you see, all the document "source" files are not ".sgml", but are +".sgmlin". This change was made to preserve all the original +PostgreSQL document, select, modify and add common and Postgres-XC +specific descriptions. + +Background and practice are as follows: + +We should be careful to make it easier to merge with later version of +PostgreSQL SGML files. To do this, we can embed special "TAG" to +distinguish what is common, what is PostgreSQL-specific and what is +Postgres-XC specific. Also, we may want to distinguish translation to +different languages. + +To make it easier to handle as an external tool, we can build +dedicated (but somewhat general) tool to select what tags to be +included. At present, the format is <!## tag> ... <!## end>. These +tags can appear just itself as separate lines. Lines not enclosed with +any such tags are common to all. + +So SGML file may look like... + +--------------------- + ... + <para> + <!## PG> + ... + <!## end> + <!## XC> + ... + <!## end> + </para> +-------------------- + +You can nest this tag. With the nest, you can include multiple +translations in a single file. + +This can be handled by a command makesgml, which will be placed at +postgres-xc/doc/tools. + +Makesgml can be invoked like + +------------------ +makesgml -i inf -o outf -I include_tag ... -E exclude_tag ... +------------------ + +Each argument is optional and order of the argument is arbitrary. If +you omit -i option, it will read from stdin. If -o is omitted, it will +write to stdout. If input file include unspecified tags in the +arguments, it will be treated as specified -E. + +All the sgml files from original PostgreSQL tarball will be renamed to +sgmlin. Then it will be filtered by makesgml and fed to original +document build scripts. + diff --git a/src/pgxc/tools/makesgml/makesgml.c b/src/pgxc/tools/makesgml/makesgml.c new file mode 100644 index 0000000000..a5f257238d --- /dev/null +++ b/src/pgxc/tools/makesgml/makesgml.c @@ -0,0 +1,379 @@ +/*---------------------------------------------------------------------------- + * + * makesgml - Postgres-XC document build tool + * + * Copyright (c) 2010-2012, Nippon Telegraph and Telephone Corporation + * + * IDENTIFICATION + * doc-xc/tools/makesgml/makesgml.c + * + * This tools converts .sgmlin files into .sgml files to be handled by + * many tools to generate Postgres-XC documants. + * + * To mark the difference between PostgreSQL and Postgres-XC, .sgmlin + * uses dedicated tabs <!## name> and <!## end>, where name is PG or XC + * which indicates specific information for PostgreSQL and Postgres-XC + * respectively. This mechanism is introduced to make it easier + * to merge PostgreSQL upgrades. + * + * In fact, name can be arbitrary identifier other than "end". For example, + * this can be <!## JP> or <!## EN> to indicate the language is Japanese or + * English. + * + * This tool accepts the following arguments: + * + * -i infilename: specifies input file name. - means standard input. If not + * specified, standard input will be used. + * -o outfilename: specifies output file name. - means standard output. If + * not specified, standard output will be used. + * -I name: specify the name tag which will be included in the output. + * You can specifiy this parameter as many times as needed. + * -E name: specify the name tag which will be excluded in the output. + * You may specify this parameter as many times as needed. + * -d opt: Specify the default handling of the tags which does not appear + * in -I or -E option. opt can be i (include) or e (exluce). + * Default is e. + * + * To keep error massages in the following stage easy to track by the line + * number, excluded line will be replaced with brank line. + * + *--------------------------------------------------------------------------- + */ +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#include <unistd.h> +#include <errno.h> + + +typedef struct tokenlist +{ + struct tokenlist *next; + char *token; +} tokenlist; + +static int find_match(char *token, tokenlist *toks); +static int find_match_exclude(char *token); +static int find_match_include(char *token); +static void usage(int exitcode); + +#define STARTTOKEN "<!##" + +tokenlist *ignoreToks = NULL; +tokenlist *lastIgnoreToken = NULL; +tokenlist *includeToks = NULL; +tokenlist *lastIncludeToken = NULL; + +FILE *inf; +FILE *outf; +int inf_lno; +char *progname; +int default_include = 0; + +void make_sgml(int writeflag); +void usage(int exitcode); +void format_err(int lno); +int my_getline(char *buf); + +int main(int argc, char *argv[]) +{ + int opt; + char *ifnam = NULL; + char *ofnam = NULL; + + char *token; + + inf = stdin; + outf = stdout; + + progname = argv[0]; + while ((opt = getopt(argc, argv, "i:o:E:I:d:")) != -1) + { + switch(opt) + { + case 'i': + if (ifnam) + { + free(ifnam); + ifnam = NULL; + } + + if ((strcmp(optarg, "-") == 0) || (strcmp(optarg, "stdin") == 0)) + inf = stdin; + else + ifnam = strndup(optarg, strlen(optarg)); + break; + + case 'o': + if (ofnam) + { + free(ofnam); + ofnam = NULL; + } + + if ((strcmp(optarg, "-") == 0) || (strcmp(optarg, "stdout") == 0)) + outf = stdout; + else + ofnam = strndup(optarg, strlen(optarg)); + break; + + case 'E': + token = strndup(optarg,strlen(optarg)); + if (ignoreToks == NULL) + { + ignoreToks = (tokenlist *)malloc(sizeof(tokenlist)); + if (ignoreToks == NULL) + goto memerr; + ignoreToks->token = token; + ignoreToks->next = NULL; + lastIgnoreToken = ignoreToks; + } + else + { + lastIgnoreToken->next = (tokenlist *)malloc(sizeof(tokenlist)); + if (lastIgnoreToken->next == NULL) + goto memerr; + lastIgnoreToken = lastIgnoreToken->next; + lastIgnoreToken->next = NULL; + lastIgnoreToken->token = token; + } + break; + + case 'I': + token = strndup(optarg, strlen(optarg)); + if (includeToks == NULL) + { + includeToks = (tokenlist *)malloc(sizeof(tokenlist)); + if (includeToks == NULL) + goto memerr; + includeToks->token = token; + includeToks->next = NULL; + lastIncludeToken = includeToks; + } + else + { + lastIncludeToken->next = (tokenlist *)malloc(sizeof(tokenlist)); + if (lastIncludeToken->next == NULL) + goto memerr; + lastIncludeToken = lastIncludeToken->next; + lastIncludeToken->next = NULL; + lastIncludeToken->token = token; + } + break; + + case 'd': /* Default handling: include/exclude */ + if (strcmp(optarg, "i") == 0) + default_include = 1; + else if (strcmp(optarg, "e") == 0) + default_include = 0; + else + usage(1); + break; + + default: + usage(1); + exit(1); + } + } + if (ifnam) + { + inf = fopen(ifnam, "r"); + if (inf == NULL) + { + fprintf(stderr, "Cannot open input file %s, %s\n", ifnam, strerror(errno)); + exit(1); + } + } + inf_lno = 0; + if (ofnam) + { + outf = fopen(ofnam, "w"); + if (outf == NULL) + { + fprintf(stderr, "Cannot open output file %s, %s\n", ofnam, strerror(errno)); + exit(1); + } + } + make_sgml(1); + exit(0); + +memerr: + fprintf(stderr, "Memory not available.\n"); + exit(1); +} + +int my_getline(char *buf) +{ + int c; + + c = getc(inf); + if (c == EOF) + { + *buf = 0; + return EOF; + } + else + { + ungetc(c, inf); + } + for (;;) + { + c = getc(inf); + switch(c) + { + case '\n': + *buf++ = c; + *buf = 0; + inf_lno++; + return 1; + case EOF: + *buf = 0; + inf_lno++; + return 1; + default: + *buf++ = c; + continue; + } + } + exit(1); +} + + +static int find_match(char *token, tokenlist *toks) +{ + tokenlist *currToks; + + for (currToks = toks; currToks; currToks = currToks->next) + { + if (strcmp(token, currToks->token) == 0) + return 1; + } + return 0; +} + +static int find_match_exclude(char *token) +{ + return find_match(token, ignoreToks); +} + +static int find_match_include(char *token) +{ + return find_match(token, includeToks); +} + +void format_err(int lno) +{ + fprintf(stderr, "Input file format error. Line %d.\n", lno); + exit(1); +} + +void make_sgml(int writeflag) +{ + int rv; + char inputline[4096]; + + for (;;) + { + char *curr; + char *token; + + rv = my_getline(inputline); + if (rv == EOF) + return; + curr = inputline; + for (;;curr++) + { + if (*curr == ' ' || *curr == '\t') + continue; + else + break; + } + if (memcmp(curr, STARTTOKEN, strlen(STARTTOKEN)) == 0) + { + curr += strlen(STARTTOKEN); + if (*curr != ' ' && *curr != '\t') + format_err(inf_lno); + + for (curr++;;curr++) + { + if (*curr == '\n' || *curr == 0) + format_err(inf_lno); + if (*curr == ' ' || *curr == '\t') + continue; + else + break; + } + token = curr; + for (;;curr++) + { + if (*curr == '\n' || *curr == 0) + format_err(inf_lno); + + if (*curr == ' ' || *curr == '\t') + { + *curr = 0; + curr++; + break; + } + else if (*curr == '>') + { + *curr = 0; + curr++; + *curr = '>'; + break; + } + else + { + continue; + } + } + for (;;curr++) + { + if (*curr == '\n' || *curr == 0) + format_err(inf_lno); + + if (*curr == ' ' || *curr == '\t') + continue; + else if (*curr == '>') + break; + else + format_err(inf_lno); + } + + /* You can write anything after clsing '>' */ + fputc('\n', outf); + if (strcmp(token, "end") == 0) + return; + if (find_match_exclude(token)) + { + make_sgml(0); + } + else if (find_match_include(token)) + { + if (writeflag) + make_sgml(1); + else + make_sgml(0); + } + else { + make_sgml(0); + } + } + else + { + if (writeflag) + fputs(inputline, outf); + else + fputc('\n', outf); + } + } + exit(1); +} + +static void usage(int exitcode) +{ + fprintf(stderr, + "%s -i infile -o outfile [-d i|e ] -D exclude_token -D ... -U include_token -U ...\n", + progname); + exit(exitcode); +} |