Skip to content

Commit 295330b

Browse files
committed
initial version of autopoint
all autoconf packages that use gnu gettext for translations require a tool called autopoint in order to run `autoreconf -i`, which is the command to generate the configure script from configure.ac. this is often needed to compile git checkouts of applications, because they usually do not have the configure scripts and the other generated files checked into their version control systems. the autopoint tool is called without parameters, and it is required to copy some m4 files into place and generate some other files. this version here was created just by observing which error messages would be thrown after running it and gradually adding functionality. it was tested on a git checkout of weechat, and later on the source tarballs of various packages like glib, and it seemed to work so far. it's very likely that in future new scenarios will show up that require additional files, but what we have right now is a good start. the m4 files were taken from gnu gettext 0.18, and they are all licensed under very liberal conditions. each file has the original copyright header. there's only one m4 file i wrote myself, which is configheader.m4, supplying a macro i couldn't otherwise find in gettext's source code.
1 parent 18f7b98 commit 295330b

35 files changed

+3912
-2
lines changed

Makefile

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ bindir=$(prefix)/bin
33
includedir=$(prefix)/include
44
libdir=$(prefix)/lib
55
sysconfdir=$(prefix)/etc
6+
m4dir=$(prefix)/share/gettext-tiny
67

78
LIBSRC = $(sort $(wildcard libintl/*.c))
89
PROGSRC = $(sort $(wildcard src/*.c))
@@ -17,7 +18,8 @@ HEADERS = libintl.h
1718
ALL_INCLUDES = $(HEADERS)
1819

1920
ALL_LIBS=libintl.a
20-
ALL_TOOLS=msgfmt msgmerge xgettext
21+
ALL_TOOLS=msgfmt msgmerge xgettext autopoint
22+
ALL_M4S=$(sort $(wildcard m4/*.m4))
2123

2224
CFLAGS=-O0 -fPIC
2325

@@ -31,7 +33,7 @@ BUILDCFLAGS=$(CFLAGS)
3133

3234
all: $(ALL_LIBS) $(ALL_TOOLS)
3335

34-
install: $(ALL_LIBS:lib%=$(DESTDIR)$(libdir)/lib%) $(ALL_INCLUDES:%=$(DESTDIR)$(includedir)/%) $(ALL_TOOLS:%=$(DESTDIR)$(bindir)/%)
36+
install: $(ALL_LIBS:lib%=$(DESTDIR)$(libdir)/lib%) $(ALL_INCLUDES:%=$(DESTDIR)$(includedir)/%) $(ALL_TOOLS:%=$(DESTDIR)$(bindir)/%) $(ALL_M4S:%=$(DESTDIR)$(m4dir)/%)
3537

3638
clean:
3739
rm -f $(ALL_LIBS)
@@ -55,6 +57,9 @@ msgfmt: $(OBJS)
5557
xgettext:
5658
cp src/xgettext.sh ./xgettext
5759

60+
autopoint: src/autopoint.in
61+
cat $< | sed 's,@m4dir@,$(m4dir),' > $@
62+
5863
$(DESTDIR)$(libdir)/%.a: %.a
5964
install -D -m 755 $< $@
6065

@@ -64,6 +69,9 @@ $(DESTDIR)$(includedir)/%.h: include/%.h
6469
$(DESTDIR)$(bindir)/%: %
6570
install -D -m 755 $< $@
6671

72+
$(DESTDIR)$(m4dir)/%: %
73+
install -D -m 644 $< $@
74+
6775
.PHONY: all clean install
6876

6977

m4/ansi-c++.m4

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# ansi-c++.m4 serial 1 (gettext-0.12)
2+
dnl Copyright (C) 2002-2003 Free Software Foundation, Inc.
3+
dnl This file is free software; the Free Software Foundation
4+
dnl gives unlimited permission to copy and/or distribute it,
5+
dnl with or without modifications, as long as this notice is preserved.
6+
7+
dnl From Bruno Haible.
8+
9+
# Sets CXX to the name of a sufficiently ANSI C++ compliant compiler,
10+
# or to ":" if none is found.
11+
12+
AC_DEFUN([gt_PROG_ANSI_CXX],
13+
[
14+
AC_CHECK_PROGS(CXX, $CCC g++ c++ gpp aCC CC cxx cc++ cl FCC KCC RCC xlC_r xlC, :)
15+
if test "$CXX" != ":"; then
16+
dnl Use a modified version of AC_PROG_CXX_WORKS that does not exit
17+
dnl upon failure.
18+
AC_MSG_CHECKING([whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) works])
19+
AC_LANG_PUSH(C++)
20+
AC_ARG_VAR([CXX], [C++ compiler command])
21+
AC_ARG_VAR([CXXFLAGS], [C++ compiler flags])
22+
echo 'int main () { return 0; }' > conftest.$ac_ext
23+
if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then
24+
ac_cv_prog_cxx_works=yes
25+
if (./conftest; exit) 2>/dev/null; then
26+
ac_cv_prog_cxx_cross=no
27+
else
28+
ac_cv_prog_cxx_cross=yes
29+
fi
30+
else
31+
ac_cv_prog_cxx_works=no
32+
fi
33+
rm -fr conftest*
34+
AC_LANG_POP(C++)
35+
AC_MSG_RESULT($ac_cv_prog_cxx_works)
36+
if test $ac_cv_prog_cxx_works = no; then
37+
CXX=:
38+
else
39+
dnl Test for namespaces. Both libasprintf and tests/lang-c++ need it.
40+
dnl We don't bother supporting pre-ANSI-C++ compilers.
41+
AC_MSG_CHECKING([whether the C++ compiler supports namespaces])
42+
AC_LANG_PUSH(C++)
43+
cat <<EOF > conftest.$ac_ext
44+
#include <iostream>
45+
namespace test { using namespace std; }
46+
std::ostream* ptr;
47+
int main () { return 0; }
48+
EOF
49+
if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then
50+
gt_cv_prog_cxx_namespaces=yes
51+
else
52+
gt_cv_prog_cxx_namespaces=no
53+
fi
54+
rm -fr conftest*
55+
AC_LANG_POP(C++)
56+
AC_MSG_RESULT($gt_cv_prog_cxx_namespaces)
57+
if test $gt_cv_prog_cxx_namespaces = no; then
58+
CXX=:
59+
fi
60+
fi
61+
fi
62+
])

m4/codeset.m4

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# codeset.m4 serial 4 (gettext-0.18)
2+
dnl Copyright (C) 2000-2002, 2006, 2008-2010 Free Software Foundation, Inc.
3+
dnl This file is free software; the Free Software Foundation
4+
dnl gives unlimited permission to copy and/or distribute it,
5+
dnl with or without modifications, as long as this notice is preserved.
6+
7+
dnl From Bruno Haible.
8+
9+
AC_DEFUN([AM_LANGINFO_CODESET],
10+
[
11+
AC_CACHE_CHECK([for nl_langinfo and CODESET], [am_cv_langinfo_codeset],
12+
[AC_TRY_LINK([#include <langinfo.h>],
13+
[char* cs = nl_langinfo(CODESET); return !cs;],
14+
[am_cv_langinfo_codeset=yes],
15+
[am_cv_langinfo_codeset=no])
16+
])
17+
if test $am_cv_langinfo_codeset = yes; then
18+
AC_DEFINE([HAVE_LANGINFO_CODESET], [1],
19+
[Define if you have <langinfo.h> and nl_langinfo(CODESET).])
20+
fi
21+
])

m4/configheader.m4

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
AC_DEFUN([AM_CONFIG_HEADER], [AC_CONFIG_HEADERS($@)])

m4/fcntl-o.m4

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# fcntl-o.m4 serial 1
2+
dnl Copyright (C) 2006, 2009-2010 Free Software Foundation, Inc.
3+
dnl This file is free software; the Free Software Foundation
4+
dnl gives unlimited permission to copy and/or distribute it,
5+
dnl with or without modifications, as long as this notice is preserved.
6+
7+
dnl Written by Paul Eggert.
8+
9+
# Test whether the flags O_NOATIME and O_NOFOLLOW actually work.
10+
# Define HAVE_WORKING_O_NOATIME to 1 if O_NOATIME works, or to 0 otherwise.
11+
# Define HAVE_WORKING_O_NOFOLLOW to 1 if O_NOFOLLOW works, or to 0 otherwise.
12+
AC_DEFUN([gl_FCNTL_O_FLAGS],
13+
[
14+
dnl Persuade glibc <fcntl.h> to define O_NOATIME and O_NOFOLLOW.
15+
AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
16+
AC_CACHE_CHECK([for working fcntl.h], [gl_cv_header_working_fcntl_h],
17+
[AC_RUN_IFELSE(
18+
[AC_LANG_PROGRAM(
19+
[[#include <sys/types.h>
20+
#include <sys/stat.h>
21+
#include <unistd.h>
22+
#include <fcntl.h>
23+
#ifndef O_NOATIME
24+
#define O_NOATIME 0
25+
#endif
26+
#ifndef O_NOFOLLOW
27+
#define O_NOFOLLOW 0
28+
#endif
29+
static int const constants[] =
30+
{
31+
O_CREAT, O_EXCL, O_NOCTTY, O_TRUNC, O_APPEND,
32+
O_NONBLOCK, O_SYNC, O_ACCMODE, O_RDONLY, O_RDWR, O_WRONLY
33+
};
34+
]],
35+
[[
36+
int status = !constants;
37+
{
38+
static char const sym[] = "conftest.sym";
39+
if (symlink (".", sym) != 0
40+
|| close (open (sym, O_RDONLY | O_NOFOLLOW)) == 0)
41+
status |= 32;
42+
unlink (sym);
43+
}
44+
{
45+
static char const file[] = "confdefs.h";
46+
int fd = open (file, O_RDONLY | O_NOATIME);
47+
char c;
48+
struct stat st0, st1;
49+
if (fd < 0
50+
|| fstat (fd, &st0) != 0
51+
|| sleep (1) != 0
52+
|| read (fd, &c, 1) != 1
53+
|| close (fd) != 0
54+
|| stat (file, &st1) != 0
55+
|| st0.st_atime != st1.st_atime)
56+
status |= 64;
57+
}
58+
return status;]])],
59+
[gl_cv_header_working_fcntl_h=yes],
60+
[case $? in #(
61+
32) gl_cv_header_working_fcntl_h='no (bad O_NOFOLLOW)';; #(
62+
64) gl_cv_header_working_fcntl_h='no (bad O_NOATIME)';; #(
63+
96) gl_cv_header_working_fcntl_h='no (bad O_NOATIME, O_NOFOLLOW)';; #(
64+
*) gl_cv_header_working_fcntl_h='no';;
65+
esac],
66+
[gl_cv_header_working_fcntl_h=cross-compiling])])
67+
68+
case $gl_cv_header_working_fcntl_h in #(
69+
*O_NOATIME* | no | cross-compiling) ac_val=0;; #(
70+
*) ac_val=1;;
71+
esac
72+
AC_DEFINE_UNQUOTED([HAVE_WORKING_O_NOATIME], [$ac_val],
73+
[Define to 1 if O_NOATIME works.])
74+
75+
case $gl_cv_header_working_fcntl_h in #(
76+
*O_NOFOLLOW* | no | cross-compiling) ac_val=0;; #(
77+
*) ac_val=1;;
78+
esac
79+
AC_DEFINE_UNQUOTED([HAVE_WORKING_O_NOFOLLOW], [$ac_val],
80+
[Define to 1 if O_NOFOLLOW works.])
81+
])

0 commit comments

Comments
 (0)