build: Fix up rules for enums and marshallers

• Use addprefix instead of manually concatenating $(srcdir)
• Use AM_V_GEN instead of QUIET_GEN, to avoid inter-dependencies
• Do basic checks on GLIB_MKENUMS and GLIB_GENMARSHAL being defined
• Do checks on the required variables being defined
This commit is contained in:
Emmanuele Bassi 2010-09-07 14:47:59 +01:00
parent d7e5e9247b
commit 368b24b420
2 changed files with 31 additions and 16 deletions

View File

@ -15,17 +15,26 @@
# #
# Author: Emmanuele Bassi <ebassi@linux.intel.com> # Author: Emmanuele Bassi <ebassi@linux.intel.com>
enum_tmpl_h=$(glib_enum_h:.h=.h.in) # Basic sanity checks
enum_tmpl_c=$(glib_enum_c:.c=.c.in) $(if $(GLIB_MKENUMS),,$(error Need to define GLIB_MKENUMS))
$(if $(or $(glib_enum_h), \
$(glib_enum_c)),, \
$(error Need to define glib_enum_h and glib_enum_c))
$(if $(glib_enum_headers),,$(error Need to define glib_enum_headers))
enum_tmpl_h=$(addprefix $(srcdir)/, $(glib_enum_h:.h=.h.in))
enum_tmpl_c=$(addprefix $(srcdir)/, $(glib_enum_c:.c=.c.in))
CLEANFILES += stamp-enum-types CLEANFILES += stamp-enum-types
DISTCLEANFILES += $(glib_enum_h) $(glib_enum_c) DISTCLEANFILES += $(glib_enum_h) $(glib_enum_c)
BUILT_SOURCES += $(glib_enum_h) $(glib_enum_c) BUILT_SOURCES += $(glib_enum_h) $(glib_enum_c)
EXTRA_DIST += $(srcdir)/$(enum_tmpl_h) $(srcdir)/$(enum_tmpl_c) EXTRA_DIST += $(enum_tmpl_h) $(enum_tmpl_c)
stamp-enum-types: $(glib_enum_headers) $(srcdir)/$(enum_tmpl_h) stamp-enum-types: $(glib_enum_headers) $(enum_tmpl_h)
$(QUIET_GEN)$(GLIB_MKENUMS) \ $(AM_V_GEN)$(GLIB_MKENUMS) \
--template $(srcdir)/$(enum_tmpl_h) \ --template $(enum_tmpl_h) \
$(glib_enum_headers) > xgen-eh \ $(glib_enum_headers) > xgen-eh \
&& (cmp -s xgen-eh $(glib_enum_h) || cp -f xgen-eh $(glib_enum_h)) \ && (cmp -s xgen-eh $(glib_enum_h) || cp -f xgen-eh $(glib_enum_h)) \
&& rm -f xgen-eh \ && rm -f xgen-eh \
@ -34,10 +43,9 @@ stamp-enum-types: $(glib_enum_headers) $(srcdir)/$(enum_tmpl_h)
$(glib_enum_h): stamp-enum-types $(glib_enum_h): stamp-enum-types
@true @true
$(glib_enum_c): $(glib_enum_headers) $(glib_enum_h) $(srcdir)/$(enum_tmpl_c) $(glib_enum_c): $(glib_enum_headers) $(glib_enum_h) $(enum_tmpl_c)
$(QUIET_GEN)$(GLIB_MKENUMS) \ $(QUIET_GEN)$(GLIB_MKENUMS) \
--template $(srcdir)/$(enum_tmpl_c) \ --template $(enum_tmpl_c) \
$(glib_enum_headers) > xgen-ec \ $(glib_enum_headers) > xgen-ec \
&& cp -f xgen-ec $(glib_enum_c) \ && cp -f xgen-ec $(glib_enum_c) \
&& rm -f xgen-ec && rm -f xgen-ec

View File

@ -14,19 +14,27 @@
# #
# Author: Emmanuele Bassi <ebassi@linux.intel.com> # Author: Emmanuele Bassi <ebassi@linux.intel.com>
# Basic sanity checks
$(if $(GLIB_GENMARSHAL),,$(error Need to define GLIB_GENMARSHAL))
$(if $(or $(glib_marshal_list), \
$(glib_marshal_prefix)),, \
$(error Need to define glib_marshal_list and glib_marshal_prefix))
marshal_h = $(glib_marshal_list:.list=.h) marshal_h = $(glib_marshal_list:.list=.h)
marshal_c = $(glib_marshal_list:.list=.c) marshal_c = $(glib_marshal_list:.list=.c)
marshal_list = $(addprefix $(srcdir)/, $(glib_marshal_list))
CLEANFILES += stamp-marshal CLEANFILES += stamp-marshal
DISTCLEANFILES += $(marshal_h) $(marshal_c) DISTCLEANFILES += $(marshal_h) $(marshal_c)
BUILT_SOURCES += $(marshal_h) $(marshal_c) BUILT_SOURCES += $(marshal_h) $(marshal_c)
EXTRA_DIST += $(srcdir)/$(glib_marshal_list) EXTRA_DIST += $(marshal_list)
stamp-marshal: $(glib_marshal_list) stamp-marshal: $(marshal_list)
$(QUIET_GEN)$(GLIB_GENMARSHAL) \ $(AM_V_GEN)$(GLIB_GENMARSHAL) \
--prefix=$(glib_marshal_prefix) \ --prefix=$(glib_marshal_prefix) \
--header \ --header \
$(srcdir)/$(glib_marshal_list) > xgen-mh \ $(marshal_list) > xgen-mh \
&& (cmp -s xgen-mh $(marshal_h) || cp -f xgen-mh $(marshal_h)) \ && (cmp -s xgen-mh $(marshal_h) || cp -f xgen-mh $(marshal_h)) \
&& rm -f xgen-mh \ && rm -f xgen-mh \
&& echo timestamp > $(@F) && echo timestamp > $(@F)
@ -35,11 +43,10 @@ $(marshal_h): stamp-marshal
@true @true
$(marshal_c): $(marshal_h) $(marshal_c): $(marshal_h)
$(QUIET_GEN)(echo "#include \"$(marshal_h)\"" ; \ $(AM_V_GEN)(echo "#include \"$(marshal_h)\"" ; \
$(GLIB_GENMARSHAL) \ $(GLIB_GENMARSHAL) \
--prefix=$(glib_marshal_prefix) \ --prefix=$(glib_marshal_prefix) \
--body \ --body \
$(srcdir)/$(glib_marshal_list)) > xgen-mc \ $(marshal_list)) > xgen-mc \
&& cp xgen-mc $(marshal_c) \ && cp xgen-mc $(marshal_c) \
&& rm -f xgen-mc && rm -f xgen-mc