[json-glib] build: Clean up the build environment



commit 2616938c7c042fced9be197205a535a8b420534e
Author: Emmanuele Bassi <ebassi linux intel com>
Date:   Tue Oct 27 11:57:38 2009 +0000

    build: Clean up the build environment
    
    Some of the rules can be moved into their own files to be included
    when needed, like:
    
      â?¢ silent rules (QUIET_*)
      â?¢ glib-mkenums rules
      â?¢ glib-genmarshal rules
    
    Also, the test suite rules should be moved from the top-level of
    the project into the build/autotools directory and then included
    only where it makes sense.
    
    This requires changing most of the build system to use the new
    files layout.

 .gitignore                                         |    4 +-
 Makefile.am                                        |    5 +-
 build/Makefile.am                                  |   12 ++-
 build/autotools/Makefile.am                        |   21 ++++-
 build/autotools/Makefile.am.enums                  |   43 ++++++++++
 Makefile.decl => build/autotools/Makefile.am.gtest |    0
 build/autotools/Makefile.am.marshal                |   45 ++++++++++
 build/autotools/Makefile.am.silent                 |   17 ++++
 doc/Makefile.am                                    |   12 ++-
 doc/reference/Makefile.am                          |    5 +-
 json-glib/Makefile.am                              |   88 ++++++--------------
 json-glib/tests/Makefile.am                        |   12 ++-
 tests/Makefile.am                                  |   15 ++--
 13 files changed, 191 insertions(+), 88 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index 53747f3..caf3c70 100644
--- a/.gitignore
+++ b/.gitignore
@@ -31,8 +31,8 @@ json-version.h
 Json-1.0.gir
 Json-1.0.typelib
 *.la
-stamp-json-enum-types.h
-stamp-json-marshal.h
+stamp-enum-types
+stamp-marshal
 array-test
 object-test
 node-test
diff --git a/Makefile.am b/Makefile.am
index 3d9b9df..bfaee05 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,4 +1,5 @@
-include $(top_srcdir)/Makefile.decl
+include $(top_srcdir)/build/autotools/Makefile.am.gtest
+include $(top_srcdir)/build/autotools/Makefile.am.silent
 
 ACLOCAL_AMFLAGS = -I build/autotools
 
@@ -13,7 +14,7 @@ DIST_SUBDIRS = build json-glib doc tests
 pcfiles = json-glib-1.0.pc
 
 json-glib-1.0.pc: json-glib.pc
-	@cp -f $< $@
+	$(QUIET_GEN)cp -f $< $@
 
 pkgconfig_DATA = $(pcfiles)
 pkgconfigdir = $(libdir)/pkgconfig
diff --git a/build/Makefile.am b/build/Makefile.am
index 3606b71..5dce928 100644
--- a/build/Makefile.am
+++ b/build/Makefile.am
@@ -1,3 +1,11 @@
-include $(top_srcdir)/Makefile.decl
-
 SUBDIRS = autotools
+
+test-report:
+	@true
+
+test:
+	@true
+
+check-local: test
+
+.PHONY: test-report test check-local
diff --git a/build/autotools/Makefile.am b/build/autotools/Makefile.am
index 3d18d93..31d36d7 100644
--- a/build/autotools/Makefile.am
+++ b/build/autotools/Makefile.am
@@ -1,10 +1,23 @@
-include $(top_srcdir)/Makefile.decl
-
-EXTRA_DIST += \
+EXTRA_DIST = \
 	shave-libtool.in 	\
 	shave.in 		\
 	shave.m4 		\
 	as-compiler-flag.m4	\
-	introspection.m4
+	introspection.m4	\
+	Makefile.am.silent	\
+	Makefile.am.enums	\
+	Makefile.am.marshal	\
+	Makefile.am.gtest
 
 DISTCLEANFILES = shave-libtool shave
