summaryrefslogtreecommitdiff
path: root/build/autotools/Makefile.am.enums
blob: d3dc742b56cc5ad0e14fe2ac7c3651f721a775a6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# 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>

# Basic sanity checks
$(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
DISTCLEANFILES += $(glib_enum_h) $(glib_enum_c)
BUILT_SOURCES += $(glib_enum_h) $(glib_enum_c)
EXTRA_DIST += $(enum_tmpl_h) $(enum_tmpl_c)

stamp-enum-types: $(glib_enum_headers) $(enum_tmpl_h)
	$(AM_V_GEN)$(GLIB_MKENUMS) \
		--template $(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_headers) $(glib_enum_h) $(enum_tmpl_c)
	$(AM_V_GEN)$(GLIB_MKENUMS) \
		--template $(enum_tmpl_c) \
	$(glib_enum_headers) > xgen-ec \
	&& cp -f xgen-ec $(glib_enum_c) \
	&& rm -f xgen-ec