-*.o
-*.so*
config.*
-
.depends
autom4te.cache
configure
-madtty.pc
-Makefile
--- /dev/null
+DEPTH=.
+include $(DEPTH)/am/header.mk
+
+SUBDIRS = madtty
+
+include $(DEPTH)/am/footer.mk
+# vim:set ft=automake:
--- /dev/null
+ifneq (,$(filter gcc%,$(CC)))
+ _gccversion:=$(shell $(CC) -dumpversion)
+ _gccmachine:=$(shell $(CC) -dumpmachine)
+ _cobjs := .objs-$(_gccmachine:-linux-gnu=)-$(_gccversion)
+
+ # Use pipes and not temp files.
+ CFLAGS += -pipe
+ # optimize even more
+ CFLAGS += -O2
+ # let the type char be unsigned by default
+ CFLAGS += -funsigned-char
+ CFLAGS += -fstrict-aliasing
+ # turn on all common warnings
+ CFLAGS += -Wall
+ # turn on extra warnings
+ CFLAGS += $(if $(filter 4.%,$(GCCVERSION)),-W,-Wextra)
+ # treat warnings as errors
+ CFLAGS += -Werror
+ CFLAGS += -Wchar-subscripts
+ # warn about undefined preprocessor identifiers
+ CFLAGS += -Wundef
+ # warn about local variable shadowing another local variable
+ CFLAGS += -Wshadow
+ # warn about casting of pointers to increased alignment requirements
+ CFLAGS += -Wcast-align
+ # make string constants const
+ CFLAGS += -Wwrite-strings
+ # warn about implicit conversions with side effects
+ # fgets, calloc and friends take an int, not size_t...
+ #CFLAGS += -Wconversion
+ # warn about comparisons between signed and unsigned values
+ CFLAGS += -Wsign-compare
+ # warn about unused declared stuff
+ CFLAGS += -Wunused
+ # don not warn about unused return value
+ CFLAGS += -Wno-unused-value
+ # warn about variable use before initialization
+ CFLAGS += -Wuninitialized
+ # warn about pointer arithmetic on void* and function pointers
+ CFLAGS += -Wpointer-arith
+ # warn about multiple declarations
+ CFLAGS += -Wredundant-decls
+ # warn if the format string is not a string literal
+ CFLAGS += -Wformat-nonliteral
+ # do not warn about strftime format with y2k issues
+ CFLAGS += -Wno-format-y2k
+
+ CFLAGS += -I$(DEPTH)
+else
+ CFLAGS += -Wall
+ _cobjs := .objs
+endif
+
+LDFLAGS += -Wl,--warn-common
--- /dev/null
+#[ Rules and Depends ]##################################################{{{#
+
+AUTO_DEPENDS += filter_c
+filter_c = $(addprefix $2/,$(patsubst %.c,%.o,$(filter %.c,$1)))
+
+# this is some ad-hoc last resort dependency method
+%.a: FORCE
+ @$(MAKE) -q -rC $(dir $(@D)) $(_cobjs)/$(@F) || $(MAKE) -rC $(dir $(@D)) $(_cobjs)/$(@F)
+
+# this implicit rule is used to force directory existence, without depending
+# on the directory itself, since its mtime changes too often.
+%/.exists: Makefile $(CONFDIR)/$(wildcard *.mk)
+ @$(RM) -r $*
+ @-mkdir -p $*
+ @touch $@
+# We don't want make to remove these files because of default rules.
+.PRECIOUS: %/.exists
+
+define RULE_C_tpl
+$(_cobjs)/$1/%.o: %.c $(_cobjs)/$1/.exists
+ $(CC) $$(CFLAGS) $$($1_CPPFLAGS) $2 -MMD -MT "$$(@D)/$$*.d $$(@D)/$$*.o" -MF $$(@D)/$$*.d -g -c -o $$@ $$<
+
+$(_cobjs)/$1/%.d: %.c $(_cobjs)/$1/.exists
+ @$(CPP) $$(CFLAGS) $$($1_CPPFLAGS) $2 -MM -MT "$$(@D)/$$*.d $$(@D)/$$*.o" -MF $$(@D)/$$*.d $$<
+
+-include $$(wildcard $(_cobjs)/$1/*.d) /dev/null
+endef
+
+########################################################################}}}#
+#[ Classes ]############################################################{{{#
+
+deps_create = $(foreach f,$(AUTO_DEPENDS),$(call $f,$1,$2))
+
+define CLASS_LIBRARIES_tpl
+all:: $1.so
+
+$1.so: $(_cobjs)/$1/.exists $$(call deps_create,$$($1_SOURCES),$(_cobjs)/$1)
+ $(CC) $$(CFLAGS) $$($1_CPPFLAGS) -fPIC -shared -o $$@ \
+ $$(filter %.o,$$^) $$(LDFLAGS) $$($1_LDFLAGS) $$($1_LIBADD)
+
+$$(eval $$(call RULE_C_tpl,$1,-fPIC $2))
+
+clean::
+ $(RM) $1.so
+endef
+$(foreach l, \
+ $(foreach l,$(filter %_LIBRARIES,$(.VARIABLES)),$($l)), \
+ $(eval $(call CLASS_LIBRARIES_tpl,$l,)))
+
+#define CLASS_EXE_tpl
+#all:: $1
+#$1: $(_cobjs)/$1/.exists $$(call deps_create,$$($1_SOURCES),$(_cobjs)/$1)
+# $(CC) -o $$@ $$(CFLAGS) $$($1_CPPFLAGS) $$(filter %.o,$$^) \
+# $$(LDFLAGS) $$($1_LDFLAGS) $$(filter %.a,$$^)
+#
+#$$(eval $$(call RULE_C_tpl,$1,$2))
+#
+#clean::
+# $(RM) $1
+#endef
+#$(foreach x,$(__EXE__),$(eval $(call CLASS_EXE_tpl,$x,)))
+
+########################################################################}}}#
+#[ Candy ]##############################################################{{{#
+
+echo-root:
+ @echo $(DEPTH)
+
+echo-tags:
+ @echo $(DEPTH)/.tags
+
+ifeq (".","$(DEPTH)")
+tags:
+ ctags -o .$@ --recurse=yes --exclude=.svn --exclude=\*.mk --totals=yes;
+
+distclean clober::
+ $(RM) -f .tags
+else
+tags:
+ $(MAKE) -C $(DEPTH) $@
+endif
+
+.PHONY: tags
+
+########################################################################}}}#
+
+all check clobber distclean::
+ @set -e $(patsubst %,; $(MAKE) -rC % $@,$(SUBDIRS))
+
+CLEAN_RECURSE=1
+clean::
+ $(RM) -r $(_cobjs)
+ @$(if $(CLEAN_RECURSE),$(patsubst %,$(MAKE) -rC % $@;,$(SUBDIRS)))
+
+clobber distclean:: CLEAN_RECURSE=
+clobber distclean:: clean
+ $(RM) -r .objs*
+
+.PHONY: all check clean clobber distclean FORCE
--- /dev/null
+# Disable most default rules
+.SUFFIXES:
+
+# where is admin/ wrt us ?
+CONFDIR := $(dir $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)))
+
+ifeq ("","$(DEPTH)")
+ $(error you have to define DEPTH)
+endif
+
+include $(CONFDIR)/vars.mk
+include $(CONFDIR)/cflags.mk
+
+# trick : make all always be the default target !
+# note that it breaks default Makefile semantics
+all::
--- /dev/null
+CC=@CC@
+CFLAGS=@CFLAGS@
+LDFLAGS=@LDFLAGS@
+
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+bindir=@bindir@
+
AC_SUBST(PACKAGE_NAME)
AC_SUBST(PACKAGE_VERSION)
-AC_CONFIG_SRCDIR([rote.c])
+AC_CONFIG_SRCDIR([madtty/madtty.h])
dnl Checks for programs.
AC_PROG_CC
AC_TYPE_PID_T
AC_TYPE_SIGNAL
-AC_CONFIG_FILES([Makefile madtty.pc])
+AC_CONFIG_FILES([am/vars.mk madtty/madtty.pc])
AC_OUTPUT
--- /dev/null
+DEPTH=..
+include $(DEPTH)/am/header.mk
+
+lib_LIBRARIES = libmadtty
+libmadtty_SOURCES = inject.c inject_csi.c inject_csi.h madtty.h rote.c rote_keymap.c roteprivate.h
+libmadtty_CPPFLAGS = -Wno-error
+libmadtty_LDFLAGS =
+libmadtty_LIBADD =
+
+include $(DEPTH)/am/footer.mk
+
+# vim:set ft=automake:
-# Makefile for libmadtty
-#
-# LICENSE INFORMATION:
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public
-# License as published by the Free Software Foundation; either
-# version 2 of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# General Public License for more details.
-#
-# You should have received a copy of the GNU General Public
-# License along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-#
-# Copyright © 2002-2004 Bruno T. C. de Oliveira
-# Copyright © 2006 Pierre Habouzit
+DEPTH=..
+include $(DEPTH)/admin/header.mk
-SOURCES=$(wildcard *.c)
-HEADERS=$(wildcard *.h)
+__LIB__ = madtty
-OBJECTS=$(patsubst %.c,%.o,$(SOURCES))
+madtty_SOURCES = inject.c inject_csi.c inject_csi.h madtty.h rote.c rote_keymap.c roteprivate.h
MADTTY_VERSION=@PACKAGE_VERSION@
MADTTY_SONAME=libmadtty.so.0
CC=@CC@
-CFLAGS=@CFLAGS@ -Wall -fPIC
+CFLAGS=@CFLAGS@ -Wall -W -fPIC
LIBS=@LIBS@
LDFLAGS=@LDFLAGS@
prefix=@prefix@
includedir=@includedir@
bindir=@bindir@
-all: libmadtty.so.$(MADTTY_VERSION)
+#all: libmadtty.so.$(MADTTY_VERSION)
install: all
mkdir -p $(DESTDIR)$(includedir)/madtty
-include .depends
-clean:
- rm -f *.o .depends libmadtty.so.*
+clean::
+ libmadtty.so.*
-pristine: clean
+distclean::
rm -rf autom4te.cache configure config.status config.log Makefile madtty.pc
-.PHONY: clean all install pristine
-
+include $(DEPTH)/admin/footer.mk