1# $Id$
2#
3# This file is part of avahi.
4#
5# avahi is free software; you can redistribute it and/or modify it
6# under the terms of the GNU Lesser General Public License as
7# published by the Free Software Foundation; either version 2 of the
8# License, or (at your option) any later version.
9#
10# avahi is distributed in the hope that it will be useful, but WITHOUT
11# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
13# License for more details.
14#
15# You should have received a copy of the GNU Lesser General Public
16# License along with avahi; if not, write to the Free Software
17# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
18# USA.
19
20AM_CFLAGS=-I$(top_srcdir)
21
22# This cool debug trap works on i386/gcc only
23AM_CFLAGS+='-DDEBUG_TRAP=__asm__("int $$3")'
24
25if HAVE_GOBJECT
26if HAVE_DBUS
27
28avahigobjectincludedir=$(includedir)/avahi-gobject
29
30avahigobjectinclude_HEADERS = \
31	ga-client.h \
32	ga-entry-group.h \
33	ga-enums.h \
34	ga-error.h \
35	ga-record-browser.h \
36	ga-service-browser.h \
37	ga-service-resolver.h
38
39lib_LTLIBRARIES = \
40	libavahi-gobject.la
41
42BUILT_SOURCES = \
43	signals-marshal.list \
44	signals-marshal.h \
45	signals-marshal.c \
46	ga-client-enumtypes.h \
47	ga-client-enumtypes.c  \
48	ga-entry-group-enumtypes.h \
49	ga-entry-group-enumtypes.c  \
50	ga-enums-enumtypes.h \
51	ga-enums-enumtypes.c
52
53CORE_SOURCES = \
54	ga-client.c ga-client.h \
55	ga-entry-group.c ga-entry-group.h \
56	ga-enums.h \
57	ga-error.c ga-error.h \
58	ga-record-browser.c ga-record-browser.h \
59	ga-service-browser.c ga-service-browser.h \
60	ga-service-resolver.c ga-service-resolver.h
61
62libavahi_gobject_la_SOURCES = \
63	$(CORE_SOURCES) \
64	$(BUILT_SOURCES)
65
66libavahi_gobject_la_CFLAGS = $(AM_CFLAGS) $(GOBJECT_CFLAGS)
67libavahi_gobject_la_LIBADD = $(AM_LDADD) ../avahi-common/libavahi-common.la ../avahi-client/libavahi-client.la ../avahi-glib/libavahi-glib.la $(GOBJECT_LIBS)
68libavahi_gobject_la_LDFLAGS = $(AM_LDFLAGS) -version-info $(LIBAVAHI_GOBJECT_VERSION_INFO) -export-symbols-regex '^ga_'
69
70# correctly clean the generated source files
71CLEANFILES = $(BUILT_SOURCES)
72
73dist-hook:
74	$(shell for x in $(BUILT_SOURCES); do rm -f $(distdir)/$$x ; done)
75
76signals-marshal.list: $(CORE_SOURCES) Makefile.am
77	( cd $(srcdir) && \
78	sed -n -e 's/.*_ga_signals_marshal_\([A-Z]*__[A-Z_]*\).*/\1/p' \
79		$(CORE_SOURCES) ) \
80		| sed -e 's/__/:/' -e 'y/_/,/' | sort -u > $@.tmp
81	if cmp -s $@.tmp $@; then \
82		rm $@.tmp; \
83	else \
84		mv $@.tmp $@; \
85	fi
86
87signals-marshal.h: signals-marshal.list
88	glib-genmarshal --header --prefix=_ga_signals_marshal $< > $@
89
90signals-marshal.c: signals-marshal.list
91	glib-genmarshal --body --prefix=_ga_signals_marshal $< > $@
92
93
94# rules for making the glib enum objects
95%-enumtypes.h: %.h Makefile.in
96	glib-mkenums \
97	--fhead "#ifndef __$(shell echo $* | tr [:lower:]- [:upper:]_)_ENUM_TYPES_H__\n#define __$(shell echo $* | tr [:lower:]- [:upper:]_)_ENUM_TYPES_H__\n\n#include <glib-object.h>\n\nG_BEGIN_DECLS\n" \
98	--fprod "/* enumerations from \"@filename@\" */\n" \
99	--vhead "GType @enum_name@_get_type (void);\n#define $(shell echo $* | tr [:lower:]- [:upper:]_ | sed 's/_.*//')_TYPE_@ENUMSHORT@ (@enum_name@_get_type())\n"         \
100	--ftail "G_END_DECLS\n\n#endif /* __$(shell echo $* | tr [:lower:]- [:upper:]_)_ENUM_TYPES_H__ */" \
101	$< > $@
102
103%-enumtypes.c: %.h Makefile.in
104	glib-mkenums \
105	--fhead "#include <$*.h>" \
106	--fprod "\n/* enumerations from \"@filename@\" */" \
107	--vhead "GType\n@enum_name@_get_type (void)\n{\n  static GType etype = 0;\n  if (etype == 0) {\n    static const G@Type@Value values[] = {"     \
108	--vprod "      { @VALUENAME@, \"@VALUENAME@\", \"@VALUENAME@\" }," \
109	--vtail "      { 0, NULL, NULL }\n    };\n    etype = g_@type@_register_static (\"@EnumName@\", values);\n  }\n  return etype;\n}\n" \
110	$< > $@
111
112endif
113endif
114
115indent:
116	indent -brf -nbbo -nbc -ip0 -cs -nbfde -npsl -br -brs -bap -i4 -bs -cdw -ce -npcs -hnl -cli4 -nut -ci8 ga-*.[ch]
117