001a5822c59eacc26b697a6fe3a6ad3d8b16cd1c
[gnome.gobject-introspection] / tests / scanner / Makefile.am
1 include $(top_srcdir)/common.mk
2
3 # We need to build a shared library, which can be dlopened
4 # it does not work with noinst_LTLIBRARIES
5 testlib_LTLIBRARIES = \
6         libannotation.la \
7         libdrawable.la \
8         libfoo.la \
9         libutility.la \
10         libgtkfrob.la
11 testlibdir = $(prefix)/unused
12 install-testlibLTLIBRARIES: # prevent it from being installed
13
14 AM_CPPFLAGS = -I$(top_srcdir)/girepository
15 AM_CFLAGS = $(GIO_CFLAGS) $(GOBJECT_CFLAGS) $(GTHREAD_CFLAGS)
16 AM_LDFLAGS = -avoid-version
17 LIBS = $(GOBJECT_LIBS) $(GTHREAD_LIBS)
18
19 libannotation_la_SOURCES = $(srcdir)/annotation.c $(srcdir)/annotation.h
20 libdrawable_la_SOURCES = $(srcdir)/drawable.c $(srcdir)/drawable.h
21 libfoo_la_SOURCES = $(srcdir)/foo.c $(srcdir)/foo.h
22 libutility_la_SOURCES = $(srcdir)/utility.c $(srcdir)/utility.h
23 libgtkfrob_la_SOURCES = $(srcdir)/gtkfrob.c $(srcdir)/gtkfrob.h
24
25 if OS_WIN32
26 AM_LDFLAGS += -no-undefined
27 endif
28
29 # .gir --[scanner]-> .typelib --[generate]-> .tgir
30 GIRS =
31 TYPELIBS = $(GIRS:.gir=.typelib)
32 CHECKGIRS = $(GIRS:.gir=.gir.check)
33 EXPECTEDGIRS = $(GIRS:.gir=-expected.gir)
34 TGIRS = $(GIRS:.gir=.tgir)
35 CHECKTGIRS = $(GIRS:.gir=.tgir.check)
36 EXPECTEDTGIRS = $(GIRS:.gir=-expected.tgir)
37 CLEANFILES = $(TYPELIBS)  $(GIRS)
38 BUILT_SOURCES = $(TYPELIBS) $(GIRS) $(TGIRS)
39 EXTRA_DIST = $(EXPECTEDGIRS) $(EXPECTEDTGIRS)
40
41 annotation-1.0.gir: libannotation.la annotation.c annotation.h utility-1.0.gir $(SCANNER_BIN) $(SCANNER_LIBS) Makefile
42          $(CHECK_DEBUG) $(SCANNER) \
43         --include=GObject-2.0 \
44         --include=utility-1.0 \
45         --libtool="$(LIBTOOL)" \
46         --library=libannotation.la \
47         --namespace=annotation \
48         --nsversion=1.0 \
49         --pkg gobject-2.0 \
50         $(srcdir)/annotation.h $(srcdir)/annotation.c \
51          --output $@
52 GIRS += annotation-1.0.gir
53
54 drawable-1.0.gir: libdrawable.la drawable.c drawable.h utility-1.0.gir $(SCANNER_BIN) $(SCANNER_LIBS) Makefile
55         $(CHECK_DEBUG) $(SCANNER) \
56         --include=GObject-2.0 \
57         --include=utility-1.0 \
58         --libtool="$(LIBTOOL)" \
59         --library=libdrawable.la \
60         --namespace=drawable \
61         --nsversion=1.0 \
62         --pkg gobject-2.0 \
63         $(srcdir)/drawable.h $(srcdir)/drawable.c \
64          --output $@
65 GIRS += drawable-1.0.gir
66
67 foo-1.0.gir: libfoo.la foo.c foo.h utility-1.0.gir $(SCANNER_BIN) $(SCANNER_LIBS) Makefile
68         $(CHECK_DEBUG) $(SCANNER) \
69         --include=GObject-2.0 \
70         --include=utility-1.0 \
71         --include=Gio-2.0 \
72         --c-include="foo.h" \
73         --libtool="$(LIBTOOL)" \
74         --library=libfoo.la \
75         --namespace=foo \
76         --nsversion=1.0 \
77         --pkg gobject-2.0 \
78         $(srcdir)/foo.h $(srcdir)/foo.c \
79          --output $@
80 GIRS += foo-1.0.gir
81
82 utility-1.0.gir: libutility.la utility.h $(SCANNER_BIN) $(SCANNER_LIBS) Makefile
83         $(CHECK_DEBUG) $(SCANNER) \
84         --include=GObject-2.0 \
85         --libtool="$(LIBTOOL)" \
86         --library=libutility.la \
87         --namespace=utility \
88         --nsversion=1.0 \
89         --pkg gobject-2.0 \
90         $(libutility_la_SOURCES) \
91         --output $@
92 GIRS += utility-1.0.gir
93
94 # This one tests different --namespace and --strip-prefix
95 GtkFrob-1.0.gir: libgtkfrob.la gtkfrob.h $(SCANNER_BIN) $(SCANNER_LIBS) Makefile
96         $(CHECK_DEBUG) $(SCANNER) \
97         --include=GObject-2.0 \
98         --libtool="$(LIBTOOL)" \
99         --library=libgtkfrob.la \
100         --namespace=GtkFrob \
101         --strip-prefix=Gtk \
102         --nsversion=1.0 \
103         --pkg gobject-2.0 \
104         $(libgtkfrob_la_SOURCES) \
105         --output $@
106 GIRS += GtkFrob-1.0.gir
107
108 noinst_PROGRAMS = barapp
109
110 barapp_SOURCES = $(srcdir)/barapp.c $(srcdir)/barapp.h
111 barapp_LDADD = $(top_builddir)/girepository/libgirepository-1.0.la
112 barapp_LDFLAGS = -export-dynamic
113 BarApp-1.0.gir: barapp $(SCANNER_BIN) $(SCANNER_LIBS) Makefile
114         $(SCANNER) \
115         --include=GObject-2.0 \
116         --libtool="$(LIBTOOL)" \
117         --program=./barapp \
118         --namespace=BarApp \
119         --strip-prefix=Bar \
120         --nsversion=1.0 \
121         --pkg gobject-2.0 \
122         $(barapp_SOURCES) \
123         --output $@
124 GIRS += BarApp-1.0.gir
125
126 pre-check:
127         @if test "$(top_builddir)" != "$(top_srcdir)"; then \
128            cp -f $(top_srcdir)/giscanner/*.py $(top_builddir)/giscanner; \
129         fi
130
131 post-check:
132         @echo "========================"
133         @echo "All scanner tests passed"
134         @echo "========================"
135         @if test "$(top_builddir)" != "$(top_srcdir)"; then \
136            rm -f $(top_builddir)/giscanner/*.py*; \
137         fi
138
139 %.gir.check: %.gir
140         @diff -u -U 10 $(srcdir)/$*-expected.gir $*.gir && echo "  TEST  $*.gir"
141
142 # stop %.typelib rule from building %-expected.tgir (via %-expected.typelib)
143 %-expected.typelib:
144         @true
145
146 %.typelib: %.gir $(top_builddir)/tools/g-ir-compiler$(EXEEXT) Makefile
147         $(top_builddir)/tools/g-ir-compiler --includedir=. --includedir=$(top_builddir)/gir $< -o $@
148
149 %.tgir: %.typelib $(top_builddir)/tools/g-ir-generate$(EXEEXT) Makefile
150         $(top_builddir)/tools/g-ir-generate --includedir=. --includedir=$(top_builddir)/gir $< -o $@
151
152 %.tgir.check: %.tgir
153         @diff -u -U 10 $(srcdir)/$*-expected.tgir $*.tgir; \
154         if test "$$?" = "0"; then \
155             echo "  TEST  $*.tgir"; \
156             rm -f $*.tgir; \
157         else \
158             exit 1; \
159         fi
160
161 distclean-local:
162         @if test "$(top_builddir)" != "$(top_srcdir)"; then \
163             rm -f $(top_builddir)/tests/scanner/*.tgir; \
164         fi
165
166 check-local: pre-check
167 check-local: $(CHECKGIRS) $(CHECKTGIRS) $(TYPELIBS)
168
169 check-local: post-check