+
+# needed to avoid including Makefile.am.gtest
+test-report:
+	@true
+
+test:
+	@true
+
+check-local: test
+
+.PHONY: test test-report check-local
diff --git a/build/autotools/Makefile.am.enums b/build/autotools/Makefile.am.enums
new file mode 100644
index 0000000..67f4de0
--- /dev/null
+++ b/build/autotools/Makefile.am.enums
@@ -0,0 +1,43 @@
+# Rules for generating enumeration types using glib-mkenums
+#
+# Define:
+# 	glib_enum_h = header template file
+# 	glib_enum_c = source template file
+# 	glib_enum_headers = list of headers to parse
+#
+# before including Makefile.am.enums. You will also need to have
+# the following targets already defined:
+#
+# 	CLEANFILES
+#	DISTCLEANFILES
+#	BUILT_SOURCES
+#	EXTRA_DIST
+#
+# Author: Emmanuele Bassi <ebassi linux intel com>
+
+enum_tmpl_h=$(glib_enum_h:.h=.h.in)
+enum_tmpl_c=$(glib_enum_c:.c=.c.in)
+
+CLEANFILES += stamp-enum-types
+DISTCLEANFILES += $(glib_enum_h) $(glib_enum_c)
+BUILT_SOURCES += $(glib_enum_h) $(glib_enum_c)
+EXTRA_DIST += $(srcdir)/$(enum_tmpl_h) $(srcdir)/$(enum_tmpl_c)
+
+stamp-enum-types: $(glib_enum_headers)
+	$(QUIET_GEN)$(GLIB_MKENUMS) \
+		--template $(srcdir)/$(enum_tmpl_h) \
+	$(glib_enum_headers) > xgen-eh \
+	&& (cmp -s xgen-eh $(glib_enum_h) || cp -f xgen-eh $(glib_enum_h)) \
+	&& rm -f xgen-eh \
+	&& echo timestamp > $(@F)
+
+$(glib_enum_h): stamp-enum-types
+	@true
+
+$(glib_enum_c): $(glib_enum_h)
+	$(QUIET_GEN)$(GLIB_MKENUMS) \
+		--template $(srcdir)/$(enum_tmpl_c) \
+	$(glib_enum_headers) > xgen-ec \
+	&& cp -f xgen-ec $(glib_enum_c) \
+	&& rm -f xgen-ec
+
diff --git a/Makefile.decl b/build/autotools/Makefile.am.gtest
similarity index 100%
rename from Makefile.decl
rename to build/autotools/Makefile.am.gtest
diff --git a/build/autotools/Makefile.am.marshal b/build/autotools/Makefile.am.marshal
new file mode 100644
index 0000000..cab117d
--- /dev/null
+++ b/build/autotools/Makefile.am.marshal
@@ -0,0 +1,45 @@
+# Rules for generating marshal files using glib-genmarshal
+#
+# Define:
+# 	glib_marshal_list = marshal list file
+# 	glib_marshal_prefix = prefix for marshal functions
+#
+# before including Makefile.am.marshal. You will also need to have
+# the following targets already defined:
+#
+# 	CLEANFILES
+#	DISTCLEANFILES
+#	BUILT_SOURCES
+#	EXTRA_DIST
+#
+# Author: Emmanuele Bassi <ebassi linux intel com>
+
+marshal_h = $(glib_marshal_list:.list=.h)
+marshal_c = $(glib_marshal_list:.list=.c)
+
+CLEANFILES += stamp-marshal
+DISTCLEANFILES += $(marshal_h) $(marshal_c)
+BUILT_SOURCES += $(marshal_h) $(marshal_c)
+EXTRA_DIST += $(srcdir)/$(glib_marshal_list)
+
+stamp-marshal: $(glib_marshal_list)
+	$(QUIET_GEN)$(GLIB_GENMARSHAL) \
+		--prefix=$(glib_marshal_prefix) \
+		--header \
+	$(srcdir)/$(glib_marshal_list) > xgen-mh \
+	&& (cmp -s xgen-mh $(marshal_h) || cp -f xgen-mh $(marshal_h)) \
+	&& rm -f xgen-mh \
+	&& echo timestamp > $(@F)
+
+$(marshal_h): stamp-marshal
+	@true
+
+$(marshal_c): $(marshal_h)
+	$(QUIET_GEN)(echo "#include \"$(marshal_h)\"" ; \
+	$(GLIB_GENMARSHAL) \
+		--prefix=$(glib_marshal_prefix) \
+		--body \
+	$(srcdir)/$(glib_marshal_list)) > xgen-mc \
+	&& cp xgen-mc $(marshal_c) \
+	&& rm -f xgen-mc
+
diff --git a/build/autotools/Makefile.am.silent b/build/autotools/Makefile.am.silent
new file mode 100644
index 0000000..249f6af
--- /dev/null
+++ b/build/autotools/Makefile.am.silent
@@ -0,0 +1,17 @@
+# custom rules for quiet builds
+
+if USE_SHAVE
+QUIET_GEN = $(Q:@= echo '  GEN   '$@;)
+QUIET_LN  = $(Q:@= echo '  LN    '$@;)
+QUIET_RM  = $(Q:@= echo '  RM    '$@;)
+else
+QUIET_GEN = $(AM_V_GEN)
+
+QUIET_LN   = $(QUIET_LN_$(V))
+QUIET_LN_  = $(QUIET_LN_$(AM_DEFAULT_VERBOSITY))
+QUIET_LN_0 = @echo '  LN     '$@;
+
+QUIET_RM   = $(QUIET_RM_$(V))
+QUIET_RM_  = $(QUIET_RM_$(AM_DEFAULT_VERBOSITY))
+QUIET_RM_0 = @echo '  RM     '$@;
+endif # USE_SHAVE
diff --git a/doc/Makefile.am b/doc/Makefile.am
index 3fe3167..fd91f01 100644
--- a/doc/Makefile.am
+++ b/doc/Makefile.am
@@ -1,3 +1,11 @@
-include $(top_srcdir)/Makefile.decl
-
 SUBDIRS = reference
