Skip to content

Commit

Permalink
initial version of autopoint
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
rofl0r committed Dec 22, 2016
1 parent 18f7b98 commit 295330b
Show file tree
Hide file tree
Showing 35 changed files with 3,912 additions and 2 deletions.
12 changes: 10 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ bindir=$(prefix)/bin
includedir=$(prefix)/include
libdir=$(prefix)/lib
sysconfdir=$(prefix)/etc
m4dir=$(prefix)/share/gettext-tiny

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

ALL_LIBS=libintl.a
ALL_TOOLS=msgfmt msgmerge xgettext
ALL_TOOLS=msgfmt msgmerge xgettext autopoint
ALL_M4S=$(sort $(wildcard m4/*.m4))

CFLAGS=-O0 -fPIC

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

all: $(ALL_LIBS) $(ALL_TOOLS)

install: $(ALL_LIBS:lib%=$(DESTDIR)$(libdir)/lib%) $(ALL_INCLUDES:%=$(DESTDIR)$(includedir)/%) $(ALL_TOOLS:%=$(DESTDIR)$(bindir)/%)
install: $(ALL_LIBS:lib%=$(DESTDIR)$(libdir)/lib%) $(ALL_INCLUDES:%=$(DESTDIR)$(includedir)/%) $(ALL_TOOLS:%=$(DESTDIR)$(bindir)/%) $(ALL_M4S:%=$(DESTDIR)$(m4dir)/%)

clean:
rm -f $(ALL_LIBS)
Expand All @@ -55,6 +57,9 @@ msgfmt: $(OBJS)
xgettext:
cp src/xgettext.sh ./xgettext

autopoint: src/autopoint.in
cat $< | sed 's,@m4dir@,$(m4dir),' > $@

$(DESTDIR)$(libdir)/%.a: %.a
install -D -m 755 $< $@

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

$(DESTDIR)$(m4dir)/%: %
install -D -m 644 $< $@

.PHONY: all clean install


Expand Down
62 changes: 62 additions & 0 deletions m4/ansi-c++.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# ansi-c++.m4 serial 1 (gettext-0.12)
dnl Copyright (C) 2002-2003 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.

dnl From Bruno Haible.

# Sets CXX to the name of a sufficiently ANSI C++ compliant compiler,
# or to ":" if none is found.

AC_DEFUN([gt_PROG_ANSI_CXX],
[
AC_CHECK_PROGS(CXX, $CCC g++ c++ gpp aCC CC cxx cc++ cl FCC KCC RCC xlC_r xlC, :)
if test "$CXX" != ":"; then
dnl Use a modified version of AC_PROG_CXX_WORKS that does not exit
dnl upon failure.
AC_MSG_CHECKING([whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) works])
AC_LANG_PUSH(C++)
AC_ARG_VAR([CXX], [C++ compiler command])
AC_ARG_VAR([CXXFLAGS], [C++ compiler flags])
echo 'int main () { return 0; }' > conftest.$ac_ext
if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then
ac_cv_prog_cxx_works=yes
if (./conftest; exit) 2>/dev/null; then
ac_cv_prog_cxx_cross=no
else
ac_cv_prog_cxx_cross=yes
fi
else
ac_cv_prog_cxx_works=no
fi
rm -fr conftest*
AC_LANG_POP(C++)
AC_MSG_RESULT($ac_cv_prog_cxx_works)
if test $ac_cv_prog_cxx_works = no; then
CXX=:
else
dnl Test for namespaces. Both libasprintf and tests/lang-c++ need it.
dnl We don't bother supporting pre-ANSI-C++ compilers.
AC_MSG_CHECKING([whether the C++ compiler supports namespaces])
AC_LANG_PUSH(C++)
cat <<EOF > conftest.$ac_ext
#include <iostream>
namespace test { using namespace std; }
std::ostream* ptr;
int main () { return 0; }
EOF
if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then
gt_cv_prog_cxx_namespaces=yes
else
gt_cv_prog_cxx_namespaces=no
fi
rm -fr conftest*
AC_LANG_POP(C++)
AC_MSG_RESULT($gt_cv_prog_cxx_namespaces)
if test $gt_cv_prog_cxx_namespaces = no; then
CXX=:
fi
fi
fi
])
21 changes: 21 additions & 0 deletions m4/codeset.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# codeset.m4 serial 4 (gettext-0.18)
dnl Copyright (C) 2000-2002, 2006, 2008-2010 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.

dnl From Bruno Haible.

AC_DEFUN([AM_LANGINFO_CODESET],
[
AC_CACHE_CHECK([for nl_langinfo and CODESET], [am_cv_langinfo_codeset],
[AC_TRY_LINK([#include <langinfo.h>],
[char* cs = nl_langinfo(CODESET); return !cs;],
[am_cv_langinfo_codeset=yes],
[am_cv_langinfo_codeset=no])
])
if test $am_cv_langinfo_codeset = yes; then
AC_DEFINE([HAVE_LANGINFO_CODESET], [1],
[Define if you have <langinfo.h> and nl_langinfo(CODESET).])
fi
])
1 change: 1 addition & 0 deletions m4/configheader.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
AC_DEFUN([AM_CONFIG_HEADER], [AC_CONFIG_HEADERS($@)])
81 changes: 81 additions & 0 deletions m4/fcntl-o.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# fcntl-o.m4 serial 1
dnl Copyright (C) 2006, 2009-2010 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.

dnl Written by Paul Eggert.

# Test whether the flags O_NOATIME and O_NOFOLLOW actually work.
# Define HAVE_WORKING_O_NOATIME to 1 if O_NOATIME works, or to 0 otherwise.
# Define HAVE_WORKING_O_NOFOLLOW to 1 if O_NOFOLLOW works, or to 0 otherwise.
AC_DEFUN([gl_FCNTL_O_FLAGS],
[
dnl Persuade glibc <fcntl.h> to define O_NOATIME and O_NOFOLLOW.
AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
AC_CACHE_CHECK([for working fcntl.h], [gl_cv_header_working_fcntl_h],
[AC_RUN_IFELSE(
[AC_LANG_PROGRAM(
[[#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
#ifndef O_NOATIME
#define O_NOATIME 0
#endif
#ifndef O_NOFOLLOW
#define O_NOFOLLOW 0
#endif
static int const constants[] =
{
O_CREAT, O_EXCL, O_NOCTTY, O_TRUNC, O_APPEND,
O_NONBLOCK, O_SYNC, O_ACCMODE, O_RDONLY, O_RDWR, O_WRONLY
};
]],
[[
int status = !constants;
{
static char const sym[] = "conftest.sym";
if (symlink (".", sym) != 0
|| close (open (sym, O_RDONLY | O_NOFOLLOW)) == 0)
status |= 32;
unlink (sym);
}
{
static char const file[] = "confdefs.h";
int fd = open (file, O_RDONLY | O_NOATIME);
char c;
struct stat st0, st1;
if (fd < 0
|| fstat (fd, &st0) != 0
|| sleep (1) != 0
|| read (fd, &c, 1) != 1
|| close (fd) != 0
|| stat (file, &st1) != 0
|| st0.st_atime != st1.st_atime)
status |= 64;
}
return status;]])],
[gl_cv_header_working_fcntl_h=yes],
[case $? in #(
32) gl_cv_header_working_fcntl_h='no (bad O_NOFOLLOW)';; #(
64) gl_cv_header_working_fcntl_h='no (bad O_NOATIME)';; #(
96) gl_cv_header_working_fcntl_h='no (bad O_NOATIME, O_NOFOLLOW)';; #(
*) gl_cv_header_working_fcntl_h='no';;
esac],
[gl_cv_header_working_fcntl_h=cross-compiling])])
case $gl_cv_header_working_fcntl_h in #(
*O_NOATIME* | no | cross-compiling) ac_val=0;; #(
*) ac_val=1;;
esac
AC_DEFINE_UNQUOTED([HAVE_WORKING_O_NOATIME], [$ac_val],
[Define to 1 if O_NOATIME works.])
case $gl_cv_header_working_fcntl_h in #(
*O_NOFOLLOW* | no | cross-compiling) ac_val=0;; #(
*) ac_val=1;;
esac
AC_DEFINE_UNQUOTED([HAVE_WORKING_O_NOFOLLOW], [$ac_val],
[Define to 1 if O_NOFOLLOW works.])
])
Loading

0 comments on commit 295330b

Please sign in to comment.