From 0ea862e426edf62d5ee05178d8709a67ab316145 Mon Sep 17 00:00:00 2001 From: Pierre Habouzit Date: Sat, 11 Nov 2006 00:42:13 +0100 Subject: [PATCH] even more work on the build system --- am/footer.mk | 101 +++++++++++++++++-------------- am/vars.mk.in | 4 ++ configure.ac | 6 +- demo/Makefile | 13 ++++ madtty/.gitignore | 1 + madtty/{Makefile => Makefile.in} | 6 +- 6 files changed, 82 insertions(+), 49 deletions(-) create mode 100644 demo/Makefile rename madtty/{Makefile => Makefile.in} (80%) diff --git a/am/footer.mk b/am/footer.mk index d367017..49a1afd 100644 --- a/am/footer.mk +++ b/am/footer.mk @@ -3,10 +3,6 @@ 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) @@ -31,61 +27,78 @@ endef deps_create = $(foreach f,$(AUTO_DEPENDS),$(call $f,$1,$2)) -install-LIBRARIES/%:: - mkdir -p $($*dir) - cp $($*_LIBRARIES:=.so) $($*dir) +## +## rules for *_PROGRAMS +## + +install-PROGRAMS/%:: + $(if $($*dir),$(INSTALL_DIR) $(DESTDIR)$($*dir)) + $(if $($*dir),$(INSTALL_PROGRAMS) $($*_PROGRAMS:=.so*) $(DESTDIR)$($*dir)) + +define CLASS_PROGRAMS_tpl + all:: $1 + install-PROGRAMS/$2:: $1 + install:: install-PROGRAMS/$2 + + $1: $$(call deps_create,$$($1_SOURCES),$(_cobjs)/$1) + $(CC) $$(CFLAGS) $$($1_CPPFLAGS) -o $$@ $$(filter %.o,$$^) \ + $$(LDFLAGS) $$($1_LDFLAGS) $$($1_LIBADD) + + $$(eval $$(call RULE_C_tpl,$1,)) + + clean:: + $(RM) $1 +endef +$(foreach v,$(filter %_PROGRAMS,$(.VARIABLES)), \ + $(foreach x,$($v),$(eval $(call CLASS_PROGRAMS_tpl,$x,$(v:_PROGRAMS=))))) -uninstall-LIBRARIES/%:: - rm -f $(patsubst %,$($*dir)/%.so,$($*_LIBRARIES)) - rmdir -p $($*dir) || true 2> /dev/null +## +## rules for *_LIBRARIES +## + +install-LIBRARIES/%:: + $(if $($*dir),$(INSTALL_DIR) $(DESTDIR)$($*dir)) + $(if $($*dir),$(INSTALL_DATA) $($*_LIBRARIES:=.so*) $(DESTDIR)$($*dir)) define CLASS_LIBRARIES_tpl -all:: $1.so -install-LIBRARIES/$2:: $1.so + all:: $1.so$$(if $$($1_VERSION),.$$($1_VERSION)) + install-LIBRARIES/$2:: $1.so$$(if $$($1_VERSION),.$$($1_VERSION)) -install:: install-LIBRARIES/$2 -uninstall:: uninstall-LIBRARIES/$2 + install:: install-LIBRARIES/$2 -$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) + $1.so$$(if $$($1_VERSION),.$$($1_VERSION)): $$(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)) + $$(eval $$(call RULE_C_tpl,$1,-fPIC)) -clean:: - $(RM) $1.so + clean:: + $(RM) $1.so* endef $(foreach v,$(filter %_LIBRARIES,$(.VARIABLES)), \ $(foreach x,$($v),$(eval $(call CLASS_LIBRARIES_tpl,$x,$(v:_LIBRARIES=))))) +## +## rules for *_DATA +## + install-DATA/%:: - mkdir -p $($*dir) - cp $($*_DATA) $($*dir) + $(if $($*dir), $(INSTALL_DIR) $(DESTDIR)$($*dir)) + $(if $($*dir), $(INSTALL_DATA) $($*_DATA) $(DESTDIR)$($*dir)) -uninstall-DATA/%:: - rm -f $(patsubst %,$($*dir)/%,$($*_DATA)) - rmdir -p $($*dir) || true 2> /dev/null +install:: $(foreach v,$(filter %_DATA,$(.VARIABLES)),$(patsubst %_DATA,install-DATA/%,$v)) + +## +## rules for *_SCRIPTS +## + +install-SCRIPTS/%:: + $(if $($*dir), $(INSTALL_DIR) $(DESTDIR)$($*dir)) + $(if $($*dir), $(INSTALL_PROGRAMS) $($*_SCRIPTS) $(DESTDIR)$($*dir)) + +install:: $(foreach v,$(filter %_SCRIPTS,$(.VARIABLES)),$(patsubst %_SCRIPTS,install-SCRIPTS/%,$v)) -define CLASS_DATA_tpl -install:: install-DATA/$2 -uninstall:: uninstall-DATA/$2 -endef -$(foreach v,$(filter %_DATA,$(.VARIABLES)), \ - $(foreach x,$($v),$(eval $(call CLASS_DATA_tpl,$x,$(v:_DATA=))))) - -#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 ]##############################################################{{{# diff --git a/am/vars.mk.in b/am/vars.mk.in index e0bece1..fe6bed5 100644 --- a/am/vars.mk.in +++ b/am/vars.mk.in @@ -8,3 +8,7 @@ libdir=@libdir@ includedir=@includedir@ bindir=@bindir@ +INSTALL = install +INSTALL_DIR=$(INSTALL) -d -m 755 +INSTALL_PROGRAM=$(INSTALL) -m 755 +INSTALL_DATA=$(INSTALL) -m 644 diff --git a/configure.ac b/configure.ac index 4fbfb79..9c997d2 100644 --- a/configure.ac +++ b/configure.ac @@ -44,6 +44,8 @@ AC_C_INLINE AC_TYPE_PID_T AC_TYPE_SIGNAL -AC_CONFIG_FILES([am/vars.mk madtty/madtty.pc]) +AC_CONFIG_FILES([am/vars.mk + madtty/madtty.pc + madtty/Makefile +]) AC_OUTPUT - diff --git a/demo/Makefile b/demo/Makefile new file mode 100644 index 0000000..eb7c01a --- /dev/null +++ b/demo/Makefile @@ -0,0 +1,13 @@ +DEPTH=.. +include $(DEPTH)/am/header.mk + +bin_PROGRAMS = boxshell + +boxshell_SOURCES = boxshell.c +boxshell_LDFLAGS = -L../madtty -lmadtty -lncurses -lutil +boxshell_CPPFLAGS = -Wno-error + +include $(DEPTH)/am/footer.mk + +# vim:set ft=automake: + diff --git a/madtty/.gitignore b/madtty/.gitignore index 9beaa91..2f037b1 100644 --- a/madtty/.gitignore +++ b/madtty/.gitignore @@ -1 +1,2 @@ +Makefile madtty.pc diff --git a/madtty/Makefile b/madtty/Makefile.in similarity index 80% rename from madtty/Makefile rename to madtty/Makefile.in index 10e9765..192da9a 100644 --- a/madtty/Makefile +++ b/madtty/Makefile.in @@ -8,10 +8,10 @@ pkgconfig_DATA = madtty.pc 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_CPPFLAGS= -Wno-error libmadtty_LDFLAGS = -Wl,-soname=libmadtty.so.0 -libmadtty_LIBADD = -libmadtty_SONAME = libmad +libmadtty_LIBADD = +libmadtty_VERSION = @PACKAGE_VERSION@ include $(DEPTH)/am/footer.mk -- 2.20.1