+
+test-report:
+	@true
+
+test:
+	@true
+
+check-local: test
+
+.PHONY: test-report test check-local
diff --git a/doc/reference/Makefile.am b/doc/reference/Makefile.am
index b3db6b4..d4df2e1 100644
--- a/doc/reference/Makefile.am
+++ b/doc/reference/Makefile.am
@@ -78,8 +78,9 @@ expand_content_files =
 INCLUDES = -I$(top_srcdir) -I$(top_builddir) $(JSON_CFLAGS)
 GTKDOC_LIBS = $(top_builddir)/json-glib/libjson-glib-1.0.la $(JSON_LIBS)
 
-# needed to avoid including $(top_srcdir)/Makefile.decls which redeclares
-# EXTRA_DIST and generates a warning when the gtk-doc.make include below
+# needed to avoid including Makefile.am.gtest which redeclares
+# EXTRA_DIST and generates a warning when the gtk-doc.make include
+# below
 test-report:
 	@true
 
diff --git a/json-glib/Makefile.am b/json-glib/Makefile.am
index 5f29b94..887eb5c 100644
--- a/json-glib/Makefile.am
+++ b/json-glib/Makefile.am
@@ -1,12 +1,8 @@
-include $(top_srcdir)/Makefile.decl
-
-if USE_SHAVE
-QUIET_GEN = $(Q:@= echo '  GEN   '$@;)
-else
-QUIET_GEN = $(AM_V_GEN)
-endif # USE_SHAVE
+include $(top_srcdir)/build/autotools/Makefile.am.gtest
+include $(top_srcdir)/build/autotools/Makefile.am.silent
 
 if ENABLE_GLIB_TEST
+# build this directory *before* the tests/
 SUBDIRS = . tests
 endif
 
