From 91241f1457d2391f2885761d5df423eb7a4d893e Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Wed, 29 Apr 2009 23:07:35 +0000 Subject: [PATCH] Apply the make magic wand to pick an osdep-*.c file rather than using ifdefs. --- GNUmakefile | 10 ++++++---- Makefile | 9 +++++---- osdep-darwin.c | 6 +----- osdep-freebsd.c | 6 +----- osdep-linux.c | 6 +----- osdep-netbsd.c | 4 ---- osdep-openbsd.c | 6 +----- osdep-unknown.c | 7 +------ 8 files changed, 16 insertions(+), 38 deletions(-) diff --git a/GNUmakefile b/GNUmakefile index 4eca07e8..3a8a818d 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -1,4 +1,4 @@ -# $Id: GNUmakefile,v 1.88 2009-04-29 22:42:02 nicm Exp $ +# $Id: GNUmakefile,v 1.89 2009-04-29 23:07:35 nicm Exp $ .PHONY: clean @@ -42,9 +42,7 @@ SRCS= tmux.c server.c server-msg.c server-fn.c buffer.c buffer-poll.c status.c \ window-clock.c window-scroll.c window-more.c window-copy.c \ window-choose.c \ options.c options-cmd.c paste.c colour.c utf8.c clock.c \ - tty.c tty-term.c tty-keys.c tty-write.c util.c names.c \ - osdep-unknown.c osdep-openbsd.c osdep-freebsd.c osdep-linux.c \ - osdep-darwin.c attributes.c + tty.c tty-term.c tty-keys.c tty-write.c util.c names.c attributes.c CC?= gcc INCDIRS+= -I. -I- @@ -120,6 +118,10 @@ CFLAGS+= $(shell getconf LFS_CFLAGS) -D_GNU_SOURCE \ LIBS+= -lcrypt -lutil endif +LCOS= $(shell uname|tr '[:upper:]' '[:lower:]') +OSDEP= $(shell [ -f osdep-$(LCOS).c ] && echo $(LCOS) || echo unknown) +SRCS+= osdep-$(OSDEP).c + OBJS= $(patsubst %.c,%.o,$(SRCS)) CLEANFILES= ${PROG} *.o .depend *~ ${PROG}.core *.log compat/*.o index.html diff --git a/Makefile b/Makefile index 651c9d84..6449652e 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile,v 1.126 2009-04-29 22:25:20 nicm Exp $ +# $Id: Makefile,v 1.127 2009-04-29 23:07:35 nicm Exp $ .SUFFIXES: .c .o .y .h .PHONY: clean update-index.html upload-index.html @@ -45,9 +45,7 @@ SRCS= tmux.c server.c server-msg.c server-fn.c buffer.c buffer-poll.c status.c \ window-clock.c window-scroll.c window-more.c window-copy.c \ window-choose.c \ options.c options-cmd.c paste.c colour.c utf8.c clock.c \ - tty.c tty-term.c tty-keys.c tty-write.c util.c names.c attributes.c \ - osdep-unknown.c osdep-openbsd.c osdep-freebsd.c osdep-linux.c \ - osdep-darwin.c osdep-netbsd.c + tty.c tty-term.c tty-keys.c tty-write.c util.c names.c attributes.c CC?= c INCDIRS+= -I. -I- -I/usr/local/include @@ -96,6 +94,9 @@ LIBS+= -lcrypt CFLAGS+=-DNO_STRTONUM -DNO_QUEUE_H .endif +OSDEP!= [ -f osdep-${OS:L}.c ] && echo ${OS:L} || echo unknown +SRCS+= osdep-${OSDEP}.c + OBJS= ${SRCS:S/.c/.o/:S/.y/.o/} DISTDIR= ${PROG}-${VERSION} diff --git a/osdep-darwin.c b/osdep-darwin.c index ae90a512..9a6d6cfc 100644 --- a/osdep-darwin.c +++ b/osdep-darwin.c @@ -1,4 +1,4 @@ -/* $Id: osdep-darwin.c,v 1.9 2009-02-13 00:43:04 nicm Exp $ */ +/* $Id: osdep-darwin.c,v 1.10 2009-04-29 23:07:35 nicm Exp $ */ /* * Copyright (c) 2009 Joshua Elsasser @@ -16,8 +16,6 @@ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#ifdef __APPLE__ - #include #include @@ -47,5 +45,3 @@ osdep_get_name(int fd, unused char *tty) return (strdup(kp.kp_proc.p_comm)); } - -#endif diff --git a/osdep-freebsd.c b/osdep-freebsd.c index 33bd606c..92139565 100644 --- a/osdep-freebsd.c +++ b/osdep-freebsd.c @@ -1,4 +1,4 @@ -/* $Id: osdep-freebsd.c,v 1.14 2009-02-13 00:43:04 nicm Exp $ */ +/* $Id: osdep-freebsd.c,v 1.15 2009-04-29 23:07:35 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott @@ -16,8 +16,6 @@ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#ifdef __FreeBSD__ - #include #include #include @@ -121,5 +119,3 @@ retry: free(buf); return (name); } - -#endif diff --git a/osdep-linux.c b/osdep-linux.c index ccc176d9..c85beb28 100644 --- a/osdep-linux.c +++ b/osdep-linux.c @@ -1,4 +1,4 @@ -/* $Id: osdep-linux.c,v 1.5 2009-02-13 00:43:04 nicm Exp $ */ +/* $Id: osdep-linux.c,v 1.6 2009-04-29 23:07:35 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott @@ -16,8 +16,6 @@ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#ifdef __linux__ - #include #include @@ -59,5 +57,3 @@ osdep_get_name(int fd, unused char *tty) fclose(f); return (buf); } - -#endif diff --git a/osdep-netbsd.c b/osdep-netbsd.c index 927f6cff..96fd892a 100644 --- a/osdep-netbsd.c +++ b/osdep-netbsd.c @@ -14,8 +14,6 @@ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#ifdef __NetBSD__ - #include #include #include @@ -118,5 +116,3 @@ retry: free(buf); return (name); } - -#endif diff --git a/osdep-openbsd.c b/osdep-openbsd.c index 6657a464..243018f2 100644 --- a/osdep-openbsd.c +++ b/osdep-openbsd.c @@ -1,4 +1,4 @@ -/* $Id: osdep-openbsd.c,v 1.14 2009-02-17 18:54:14 nicm Exp $ */ +/* $Id: osdep-openbsd.c,v 1.15 2009-04-29 23:07:35 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott @@ -16,8 +16,6 @@ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#ifdef __OpenBSD__ - #include #include #include @@ -130,5 +128,3 @@ retry: free(buf); return (name); } - -#endif diff --git a/osdep-unknown.c b/osdep-unknown.c index 5370af94..d59a3b53 100644 --- a/osdep-unknown.c +++ b/osdep-unknown.c @@ -1,4 +1,4 @@ -/* $Id: osdep-unknown.c,v 1.4 2009-03-31 21:22:10 nicm Exp $ */ +/* $Id: osdep-unknown.c,v 1.5 2009-04-29 23:07:35 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott @@ -16,9 +16,6 @@ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#if !defined(__OpenBSD__) && !defined(__FreeBSD__) && !defined(__linux__) && \ - !defined(__APPLE__) && !defined(__NetBSD__) - #include #include "tmux.h" @@ -28,5 +25,3 @@ osdep_get_name(unused int fd, unused char *tty) { return (NULL); } - -#endif