From fcbd5f6835f65055d0ac14d3a2da3afb39634fd3 Mon Sep 17 00:00:00 2001 From: Pierre Habouzit Date: Fri, 10 Nov 2006 23:04:52 +0100 Subject: [PATCH] use my nice build system rather than custom makefiles Signed-off-by: Pierre Habouzit --- .gitignore | 5 -- Makefile | 7 ++ am/.gitignore | 1 + am/cflags.mk | 54 +++++++++++++++ am/footer.mk | 99 +++++++++++++++++++++++++++ am/header.mk | 16 +++++ am/vars.mk.in | 10 +++ configure.ac | 4 +- madtty/.gitignore | 1 + madtty/Makefile | 12 ++++ Makefile.in => madtty/Makefile.in | 39 +++-------- inject.c => madtty/inject.c | 0 inject_csi.c => madtty/inject_csi.c | 0 inject_csi.h => madtty/inject_csi.h | 0 madtty.h => madtty/madtty.h | 0 madtty.pc.in => madtty/madtty.pc.in | 0 rote.c => madtty/rote.c | 0 rote_keymap.c => madtty/rote_keymap.c | 0 roteprivate.h => madtty/roteprivate.h | 0 19 files changed, 212 insertions(+), 36 deletions(-) create mode 100644 Makefile create mode 100644 am/.gitignore create mode 100644 am/cflags.mk create mode 100644 am/footer.mk create mode 100644 am/header.mk create mode 100644 am/vars.mk.in create mode 100644 madtty/.gitignore create mode 100644 madtty/Makefile rename Makefile.in => madtty/Makefile.in (54%) rename inject.c => madtty/inject.c (100%) rename inject_csi.c => madtty/inject_csi.c (100%) rename inject_csi.h => madtty/inject_csi.h (100%) rename madtty.h => madtty/madtty.h (100%) rename madtty.pc.in => madtty/madtty.pc.in (100%) rename rote.c => madtty/rote.c (100%) rename rote_keymap.c => madtty/rote_keymap.c (100%) rename roteprivate.h => madtty/roteprivate.h (100%) diff --git a/.gitignore b/.gitignore index 12c0349..a48f4ca 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,4 @@ -*.o -*.so* config.* - .depends autom4te.cache configure -madtty.pc -Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..e36fd9f --- /dev/null +++ b/Makefile @@ -0,0 +1,7 @@ +DEPTH=. +include $(DEPTH)/am/header.mk + +SUBDIRS = madtty + +include $(DEPTH)/am/footer.mk +# vim:set ft=automake: diff --git a/am/.gitignore b/am/.gitignore new file mode 100644 index 0000000..05c6144 --- /dev/null +++ b/am/.gitignore @@ -0,0 +1 @@ +vars.mk diff --git a/am/cflags.mk b/am/cflags.mk new file mode 100644 index 0000000..cde512c --- /dev/null +++ b/am/cflags.mk @@ -0,0 +1,54 @@ +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 diff --git a/am/footer.mk b/am/footer.mk new file mode 100644 index 0000000..5b935b7 --- /dev/null +++ b/am/footer.mk @@ -0,0 +1,99 @@ +#[ 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 diff --git a/am/header.mk b/am/header.mk new file mode 100644 index 0000000..1309171 --- /dev/null +++ b/am/header.mk @@ -0,0 +1,16 @@ +# 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:: diff --git a/am/vars.mk.in b/am/vars.mk.in new file mode 100644 index 0000000..e0bece1 --- /dev/null +++ b/am/vars.mk.in @@ -0,0 +1,10 @@ +CC=@CC@ +CFLAGS=@CFLAGS@ +LDFLAGS=@LDFLAGS@ + +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ +bindir=@bindir@ + diff --git a/configure.ac b/configure.ac index 29d47f0..4fbfb79 100644 --- a/configure.ac +++ b/configure.ac @@ -5,7 +5,7 @@ AC_INIT([maddty], 0.0.0) 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 @@ -44,6 +44,6 @@ AC_C_INLINE AC_TYPE_PID_T AC_TYPE_SIGNAL -AC_CONFIG_FILES([Makefile madtty.pc]) +AC_CONFIG_FILES([am/vars.mk madtty/madtty.pc]) AC_OUTPUT diff --git a/madtty/.gitignore b/madtty/.gitignore new file mode 100644 index 0000000..9beaa91 --- /dev/null +++ b/madtty/.gitignore @@ -0,0 +1 @@ +madtty.pc diff --git a/madtty/Makefile b/madtty/Makefile new file mode 100644 index 0000000..da4af4c --- /dev/null +++ b/madtty/Makefile @@ -0,0 +1,12 @@ +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: diff --git a/Makefile.in b/madtty/Makefile.in similarity index 54% rename from Makefile.in rename to madtty/Makefile.in index 318c1f4..d2760cd 100644 --- a/Makefile.in +++ b/madtty/Makefile.in @@ -1,33 +1,15 @@ -# 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@ @@ -36,7 +18,7 @@ libdir=@libdir@ includedir=@includedir@ bindir=@bindir@ -all: libmadtty.so.$(MADTTY_VERSION) +#all: libmadtty.so.$(MADTTY_VERSION) install: all mkdir -p $(DESTDIR)$(includedir)/madtty @@ -63,11 +45,10 @@ libmadtty.so.$(MADTTY_VERSION): $(OBJECTS) -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 diff --git a/inject.c b/madtty/inject.c similarity index 100% rename from inject.c rename to madtty/inject.c diff --git a/inject_csi.c b/madtty/inject_csi.c similarity index 100% rename from inject_csi.c rename to madtty/inject_csi.c diff --git a/inject_csi.h b/madtty/inject_csi.h similarity index 100% rename from inject_csi.h rename to madtty/inject_csi.h diff --git a/madtty.h b/madtty/madtty.h similarity index 100% rename from madtty.h rename to madtty/madtty.h diff --git a/madtty.pc.in b/madtty/madtty.pc.in similarity index 100% rename from madtty.pc.in rename to madtty/madtty.pc.in diff --git a/rote.c b/madtty/rote.c similarity index 100% rename from rote.c rename to madtty/rote.c diff --git a/rote_keymap.c b/madtty/rote_keymap.c similarity index 100% rename from rote_keymap.c rename to madtty/rote_keymap.c diff --git a/roteprivate.h b/madtty/roteprivate.h similarity index 100% rename from roteprivate.h rename to madtty/roteprivate.h -- 2.20.1