@@ -14,14 +10,7 @@ DIST_SUBDIRS = tests
 
 NULL =
 
-INCLUDES = \
-	-I$(top_srcdir) 		\
-	-DPREFIX=\""$(prefix)"\" 	\
-	-DLIBDIR=\""$(libdir)"\" 	\
-	-DJSON_COMPILATION=1		\
-	-DG_DISABLE_DEPRECATED 		\
-	-DG_LOG_DOMAIN=\"Json\" 	\
-	$(NULL)
+INCLUDES = -I$(top_srcdir)
 
 LDADD = \
 	$(JSON_LT_LDFLAGS) \
@@ -29,11 +18,20 @@ LDADD = \
 	-export-symbols-regex "^json.*" \
 	-rpath $(libdir)
 
-AM_CPPFLAGS = $(JSON_CFLAGS) $(JSON_DEBUG_CFLAGS) $(MAINTAINER_CFLAGS)
+AM_CPPFLAGS = \
+	-DPREFIX=\""$(prefix)"\" 	\
+	-DLIBDIR=\""$(libdir)"\" 	\
+	-DJSON_COMPILATION=1		\
+	-DG_DISABLE_DEPRECATED 		\
+	-DG_LOG_DOMAIN=\"Json\" 	\
+	$(JSON_DEBUG_CFLAGS) 		\
+	$(NULL)
 
-BUILT_SOURCES = json-marshal.h json-marshal.c json-enum-types.h json-enum-types.c
+AM_CFLAGS = $(JSON_CFLAGS) $(MAINTAINER_CFLAGS)
+BUILT_SOURCES =
 
-STAMP_FILES = stamp-json-marshal.h stamp-json-enum-types.h
+CLEANFILES =
+DISTCLEANFILES = json-version.h
 
 source_h = \
 	$(top_srcdir)/json-glib/json-generator.h 	\
@@ -57,42 +55,16 @@ source_c = \
 	$(srcdir)/json-scanner.c 	\
 	$(NULL)
 
-json-marshal.h: stamp-json-marshal.h
-	@true
-stamp-json-marshal.h: Makefile json-marshal.list
-	$(QUIET_GEN)$(GLIB_GENMARSHAL) \
-		--prefix=_json_marshal \
-		--header \
-	$(srcdir)/json-marshal.list > xgen-jmh \
-	&& (cmp -s xgen-jmh json-marshal.h || cp -f xgen-jmh json-marshal.h) \
-	&& rm -f xgen-jmh \
-	&& echo timestamp > $(@F)
-
-json-marshal.c: Makefile json-marshal.list
-	$(QUIET_GEN)(echo "#include \"json-marshal.h\"" ; \
-	  $(GLIB_GENMARSHAL) \
-		--prefix=_json_marshal \
-		--body \
-	  $(srcdir)/json-marshal.list ) > xgen-jmc \
-	&& cp -f xgen-jmc json-marshal.c \
-	&& rm -f xgen-jmc
-
-json-enum-types.h: stamp-json-enum-types.h
-	@true
-stamp-json-enum-types.h: $(source_h) Makefile
-	$(QUIET_GEN)$(GLIB_MKENUMS) \
-		--template $(srcdir)/json-enum-types.h.in \
-	$(source_h) > xgen-ceth \
-	&& (cmp -s xgen-ceth json-enum-types.h || cp xgen-ceth json-enum-types.h) \
-	&& rm -f xgen-ceth \
-	&& echo timestamp > $(@F)
-
-json-enum-types.c: json-enum-types.h
-	$(QUIET_GEN)$(GLIB_MKENUMS) \
-		--template $(srcdir)/json-enum-types.c.in \
-	$(source_h) > xgen-cetc \
-	&& cp xgen-cetc json-enum-types.c \
-	&& rm -f xgen-cetc
+# glib-mkenums rules
+glib_enum_h = json-enum-types.h
+glib_enum_c = json-enum-types.c
+glib_enum_headers = $(source_h)
+include $(top_srcdir)/build/autotools/Makefile.am.enums
+
+# glib-genmarshal rules
+glib_marshal_list = json-marshal.list
+glib_marshal_prefix = _json_marshal
+include $(top_srcdir)/build/autotools/Makefile.am.marshal
 
 lib_LTLIBRARIES = libjson-glib-1.0.la
 
