summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicholas Marriott <nicholas.marriott@gmail.com>2017-03-22 19:22:32 +0000
committerNicholas Marriott <nicholas.marriott@gmail.com>2017-03-22 19:22:32 +0000
commitc57039bc3d829c16fddb7bc49f2e56f65076b772 (patch)
treea263569dd52f96fbe89f97410237d922e0c9fd5b
parent9c0520f2c52548d0949db172662015a75926ff89 (diff)
Can shorten these by using LIBOBJ.
-rw-r--r--Makefile.am79
-rw-r--r--configure.ac254
2 files changed, 95 insertions, 238 deletions
diff --git a/Makefile.am b/Makefile.am
index 5bdc3093..ff9b77b7 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -14,6 +14,9 @@ dist-hook:
# Preprocessor flags.
AM_CPPFLAGS += @XOPEN_DEFINES@ -DTMUX_CONF="\"$(sysconfdir)/tmux.conf\""
+# Additional object files.
+LDADD = $(LIBOBJS)
+
# Set flags for gcc.
if IS_GCC
AM_CFLAGS += -std=gnu99 -O2
@@ -186,82 +189,16 @@ dist_tmux_SOURCES = \
xterm-keys.c
nodist_tmux_SOURCES = osdep-@PLATFORM@.c
+# Add compat file for forkpty.
+if NEED_FORKPTY
+nodist_tmux_SOURCES += compat/forkpty-@PLATFORM@.c
+endif
+
# Add compat file for utf8proc.
if HAVE_UTF8PROC
nodist_tmux_SOURCES += compat/utf8proc.c
endif
-# Add compat for missing or broken functions.
-if NO_FORKPTY
-nodist_tmux_SOURCES += compat/forkpty-@PLATFORM@.c
-endif
-if NO_IMSG
-nodist_tmux_SOURCES += compat/imsg.c compat/imsg-buffer.c
-endif
-if NO_ERR_H
-nodist_tmux_SOURCES += compat/err.c
-endif
-if NO_CLOSEFROM
-nodist_tmux_SOURCES += compat/closefrom.c
-endif
-if NO_DAEMON
-nodist_tmux_SOURCES += compat/daemon.c
-endif
-if NO_GETPROGNAME
-nodist_tmux_SOURCES += compat/getprogname.c
-endif
-if NO_SETPROCTITLE
-nodist_tmux_SOURCES += compat/setproctitle.c
-endif
-if NO_SETENV
-nodist_tmux_SOURCES += compat/setenv.c
-endif
-if NO_STRLCAT
-nodist_tmux_SOURCES += compat/strlcat.c
-endif
-if NO_STRLCPY
-nodist_tmux_SOURCES += compat/strlcpy.c
-endif
-if NO_STRNLEN
-nodist_tmux_SOURCES += compat/strnlen.c
-endif
-if NO_STRNDUP
-nodist_tmux_SOURCES += compat/strndup.c
-endif
-if NO_ASPRINTF
-nodist_tmux_SOURCES += compat/asprintf.c
-endif
-if NO_FGETLN
-nodist_tmux_SOURCES += compat/fgetln.c
-endif
-if NO_FPARSELN
-nodist_tmux_SOURCES += compat/fparseln.c
-endif
-if NO_GETOPT
-nodist_tmux_SOURCES += compat/getopt.c
-endif
-if NO_STRCASESTR
-nodist_tmux_SOURCES += compat/strcasestr.c
-endif
-if NO_STRSEP
-nodist_tmux_SOURCES += compat/strsep.c
-endif
-if NO_VIS
-nodist_tmux_SOURCES += compat/vis.c compat/unvis.c
-endif
-if NO_STRTONUM
-nodist_tmux_SOURCES += compat/strtonum.c
-endif
-if NO_B64_NTOP
-nodist_tmux_SOURCES += compat/base64.c
-endif
-if NO_CFMAKERAW
-nodist_tmux_SOURCES += compat/cfmakeraw.c
-endif
-if NO_REALLOCARRAY
-nodist_tmux_SOURCES += compat/reallocarray.c
-endif
-
# Install tmux.1 in the right format.
install-exec-hook:
if test x@MANFORMAT@ = xmdoc; then \
diff --git a/configure.ac b/configure.ac
index 11011e7c..32260e41 100644
--- a/configure.ac
+++ b/configure.ac
@@ -4,6 +4,7 @@ AC_INIT(tmux, master)
AC_PREREQ([2.60])
AC_CONFIG_AUX_DIR(etc)
+AC_CONFIG_LIBOBJ_DIR(compat)
AM_INIT_AUTOMAKE([foreign subdir-objects])
AC_CANONICAL_HOST
@@ -83,37 +84,52 @@ AC_EGREP_CPP(
AM_CONDITIONAL(IS_SUNCC, test "x$found_suncc" = xyes)
# Check for various headers. Alternatives included from compat.h.
-AC_CHECK_HEADERS(
- [ \
- bitstring.h \
- dirent.h \
- fcntl.h \
- inttypes.h \
- libutil.h \
- ndir.h \
- paths.h \
- pty.h \
- stdint.h \
- sys/dir.h \
- sys/ndir.h \
- sys/tree.h \
- util.h \
- ]
-)
+AC_CHECK_HEADERS([ \
+ bitstring.h \
+ dirent.h \
+ fcntl.h \
+ inttypes.h \
+ libutil.h \
+ ndir.h \
+ paths.h \
+ pty.h \
+ stdint.h \
+ sys/dir.h \
+ sys/ndir.h \
+ sys/tree.h \
+ util.h \
+])
# Look for library needed for flock.
AC_SEARCH_LIBS(flock, bsd)
-# Check for some functions that are replaced or omitted.
-AC_CHECK_FUNCS(
- [ \
- dirfd \
- flock \
- prctl \
- sysconf \
- cfmakeraw \
- ]
-)
+# Check for functions that are replaced or omitted.
+AC_CHECK_FUNCS([ \
+ dirfd \
+ flock \
+ prctl \
+ sysconf \
+])
+
+# Check for functions with a compatibility implementation.
+AC_REPLACE_FUNCS([ \
+ asprintf \
+ cfmakeraw \
+ closefrom \
+ fgetln \
+ fparseln \
+ getprogname \
+ reallocarray \
+ setenv \
+ setproctitle \
+ strcasestr \
+ strlcat \
+ strlcpy \
+ strndup \
+ strsep \
+ strtonum \
+])
+AC_FUNC_STRNLEN
# Look for clock_gettime. Must come before event_init.
AC_SEARCH_LIBS(clock_gettime, rt)
@@ -296,8 +312,9 @@ fi
if test "x$found_b64_ntop" = xyes; then
AC_DEFINE(HAVE_B64_NTOP)
AC_MSG_RESULT(yes)
+else
+ AC_LIBOBJ(base64)
fi
-AM_CONDITIONAL(NO_B64_NTOP, [test "x$found_b64_ntop" = xno])
# Look for networking libraries.
AC_SEARCH_LIBS(inet_ntoa, nsl)
@@ -351,29 +368,18 @@ AC_CHECK_FUNC(warn, , found_err_h=no)
AC_CHECK_FUNC(warnx, , found_err_h=no)
if test "x$found_err_h" = xyes; then
AC_CHECK_HEADER(err.h, , found_err_h=no)
+else
+ AC_LIBOBJ(err)
fi
-AM_CONDITIONAL(NO_ERR_H, [test "x$found_err_h" = xno])
# Look for imsg in libutil. compat/imsg.c is linked by Makefile.am if missing.
AC_SEARCH_LIBS(imsg_init, util, found_imsg_init=yes, found_imsg_init=no)
if test "x$found_imsg_init" = xyes; then
AC_DEFINE(HAVE_IMSG)
+else
+ AC_LIBOBJ(imsg)
+ AC_LIBOBJ(imsg-buffer)
fi
-AM_CONDITIONAL(NO_IMSG, [test "x$found_imsg_init" = xno])
-
-# Look for forkpty in libutil. compat/forkpty-*.c is linked if not found.
-AC_SEARCH_LIBS(forkpty, util, found_forkpty=yes, found_forkpty=no)
-if test "x$found_forkpty" = xyes; then
- AC_DEFINE(HAVE_FORKPTY)
-fi
-AM_CONDITIONAL(NO_FORKPTY, [test "x$found_forkpty" = xno])
-
-# Look for closefrom, compat/closefrom.c used if missing.
-AC_CHECK_FUNC(closefrom, found_closefrom=yes, found_closefrom=no)
-if test "x$found_closefrom" = xyes; then
- AC_DEFINE(HAVE_CLOSEFROM)
-fi
-AM_CONDITIONAL(NO_CLOSEFROM, [test "x$found_closefrom" = xno])
# Look for daemon, compat/daemon.c used if missing.
AC_CHECK_FUNC(daemon, found_daemon=yes, found_daemon=no)
@@ -388,99 +394,9 @@ AC_CHECK_DECL(
)
if test "x$found_daemon" = xyes; then
AC_DEFINE(HAVE_DAEMON)
+else
+ AC_LIBOBJ(daemon)
fi
-AM_CONDITIONAL(NO_DAEMON, [test "x$found_daemon" = xno])
-
-# Look for getprogname, compat/getprogname.c used if missing.
-AC_CHECK_FUNC(getprogname, found_getprogname=yes, found_getprogname=no)
-if test "x$found_getprogname" = xyes; then
- AC_DEFINE(HAVE_GETPROGNAME)
-fi
-AM_CONDITIONAL(NO_GETPROGNAME, [test "x$found_getprogname" = xno])
-
-# Look for setproctitle, compat/setproctitle.c used if missing.
-AC_CHECK_FUNC(setproctitle, found_setproctitle=yes, found_setproctitle=no)
-if test "x$found_setproctitle" = xyes; then
- AC_DEFINE(HAVE_SETPROCTITLE)
-fi
-AM_CONDITIONAL(NO_SETPROCTITLE, [test "x$found_setproctitle" = xno])
-
-# Look for setenv, compat/setenv.c used if missing.
-AC_CHECK_FUNC(setenv, found_setenv=yes, found_setenv=no)
-if test "x$found_setenv" = xyes; then
- AC_DEFINE(HAVE_SETENV)
-fi
-AM_CONDITIONAL(NO_SETENV, [test "x$found_setenv" = xno])
-
-# Look for strlcpy, compat/strlcpy.c used if missing.
-AC_CHECK_FUNC(strlcpy, found_strlcpy=yes, found_strlcpy=no)
-if test "x$found_strlcpy" = xyes; then
- AC_DEFINE(HAVE_STRLCPY)
-fi
-AM_CONDITIONAL(NO_STRLCPY, [test "x$found_strlcpy" = xno])
-
-# Look for strlcat, compat/strlcat.c used if missing.
-AC_CHECK_FUNC(strlcat, found_strlcat=yes, found_strlcat=no)
-if test "x$found_strlcat" = xyes; then
- AC_DEFINE(HAVE_STRLCAT)
-fi
-AM_CONDITIONAL(NO_STRLCAT, [test "x$found_strlcat" = xno])
-
-# Look for strnlen, compat/strnlen.c used if missing.
-AC_CHECK_FUNC(strnlen, found_strnlen=yes, found_strnlen=no)
-if test "x$found_strnlen" = xyes; then
- AC_DEFINE(HAVE_STRNLEN)
-fi
-AM_CONDITIONAL(NO_STRNLEN, [test "x$found_strnlen" = xno])
-
-# Look for strndup, compat/strndup.c used if missing.
-AC_CHECK_FUNC(strndup, found_strndup=yes, found_strndup=no)
-if test "x$found_strndup" = xyes; then
- AC_DEFINE(HAVE_STRNDUP)
-fi
-AM_CONDITIONAL(NO_STRNDUP, [test "x$found_strndup" = xno])
-
-# Look for asprintf, compat/asprintf.c used if missing.
-AC_CHECK_FUNC(asprintf, found_asprintf=yes, found_asprintf=no)
-if test "x$found_asprintf" = xyes; then
- AC_DEFINE(HAVE_ASPRINTF)
-fi
-AM_CONDITIONAL(NO_ASPRINTF, [test "x$found_asprintf" = xno])
-
-# Look for fgetln, compat/fgetln.c used if missing.
-AC_CHECK_FUNC(fgetln, found_fgetln=yes, found_fgetln=no)
-if test "x$found_fgetln" = xyes; then
- AC_DEFINE(HAVE_FGETLN)
-fi
-AM_CONDITIONAL(NO_FGETLN, [test "x$found_fgetln" = xno])
-
-# Look for fparseln, compat/fparseln.c used if missing.
-AC_CHECK_FUNC(fparseln, found_fparseln=yes, found_fparseln=no)
-if test "x$found_fparseln" = xyes; then
- AC_DEFINE(HAVE_FPARSELN)
-fi
-AM_CONDITIONAL(NO_FPARSELN, [test "x$found_fparseln" = xno])
-
-# Look for strcasestr, compat/strcasestr.c used if missing.
-AC_CHECK_FUNC(strcasestr, found_strcasestr=yes, found_strcasestr=no)
-if test "x$found_strcasestr" = xyes; then
- AC_DEFINE(HAVE_STRCASESTR)
-fi
-AM_CONDITIONAL(NO_STRCASESTR, [test "x$found_strcasestr" = xno])
-
-# Look for strsep, compat/strsep.c used if missing.
-AC_CHECK_FUNC(strsep, found_strsep=yes, found_strsep=no)
-if test "x$found_strsep" = xyes; then
- AC_DEFINE(HAVE_STRSEP)
-fi
-AM_CONDITIONAL(NO_STRSEP, [test "x$found_strsep" = xno])
-
-# Look for strtonum, compat/strtonum.c used if missing.
-AC_CHECK_FUNC(strtonum, found_strtonum=yes, found_strtonum=no)
-if test "x$found_strtonum" = xyes; then
- AC_DEFINE(HAVE_STRTONUM)
-fi
-AM_CONDITIONAL(NO_STRTONUM, [test "x$found_strtonum" = xno])
# Look for stravis, compat/{vis,unvis}.c used if missing.
AC_CHECK_FUNC(stravis, found_stravis=yes, found_stravis=no)
@@ -507,47 +423,51 @@ if test "x$found_stravis" = xyes; then
fi
if test "x$found_stravis" = xyes; then
AC_DEFINE(HAVE_VIS)
+else
+ AC_LIBOBJ(vis)
+ AC_LIBOBJ(unvis)
fi
-AM_CONDITIONAL(NO_VIS, [test "x$found_stravis" = xno])
-
-# Look for cfmakeraw, compat/cfmakeraw.c used if missing.
-AC_CHECK_FUNC(cfmakeraw, found_cfmakeraw=yes, found_cfmakeraw=no)
-if test "x$found_cfmakeraw" = xyes; then
- AC_DEFINE(HAVE_CFMAKERAW)
-fi
-AM_CONDITIONAL(NO_CFMAKERAW, [test "x$found_cfmakeraw" = xno])
-
-# Look for reallocarray, compat/reallocarray.c used if missing.
-AC_CHECK_FUNC(reallocarray, found_reallocarray=yes, found_reallocarray=no)
-if test "x$found_reallocarray" = xyes; then
- AC_DEFINE(HAVE_REALLOCARRAY)
-fi
-AM_CONDITIONAL(NO_REALLOCARRAY, [test "x$found_reallocarray" = xno])
# Look for getopt. glibc's getopt does not enforce argument order and the ways
# of making it do so are stupid, so just use our own instead.
AC_CHECK_FUNC(getopt, found_getopt=yes, found_getopt=no)
-if test "x$found_getopt" != xno; then
+if test "x$found_getopt" != xno; then
+ AC_MSG_CHECKING(if getopt is suitable)
+ AC_EGREP_CPP(
+ yes,
+ [
+ #include <features.h>
+ #ifdef __GLIBC__
+ yes
+ #endif
+ ],
+ [
+ found_getopt=no
+ AC_MSG_RESULT(no)
+ ],
+ AC_MSG_RESULT(yes))
+fi
+if test "x$found_getopt" != xno; then
AC_CHECK_DECLS(
[optarg, optind, optreset],
,
found_getopt=no,
[
#include <unistd.h>
- ]
- )
- if test "x$found_getopt" != xno; then
- AC_MSG_CHECKING(if system getopt should be avoided)
- if test "x$found_glibc" = xyes; then
- found_getopt=no
- AC_MSG_RESULT(yes)
- else
- AC_MSG_RESULT(no)
- AC_DEFINE(HAVE_GETOPT)
- fi
- fi
+ ])
fi
-AM_CONDITIONAL(NO_GETOPT, [test "x$found_getopt" = xno])
+if test "x$found_getopt" != xno; then
+ AC_DEFINE(HAVE_GETOPT)
+else
+ AC_LIBOBJ(getopt)
+fi
+
+# Look for forkpty in libutil. compat/forkpty-*.c is linked if not found.
+AC_SEARCH_LIBS(forkpty, util, found_forkpty=yes, found_forkpty=no)
+if test "x$found_forkpty" = xyes; then
+ AC_DEFINE(HAVE_FORKPTY)
+fi
+AM_CONDITIONAL(NEED_FORKPTY, test "x$found_forkpty" = xno)
# Check for BSD-style integer types.
AC_MSG_CHECKING(for BSD-style unsigned types)
@@ -652,7 +572,7 @@ fi
MANFORMAT=mdoc
AC_SUBST(MANFORMAT)
-# Figure out the platform for osdep-*.c and forkpty-*.c.
+# Figure out the platform.
AC_MSG_CHECKING(platform)
case "$host_os" in
*aix*)
@@ -704,7 +624,7 @@ case "$host_os" in
*)
AC_MSG_RESULT(unknown)
PLATFORM=unknown
- ;;
+ ;;
esac
AC_SUBST(PLATFORM)
AM_CONDITIONAL(IS_AIX, test "x$PLATFORM" = xaix)