From f71b3054cd0111625ef8bf933517a08f07833e06 Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Fri, 31 Dec 2010 22:12:33 +0000 Subject: [PATCH] Switch tmux to use autoconf and automake. Although they suck, they suck less than the alternatives. --- GNUmakefile | 87 ------------- Makefile | 84 ------------- Makefile.am | 227 ++++++++++++++++++++++++++++++++++ autogen.sh | 15 +++ cmd-server-info.c | 4 +- compat.h | 13 +- configure | 303 --------------------------------------------- configure.ac | 305 ++++++++++++++++++++++++++++++++++++++++++++++ tmux.c | 6 +- tmux.h | 4 +- tty-term.c | 8 +- 11 files changed, 561 insertions(+), 495 deletions(-) delete mode 100644 GNUmakefile delete mode 100644 Makefile create mode 100644 Makefile.am create mode 100644 autogen.sh delete mode 100755 configure create mode 100644 configure.ac diff --git a/GNUmakefile b/GNUmakefile deleted file mode 100644 index d40cd6ce..00000000 --- a/GNUmakefile +++ /dev/null @@ -1,87 +0,0 @@ -# $Id: GNUmakefile,v 1.131 2010-12-27 22:13:35 tcunha Exp $ -# -# Copyright (c) 2009 Nicholas Marriott -# -# Permission to use, copy, modify, and distribute this software for any -# purpose with or without fee is hereby granted, provided that the above -# copyright notice and this permission notice appear in all copies. -# -# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -# WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER -# IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING -# OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -# - -.PHONY: clean - -VERSION= 1.5 - -FDEBUG= 1 - -CC?= cc -CFLAGS+= -DBUILD="\"$(VERSION)\"" -LDFLAGS+= -L/usr/local/lib -LIBS+= - -# Sun CC -ifneq ($(shell ($(CC) -V 2>&1|awk '/Sun C/' || true)), ) - CFLAGS+= -erroff=E_EMPTY_DECLARATION - FDEBUG= -endif - -ifdef FDEBUG -CFLAGS+= -g -ggdb -DDEBUG -CFLAGS+= -Wno-long-long -Wall -W -Wnested-externs -Wformat=2 -CFLAGS+= -Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations -CFLAGS+= -Wwrite-strings -Wshadow -Wpointer-arith -Wsign-compare -CFLAGS+= -Wundef -Wbad-function-cast -Winline -Wcast-align -endif - -# This sort of sucks but gets rid of the stupid warning and should work on -# most platforms... -ifeq ($(shell (LC_ALL=C $(CC) -v 2>&1|awk '/gcc version 4|clang/') || true), ) -CPPFLAGS:= -I. -I- $(CPPFLAGS) -else -CPPFLAGS:= -iquote. $(CPPFLAGS) -ifdef FDEBUG -CFLAGS+= -Wno-pointer-sign -endif -endif - -PREFIX?= /usr/local -INSTALL?= install -INSTALLDIR= $(INSTALL) -d -INSTALLBIN= $(INSTALL) -m 555 -INSTALLMAN= $(INSTALL) -m 444 - -SRCS= $(shell echo *.c|LC_ALL=C sed 's|osdep-[a-z0-9]*.c||g') -include config.mk -OBJS= $(patsubst %.c,%.o,$(SRCS)) - -all: tmux - -tmux: $(OBJS) - $(CC) $(LDFLAGS) -o tmux $+ $(LIBS) - -depend: $(SRCS) - $(CC) $(CPPFLAGS) $(CFLAGS) -MM $(SRCS) > .depend - -clean: - rm -f tmux *.o *~ *.core *.log compat/*.o compat/*~ - -clean-depend: - rm -f .depend - -clean-all: clean clean-depend - rm -f config.h config.mk - -install: all - $(INSTALLDIR) $(DESTDIR)$(PREFIX)/bin - $(INSTALLBIN) tmux $(DESTDIR)$(PREFIX)/bin/tmux - $(INSTALLDIR) $(DESTDIR)$(PREFIX)/man/man1 - $(INSTALLMAN) tmux.1 $(DESTDIR)$(PREFIX)/man/man1/tmux.1 - --include .depend diff --git a/Makefile b/Makefile deleted file mode 100644 index e653ca1c..00000000 --- a/Makefile +++ /dev/null @@ -1,84 +0,0 @@ -# $Id: Makefile,v 1.163 2010-12-27 22:13:35 tcunha Exp $ -# -# Copyright (c) 2009 Nicholas Marriott -# -# Permission to use, copy, modify, and distribute this software for any -# purpose with or without fee is hereby granted, provided that the above -# copyright notice and this permission notice appear in all copies. -# -# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -# WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER -# IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING -# OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -# - -.SUFFIXES: .c .o -.PHONY: clean - -VERSION= 1.5 - -FDEBUG= 1 - -CC?= cc -CFLAGS+= -DBUILD="\"$(VERSION)\"" -LDFLAGS+= -L/usr/local/lib -LIBS+= - -.ifdef FDEBUG -CFLAGS+= -g -ggdb -DDEBUG -CFLAGS+= -Wno-long-long -Wall -W -Wnested-externs -Wformat=2 -CFLAGS+= -Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations -CFLAGS+= -Wwrite-strings -Wshadow -Wpointer-arith -Wsign-compare -CFLAGS+= -Wundef -Wbad-function-cast -Winline -Wcast-align -.endif - -# This sort of sucks but gets rid of the stupid warning and should work on -# most platforms... -CCV!= (LC_ALL=C ${CC} -v 2>&1|awk '/gcc version 4|clang/') || true -.if empty(CCV) -CPPFLAGS:= -I. -I- -I/usr/local/include ${CPPFLAGS} -.else -CPPFLAGS:= -iquote. -I/usr/local/include ${CPPFLAGS} -.ifdef FDEBUG -CFLAGS+= -Wno-pointer-sign -.endif -.endif - -PREFIX?= /usr/local -INSTALL?= install -INSTALLDIR= ${INSTALL} -d -INSTALLBIN= ${INSTALL} -m 555 -INSTALLMAN= ${INSTALL} -m 444 - -SRCS!= echo *.c|LC_ALL=C sed 's|osdep-[a-z0-9]*.c||g' -.include "config.mk" -OBJS= ${SRCS:S/.c/.o/} - -.c.o: - ${CC} ${CPPFLAGS} ${CFLAGS} -c ${.IMPSRC} -o ${.TARGET} - -all: tmux - -tmux: ${OBJS} - ${CC} ${LDFLAGS} -o tmux ${OBJS} ${LIBS} - -depend: - mkdep ${CPPFLAGS} ${CFLAGS} ${SRCS:M*.c} - -clean: - rm -f tmux *.o *~ *.core *.log compat/*.o compat/*~ - -clean-depend: - rm -f .depend - -clean-all: clean clean-depend - rm -f config.h config.mk - -install: all - ${INSTALLDIR} ${DESTDIR}${PREFIX}/bin - ${INSTALLBIN} tmux ${DESTDIR}${PREFIX}/bin/ - ${INSTALLDIR} ${DESTDIR}${PREFIX}/man/man1 - ${INSTALLMAN} tmux.1 ${DESTDIR}${PREFIX}/man/man1/ diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 00000000..d1f8ba14 --- /dev/null +++ b/Makefile.am @@ -0,0 +1,227 @@ +# $Id: Makefile.am,v 1.1 2010-12-31 22:12:33 nicm Exp $ + +# Obvious program stuff. +bin_PROGRAMS = tmux +dist_man1_MANS = tmux.1 + +# Distribution tarball options. +EXTRA_DIST = CHANGES FAQ NOTES TODO examples compat array.h compat.h tmux.h +dist-hook: + find $(distdir) -name CVS -type d|xargs rm -Rf + +# glibc as usual does things ass-backwards and hides useful things by default, +# so everyone has to add this. +if IS_GLIBC +CFLAGS += -D_GNU_SOURCE +endif + +# Set flags for gcc. gcc4 whines abouts silly stuff so it needs slightly +# different flags. +if IS_GCC +CFLAGS += -std=c99 +if IS_DEBUG +CFLAGS += -g -ggdb -O0 +CFLAGS += -Wno-long-long -Wall -W -Wnested-externs -Wformat=2 +CFLAGS += -Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations +CFLAGS += -Wwrite-strings -Wshadow -Wpointer-arith -Wsign-compare +CFLAGS += -Wundef -Wbad-function-cast -Winline -Wcast-align +CPPFLAGS += -DDEBUG +endif +if IS_GCC4 +CPPFLAGS += -iquote. -I/usr/local/include +if IS_DEBUG +CFLAGS += -Wno-pointer-sign +endif +else +CPPFLAGS += -I. -I- -I/usr/local/include +endif +endif + +# Set flags for Solaris. +if IS_SUNOS +CPPFLAGS+= -D_XPG4_2 -D__EXTENSIONS__ -D_POSIX_PTHREAD_SEMANTICS +endif + +# Set flags for Sun CC. +if IS_SUNCC +CFLAGS+= -erroff=E_EMPTY_DECLARATION +endif + +# List of sources. +dist_tmux_SOURCES = \ + attributes.c \ + cfg.c \ + client.c \ + clock.c \ + cmd-attach-session.c \ + cmd-bind-key.c \ + cmd-break-pane.c \ + cmd-capture-pane.c \ + cmd-choose-buffer.c \ + cmd-choose-client.c \ + cmd-choose-session.c \ + cmd-choose-window.c \ + cmd-clear-history.c \ + cmd-clock-mode.c \ + cmd-command-prompt.c \ + cmd-confirm-before.c \ + cmd-copy-mode.c \ + cmd-delete-buffer.c \ + cmd-detach-client.c \ + cmd-display-message.c \ + cmd-display-panes.c \ + cmd-find-window.c \ + cmd-generic.c \ + cmd-has-session.c \ + cmd-if-shell.c \ + cmd-join-pane.c \ + cmd-kill-pane.c \ + cmd-kill-server.c \ + cmd-kill-session.c \ + cmd-kill-window.c \ + cmd-last-pane.c \ + cmd-last-window.c \ + cmd-link-window.c \ + cmd-list-buffers.c \ + cmd-list-clients.c \ + cmd-list-commands.c \ + cmd-list-keys.c \ + cmd-list-panes.c \ + cmd-list-sessions.c \ + cmd-list-windows.c \ + cmd-list.c \ + cmd-load-buffer.c \ + cmd-lock-client.c \ + cmd-lock-server.c \ + cmd-lock-session.c \ + cmd-move-window.c \ + cmd-new-session.c \ + cmd-new-window.c \ + cmd-next-layout.c \ + cmd-next-window.c \ + cmd-paste-buffer.c \ + cmd-pipe-pane.c \ + cmd-previous-layout.c \ + cmd-previous-window.c \ + cmd-refresh-client.c \ + cmd-rename-session.c \ + cmd-rename-window.c \ + cmd-resize-pane.c \ + cmd-respawn-window.c \ + cmd-rotate-window.c \ + cmd-run-shell.c \ + cmd-save-buffer.c \ + cmd-select-layout.c \ + cmd-select-pane.c \ + cmd-select-window.c \ + cmd-send-keys.c \ + cmd-send-prefix.c \ + cmd-server-info.c \ + cmd-set-buffer.c \ + cmd-set-environment.c \ + cmd-set-option.c \ + cmd-set-window-option.c \ + cmd-show-buffer.c \ + cmd-show-environment.c \ + cmd-show-messages.c \ + cmd-show-options.c \ + cmd-show-window-options.c \ + cmd-source-file.c \ + cmd-split-window.c \ + cmd-start-server.c \ + cmd-string.c \ + cmd-suspend-client.c \ + cmd-swap-pane.c \ + cmd-swap-window.c \ + cmd-switch-client.c \ + cmd-unbind-key.c \ + cmd-unlink-window.c \ + cmd.c \ + colour.c \ + environ.c \ + grid-utf8.c \ + grid-view.c \ + grid.c \ + input-keys.c \ + input.c \ + job.c \ + key-bindings.c \ + key-string.c \ + layout-custom.c \ + layout-set.c \ + layout-string.c \ + layout.c \ + log.c \ + mode-key.c \ + names.c \ + options.c \ + osdep-@PLATFORM@.c \ + paste.c \ + resize.c \ + screen-redraw.c \ + screen-write.c \ + screen.c \ + server-client.c \ + server-fn.c \ + server-window.c \ + server.c \ + session.c \ + signal.c \ + status.c \ + tmux.c \ + tty-acs.c \ + tty-keys.c \ + tty-term.c \ + tty.c \ + utf8.c \ + window-choose.c \ + window-clock.c \ + window-copy.c \ + window.c \ + xmalloc.c \ + xterm-keys.c +nodist_tmux_SOURCES = + +# Pile in all the compat/ stuff that is needed. +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_CLOSEFROM +nodist_tmux_SOURCES += compat/closefrom.c +endif +if NO_DAEMON +nodist_tmux_SOURCES += compat/daemon.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_ASPRINTF +nodist_tmux_SOURCES += compat/asprintf.c +endif +if NO_FGETLN +nodist_tmux_SOURCES += compat/fgetln.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 diff --git a/autogen.sh b/autogen.sh new file mode 100644 index 00000000..f578a3dd --- /dev/null +++ b/autogen.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +[ -z "$AUTOMAKE_VERSION" ] && export AUTOMAKE_VERSION=1.10 +[ -z "$AUTOCONF_VERSION" ] && export AUTOCONF_VERSION=2.65 + +die() +{ + echo "$@" >&2 + exit 1 +} + +mkdir -p etc +aclocal || die "aclocal failed" +automake --add-missing --force-missing --copy --foreign || die "automake failed" +autoreconf || die "autoreconf failed" diff --git a/cmd-server-info.c b/cmd-server-info.c index aa950330..5140b6bb 100644 --- a/cmd-server-info.c +++ b/cmd-server-info.c @@ -1,4 +1,4 @@ -/* $Id: cmd-server-info.c,v 1.38 2010-12-22 15:36:44 tcunha Exp $ */ +/* $Id: cmd-server-info.c,v 1.39 2010-12-31 22:12:33 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott @@ -69,7 +69,7 @@ cmd_server_info_exec(unused struct cmd *self, struct cmd_ctx *ctx) tim = ctime(&start_time); *strchr(tim, '\n') = '\0'; ctx->print(ctx, - "tmux " BUILD ", pid %ld, started %s", (long) getpid(), tim); + "tmux " VERSION ", pid %ld, started %s", (long) getpid(), tim); ctx->print( ctx, "socket path %s, debug level %d", socket_path, debug_level); if (uname(&un) == 0) { diff --git a/compat.h b/compat.h index 1c279fb2..aeb8bf8b 100644 --- a/compat.h +++ b/compat.h @@ -1,4 +1,4 @@ -/* $Id: compat.h,v 1.31 2010-11-11 20:45:49 nicm Exp $ */ +/* $Id: compat.h,v 1.32 2010-12-31 22:12:33 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -30,7 +30,7 @@ #define __packed __attribute__ ((__packed__)) #endif -#ifndef HAVE_U_INT +#ifndef HAVE_BSD_TYPES typedef uint8_t u_int8_t; typedef uint16_t u_int16_t; typedef uint32_t u_int32_t; @@ -97,8 +97,7 @@ typedef uint64_t u_int64_t; #include #endif -#ifdef HAVE_BROKEN_CMSG_FIRSTHDR -/* CMSG_FIRSTHDR broken on OS X. */ +#ifdef BROKEN_CMSG_FIRSTHDR #undef CMSG_FIRSTHDR #define CMSG_FIRSTHDR(mhdr) \ ((mhdr)->msg_controllen >= sizeof(struct cmsghdr) ? \ @@ -106,9 +105,8 @@ typedef uint64_t u_int64_t; (struct cmsghdr *)NULL) #endif -/* CMSG_ALIGN, CMSG_SPACE, CMSG_LEN missing from Solaris 9. */ #ifndef CMSG_ALIGN -#ifdef __sun +#ifdef _CMSG_DATA_ALIGN #define CMSG_ALIGN _CMSG_DATA_ALIGN #else #define CMSG_ALIGN(len) (((len) + sizeof(long) - 1) & ~(sizeof(long) - 1)) @@ -165,9 +163,6 @@ typedef uint64_t u_int64_t; #ifndef HAVE_CLOSEFROM /* closefrom.c */ -#define HAVE_FCNTL_H -#define HAVE_DIRENT_H -#define HAVE_SYSCONF void closefrom(int); #endif diff --git a/configure b/configure deleted file mode 100755 index 084071dd..00000000 --- a/configure +++ /dev/null @@ -1,303 +0,0 @@ -#!/bin/sh -# $Id: configure,v 1.60 2010-12-30 20:41:07 nicm Exp $ -# -# Copyright (c) 2009 Nicholas Marriott -# -# Permission to use, copy, modify, and distribute this software for any -# purpose with or without fee is hereby granted, provided that the above -# copyright notice and this permission notice appear in all copies. -# -# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -# WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER -# IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING -# OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -# - -TMUX_PLATFORM=${TMUX_PLATFORM:-`uname -s`} - -CONFIG_H=config.h -rm -f $CONFIG_H -echo "/* $TMUX_PLATFORM */" >$CONFIG_H - -CONFIG_MK=config.mk -rm -f $CONFIG_MK -echo "# $TMUX_PLATFORM" >$CONFIG_MK - -cat <>$CONFIG_H -#undef HAVE_ASPRINTF -#undef HAVE_BROKEN_CMSG_FIRSTHDR -#undef HAVE_BROKEN_CURSES_H -#undef HAVE_BZERO -#undef HAVE_CLOSEFROM -#undef HAVE_DAEMON -#undef HAVE_DIRFD -#undef HAVE_FCNTL_CLOSEM -#undef HAVE_FGETLN -#undef HAVE_FORKPTY -#undef HAVE_GETOPT -#undef HAVE_IMSG -#undef HAVE_LIBUTIL_H -#undef HAVE_PATHS_H -#undef HAVE_PROC_PID -#undef HAVE_PROGNAME -#undef HAVE_PTY_H -#undef HAVE_QUEUE_H -#undef HAVE_SETPROCTITLE -#undef HAVE_STDINT_H -#undef HAVE_STRCASESTR -#undef HAVE_STRLCAT -#undef HAVE_STRLCPY -#undef HAVE_STRSEP -#undef HAVE_STRTONUM -#undef HAVE_TREE_H -#undef HAVE_UTIL_H -#undef HAVE_U_INT -#undef HAVE_VIS -EOF - -case $TMUX_PLATFORM in -# ------------------------------------------------------------------------------ - OpenBSD) - cat <>$CONFIG_H -#define HAVE_ASPRINTF -#define HAVE_BITSTRING_H -#define HAVE_BZERO -#define HAVE_CLOSEFROM -#define HAVE_DAEMON -#define HAVE_FGETLN -#define HAVE_FORKPTY -#define HAVE_GETOPT -#define HAVE_IMSG -#define HAVE_PATHS_H -#define HAVE_PROGNAME -#define HAVE_QUEUE_H -#define HAVE_SETENV -#define HAVE_SETPROCTITLE -#define HAVE_STDINT_H -#define HAVE_STRCASESTR -#define HAVE_STRLCAT -#define HAVE_STRLCPY -#define HAVE_STRSEP -#define HAVE_STRTONUM -#define HAVE_TREE_H -#define HAVE_UTIL_H -#define HAVE_U_INT -#define HAVE_VIS -EOF - cat <>$CONFIG_MK -LIBS+= -lcurses -lutil -levent -SRCS+= osdep-openbsd.c -EOF - ;; -# ------------------------------------------------------------------------------ - Linux) - cat <>$CONFIG_H -#define HAVE_ASPRINTF -#define HAVE_BZERO -#define HAVE_DAEMON -#define HAVE_DIRFD -#define HAVE_FORKPTY -#define HAVE_PATHS_H -#define HAVE_PROC_PID -#define HAVE_PROGNAME -#define HAVE_PTY_H -#define HAVE_SETENV -#define HAVE_STDINT_H -#define HAVE_STRCASESTR -#define HAVE_STRSEP -#define HAVE_U_INT -EOF - cat <>$CONFIG_MK -CFLAGS+= -std=c99 -D_GNU_SOURCE -D_POSIX_SOURCE -LIBS+= -lncurses -lutil -levent -lrt -SRCS+= osdep-linux.c \ - compat/closefrom.c \ - compat/fgetln.c \ - compat/strlcat.c \ - compat/strlcpy.c \ - compat/strtonum.c \ - compat/getopt.c \ - compat/vis.c \ - compat/unvis.c \ - compat/imsg-buffer.c \ - compat/imsg.c -EOF - ;; -# ------------------------------------------------------------------------------ - AIX) - cat <>$CONFIG_H -#define HAVE_SETENV -#define HAVE_STDINT_H -EOF - cat <>$CONFIG_MK -LIBS+= -lcurses -levent -SRCS+= osdep-unknown.c \ - compat/asprintf.c \ - compat/closefrom.c \ - compat/daemon.c \ - compat/forkpty-aix.c \ - compat/strcasestr.c \ - compat/strlcat.c \ - compat/strlcpy.c \ - compat/strsep.c \ - compat/strtonum.c \ - compat/fgetln.c \ - compat/getopt.c \ - compat/vis.c \ - compat/unvis.c \ - compat/imsg-buffer.c \ - compat/imsg.c -EOF - ;; -# ------------------------------------------------------------------------------ - SunOS) - cat <>$CONFIG_H -#define HAVE_CLOSEFROM -#define HAVE_STRLCAT -#define HAVE_STRLCPY -EOF - cat <>$CONFIG_MK -CFLAGS+= -D_XPG4_2 -D__EXTENSIONS__ -D_POSIX_PTHREAD_SEMANTICS -LIBS+= -lcurses -lsocket -lnsl -levent -SRCS+= osdep-sunos.c \ - compat/asprintf.c \ - compat/daemon.c \ - compat/fgetln.c \ - compat/forkpty-sunos.c \ - compat/getopt.c \ - compat/setenv.c \ - compat/strcasestr.c \ - compat/strsep.c \ - compat/strtonum.c \ - compat/vis.c \ - compat/unvis.c \ - compat/imsg-buffer.c \ - compat/imsg.c -EOF - ;; -# ------------------------------------------------------------------------------ - Darwin) - cat <>$CONFIG_H -#define HAVE_ASPRINTF -#define HAVE_BROKEN_CMSG_FIRSTHDR -#define HAVE_BZERO -#define HAVE_DAEMON -#define HAVE_DIRFD -#define HAVE_FGETLN -#define HAVE_FORKPTY -#define HAVE_GETOPT -#define HAVE_PATHS_H -#define HAVE_PROC_PID -#define HAVE_PROGNAME -#define HAVE_SETENV -#define HAVE_STDINT_H -#define HAVE_STRCASESTR -#define HAVE_STRLCAT -#define HAVE_STRLCPY -#define HAVE_STRSEP -#define HAVE_UTIL_H -#define HAVE_U_INT -EOF - cat <>$CONFIG_MK -CPPFLAGS+= -I/opt/local/include -LDFLAGS+= -L/opt/local/lib -LIBS+= -lcurses -levent -SRCS+= osdep-darwin.c \ - compat/closefrom.c \ - compat/strtonum.c \ - compat/vis.c \ - compat/unvis.c \ - compat/imsg-buffer.c \ - compat/imsg.c -EOF - ;; -# ------------------------------------------------------------------------------ - FreeBSD|DragonFly) - cat <>$CONFIG_H -#define HAVE_ASPRINTF -#define HAVE_BZERO -#define HAVE_CLOSEFROM -#define HAVE_DAEMON -#define HAVE_FGETLN -#define HAVE_FORKPTY -#define HAVE_GETOPT -#define HAVE_LIBUTIL_H -#define HAVE_PATHS_H -#define HAVE_PROGNAME -#define HAVE_SETENV -#define HAVE_SETPROCTITLE -#define HAVE_STDINT_H -#define HAVE_STRCASESTR -#define HAVE_STRLCAT -#define HAVE_STRLCPY -#define HAVE_STRSEP -#define HAVE_STRTONUM -#define HAVE_U_INT -EOF - cat <>$CONFIG_MK -LIBS+= -lcurses -lutil -levent -SRCS+= osdep-freebsd.c \ - compat/vis.c \ - compat/unvis.c \ - compat/imsg-buffer.c \ - compat/imsg.c -EOF - ;; -# ------------------------------------------------------------------------------ - NetBSD) - cat <>$CONFIG_H -#define HAVE_ASPRINTF -#define HAVE_BZERO -#define HAVE_CLOSEFROM -#define HAVE_DAEMON -#define HAVE_FGETLN -#define HAVE_FORKPTY -#define HAVE_GETOPT -#define HAVE_PATHS_H -#define HAVE_PROGNAME -#define HAVE_SETENV -#define HAVE_SETPROCTITLE -#define HAVE_STDINT_H -#define HAVE_STRCASESTR -#define HAVE_STRLCAT -#define HAVE_STRLCPY -#define HAVE_STRSEP -#define HAVE_UTIL_H -#define HAVE_U_INT -EOF - # NetBSD-6 has its own terminfo implementation - if test -f /lib/libterminfo.so; then - cat <>$CONFIG_MK -LIBS+= -lterminfo -EOF - else - cat <>$CONFIG_MK -CPPFLAGS+= -I/usr/pkg/include -LDFLAGS+= -L/usr/pkg/lib -LIBS+= -lncurses -EOF - cat <>$CONFIG_H -#define HAVE_BROKEN_CURSES_H -EOF - fi - cat <>$CONFIG_MK -LIBS+= -lutil -levent -SRCS+= osdep-netbsd.c \ - compat/strtonum.c \ - compat/vis.c \ - compat/unvis.c \ - compat/imsg-buffer.c \ - compat/imsg.c -EOF - ;; -# ------------------------------------------------------------------------------ - *) - echo Unable to configure for $TMUX_PLATFORM - exit 1 -esac - -echo Configured for $TMUX_PLATFORM -exit 0 diff --git a/configure.ac b/configure.ac new file mode 100644 index 00000000..4d0f1b96 --- /dev/null +++ b/configure.ac @@ -0,0 +1,305 @@ +# $Id: configure.ac,v 1.1 2010-12-31 22:12:33 nicm Exp $ + +# Miscellaneous autofoo bullshit. +AC_INIT(tmux, 1.5) + +AC_CONFIG_AUX_DIR(etc) +AM_INIT_AUTOMAKE([foreign]) + +AC_CANONICAL_HOST + +# Set up the compiler in two different ways and say yes we may want to install. +AC_PROG_CC +AM_PROG_CC_C_O +AC_PROG_INSTALL + +# Check for various headers. Alternatives included from compat.h. +AC_CHECK_HEADERS([ \ + bitstring.h \ + curses.h \ + dirent.h \ + fcntl.h \ + inttypes.h \ + libutil.h \ + ncurses.h \ + ndir.h \ + paths.h \ + pty.h \ + stdint.h \ + sys/dir.h \ + sys/ndir.h \ + sys/tree.h \ + term.h \ + util.h \ +]) + +# Is this a debug build? +AC_ARG_ENABLE(debug, + AC_HELP_STRING(--enable-debug, create a debug build), + found_debug=yes, + found_debug=no) +AM_CONDITIONAL(IS_DEBUG, test "x$found_debug" = xyes) + +# Is this gcc? +AM_CONDITIONAL(IS_GCC, test "x$GCC" = xyes) +AC_MSG_CHECKING(for gcc that whines about -I) +AC_EGREP_CPP(yes, [ + #if __GNUC__ > 3 + yes + #endif + ], + found_gcc4=yes, + found_gcc4=no) +AM_CONDITIONAL(IS_GCC4, test "x$found_gcc4" = xyes) +AC_MSG_RESULT($found_gcc4) + +# Is this Sun CC? +AC_EGREP_CPP(yes, [ + #ifdef __SUNPRO_C + yes + #endif + ], + found_suncc=yes, + found_suncc=no) +AM_CONDITIONAL(IS_SUNCC, test "x$found_suncc" = xyes) + +# Is this glibc? +AC_MSG_CHECKING(for glibc) +AC_EGREP_CPP(yes, [ + #include + #ifdef __GLIBC__ + yes + #endif + ], + found_glibc=yes, + found_glibc=no) +AM_CONDITIONAL(IS_GLIBC, test "x$found_glibc" = xyes) +AC_MSG_RESULT($found_glibc) + +# Look for libevent. +AC_SEARCH_LIBS(event_init, event) + +# Look for curses. +AC_SEARCH_LIBS(setupterm, [terminfo curses ncurses]) + +# Look for networking libraries. +AC_SEARCH_LIBS([inet_ntoa], [nsl]) +AC_SEARCH_LIBS([socket], [socket]) + +# 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) +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) +if test "x$found_daemon" = xyes; then + AC_DEFINE(HAVE_DAEMON) +fi +AM_CONDITIONAL(NO_DAEMON, [test "x$found_daemon" = 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 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 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 strnvis, compat/{vis,unvis}.c used if missing. +AC_CHECK_FUNC(strnvis, found_strnvis=yes, found_strnvis=no) +if test "x$found_strnvis" = xyes; then + AC_DEFINE(HAVE_VIS) +fi +AM_CONDITIONAL(NO_VIS, [test "x$found_strnvis" = 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 + 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 +AM_CONDITIONAL(NO_GETOPT, [test "x$found_getopt" = xno]) + +# Check for some functions that are replaced or omitted. +AC_CHECK_FUNCS([ \ + bzero \ + setproctitle \ + sysconf \ +]) + +# Check for BSD-style integer types. +AC_MSG_CHECKING(for BSD-style unsigned types) +AC_COMPILE_IFELSE([ + #include + #ifdef HAVE_STDINT_H + #include + #else + #include + #endif + int main(void) { + u_int8_t u8; u_int16_t u16; u_int32_t u32; u_int64_t u64; } + ], + [AC_DEFINE(HAVE_BSD_TYPES) AC_MSG_RESULT(yes)], + AC_MSG_RESULT(no)) + +# Look for a suitable queue.h. +AC_CHECK_DECL(TAILQ_PREV, + found_queue_h=yes, + found_queue_h=no, + [#include ]) +AC_CHECK_DECL(TAILQ_REPLACE, + , + found_queue_h=no, + [#include ]) +if test "x$found_queue_h" = xyes; then + AC_DEFINE(HAVE_QUEUE_H) +fi + +# Look for __progname. +AC_MSG_CHECKING(for __progname) +AC_COMPILE_IFELSE([ + extern char *__progname; + int main(void) { const char *cp = __progname; } + ], + [AC_DEFINE(HAVE___PROGNAME) AC_MSG_RESULT(yes)], + AC_MSG_RESULT(no)) + +# Look for fcntl(F_CLOSEM). +AC_CHECK_DECL(F_CLOSEM, + AC_DEFINE(HAVE_FCNTL_CLOSEM), , + [#include ]) + +# Look for /proc/$$. +AC_MSG_CHECKING(for /proc/\$\$) +if test -d /proc/$$; then + AC_DEFINE(HAVE_PROC_PID) + AC_MSG_RESULT(yes) +else + AC_MSG_RESULT(no) +fi + +# Look for /proc/$$/fd. +AC_MSG_CHECKING(for /proc/\$\$/fd) +if test -d /proc/$$/fd; then + AC_DEFINE(HAVE_DIRFD) + AC_MSG_RESULT(yes) +else + AC_MSG_RESULT(no) +fi + +# Figure out the platform for osdep-*.c and forkpty-*.c. +AC_MSG_CHECKING(platform) +case "$host_os" in + *darwin*) + AC_MSG_RESULT(darwin) + AC_DEFINE(BROKEN_CMSG_FIRSTHDR) + PLATFORM=darwin + ;; + *linux*) + AC_MSG_RESULT(linux) + PLATFORM=linux + ;; + *freebsd*|*dragonfly*) + AC_MSG_RESULT(freebsd) + PLATFORM=freebsd + ;; + *netbsd*) + AC_MSG_RESULT(netbsd) + PLATFORM=netbsd + ;; + *openbsd*) + AC_MSG_RESULT(openbsd) + PLATFORM=openbsd + ;; + *sunos*) + AC_MSG_RESULT(sunos) + PLATFORM=sunos + ;; + *) + AC_MSG_RESULT(unknown) + PLATFORM=unknown + ;; +esac +AC_SUBST(PLATFORM) +AM_CONDITIONAL(IS_DARWIN, test "x$PLATFORM" = xdarwin) +AM_CONDITIONAL(IS_LINUX, test "x$PLATFORM" = xlinux) +AM_CONDITIONAL(IS_FREEBSD, test "x$PLATFORM" = xfreebsd) +AM_CONDITIONAL(IS_NETBSD, test "x$PLATFORM" = xnetbsd) +AM_CONDITIONAL(IS_OPENBSD, test "x$PLATFORM" = xopenbsd) +AM_CONDITIONAL(IS_SUNOS, test "x$PLATFORM" = xsunos) +AM_CONDITIONAL(IS_UNKNOWN, test "x$PLATFORM" = xunknown) + +# autoconf should create a Makefile. A shock! +AC_OUTPUT(Makefile) diff --git a/tmux.c b/tmux.c index 9a9d45e3..5f0bbdaf 100644 --- a/tmux.c +++ b/tmux.c @@ -1,4 +1,4 @@ -/* $Id: tmux.c,v 1.230 2010-12-30 22:39:49 tcunha Exp $ */ +/* $Id: tmux.c,v 1.231 2010-12-31 22:12:33 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -54,7 +54,7 @@ __dead void usage(void); void parseenvironment(void); char *makesocketpath(const char *); -#ifndef HAVE_PROGNAME +#ifndef HAVE___PROGNAME char *__progname = (char *) "tmux"; #endif @@ -259,7 +259,7 @@ main(int argc, char **argv) shell_cmd = xstrdup(optarg); break; case 'V': - printf("%s %s\n", __progname, BUILD); + printf("%s %s\n", __progname, VERSION); exit(0); case 'f': if (cfg_file != NULL) diff --git a/tmux.h b/tmux.h index dc843a10..1a307eac 100644 --- a/tmux.h +++ b/tmux.h @@ -1,4 +1,4 @@ -/* $Id: tmux.h,v 1.595 2010-12-31 01:59:47 tcunha Exp $ */ +/* $Id: tmux.h,v 1.596 2010-12-31 22:12:33 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -19,8 +19,6 @@ #ifndef TMUX_H #define TMUX_H -#include "config.h" - #define PROTOCOL_VERSION 6 #include diff --git a/tty-term.c b/tty-term.c index df93768f..6520048d 100644 --- a/tty-term.c +++ b/tty-term.c @@ -1,4 +1,4 @@ -/* $Id: tty-term.c,v 1.43 2010-09-18 15:43:53 tcunha Exp $ */ +/* $Id: tty-term.c,v 1.44 2010-12-31 22:12:33 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott @@ -18,10 +18,10 @@ #include -#ifdef HAVE_BROKEN_CURSES_H -#include -#else +#ifdef HAVE_CURSES_H #include +#else +#include #endif #include #include