@@ -113,18 +85,11 @@ jsoninclude_DATA = \
 	$(top_srcdir)/json-glib/json-glib.h		\
 	$(NULL)
 
-CLEANFILES = $(STAMP_FILES) $(BUILT_SOURCES)
-
-DISTCLEANFILES = json-version.h
-
 EXTRA_DIST += \
 	json-version.h.in 	\
 	json-types-private.h	\
 	json-scanner.h 		\
 	json-glib.h 		\
-	json-marshal.list 	\
-	json-enum-types.h.in 	\
-	json-enum-types.c.in	\
 	$(NULL)
 
 TESTS_ENVIRONMENT = srcdir="$(srcdir)" json_all_c_sources="$(source_c)"
@@ -136,6 +101,7 @@ Json-1.0.gir: $(INTROSPECTION_SCANNER) libjson-glib-1.0.la
 	$(QUIET_GEN)$(INTROSPECTION_SCANNER) \
 		-v --namespace Json --nsversion=1.0 \
 		$(INCLUDES) \
+		$(AM_CPPFLAGS) \
 		--c-include='json-glib/json-object.h' \
 		--include=GObject-2.0 \
 		--library=json-glib-1.0 \
diff --git a/json-glib/tests/Makefile.am b/json-glib/tests/Makefile.am
index 31e46d4..d26f085 100644
--- a/json-glib/tests/Makefile.am
+++ b/json-glib/tests/Makefile.am
@@ -1,11 +1,15 @@
-include $(top_srcdir)/Makefile.decl
+include $(top_srcdir)/build/autotools/Makefile.am.gtest
+include $(top_srcdir)/build/autotools/Makefile.am.silent
+
+NULL =
 
 INCLUDES = \
-	-g				\
 	-I$(top_srcdir)			\
 	-I$(top_srcdir)/json-glib	\
-	$(JSON_DEBUG_CFLAGS)		\
-	$(JSON_CFLAGS)
+	$(NULL)
+
+AM_CPPFLAGS = $(JSON_DEBUG_CFLAGS)
+AM_CFLAGS = -g $(JSON_CFLAGS)
 
 noinst_PROGRAMS = $(TEST_PROGS)
 progs_ldadd = $(top_builddir)/json-glib/libjson-glib-1.0.la
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 2ffac99..87f24ac 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1,18 +1,15 @@
-include $(top_srcdir)/Makefile.decl
+include $(top_srcdir)/build/autotools/Makefile.am.gtest
+include $(top_srcdir)/build/autotools/Makefile.am.silent
 
 NULL =
 
 noinst_PROGRAMS = $(TEST_PROGS)
 
-INCLUDES = -I$(top_srcdir) $(JSON_CFLAGS)
-progs_ldadd = $(top_builddir)/json-glib/libjson-glib-1.0.la $(JSON_LIBS)
-
-AM_CPPFLAGS = \
-	-I$(top_srcdir) \
-	-I$(top_srcdir)/json-glib \
-	$(JSON_DEBUG_CFLAGS)
+INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/json-glib
+AM_CFLAGS = -g $(JSON_CFLAGS)
+AM_CPPFLAGS = $(JSON_DEBUG_CFLAGS)
 
-AM_CFLAGS = -g
+progs_ldadd = $(top_builddir)/json-glib/libjson-glib-1.0.la $(JSON_LIBS)
 
 TESTS_ENVIRONMENT = srcdir=$(srcdir)
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]