1
2# Hamlib bindings using SWIG
3# more information on swig at http://www.swig.org
4#
5
6AM_CPPFLAGS = @AM_CPPFLAGS@ -I$(top_srcdir)/include -I$(top_srcdir)/bindings  \
7	$(TCL_INCLUDE_SPEC) $(PYTHON_CPPFLAGS)
8
9AM_CFLAGS = -fno-strict-aliasing
10AM_CXXFLAGS = -O2
11
12SWGFILES = hamlib.swg ignore.swg rig.swg rotator.swg amplifier.swg
13
14SWGDEP = \
15	$(top_srcdir)/include/hamlib/rig.h \
16	$(top_srcdir)/include/hamlib/riglist.h \
17	$(top_srcdir)/include/hamlib/rotator.h \
18	$(top_srcdir)/include/hamlib/rotlist.h \
19	$(top_srcdir)/include/hamlib/amplifier.h \
20	$(top_srcdir)/include/hamlib/amplist.h \
21	$(SWGFILES)
22
23EXTRA_DIST = $(SWGFILES) \
24	Makefile.PL perltest.pl tcltest.tcl.in pytest.py py3test.py \
25	luatest.lua README.python
26
27exampledir = $(docdir)/examples
28example_DATA =
29
30BUILT_SOURCES =
31MOSTLYCLEANFILES =
32
33
34if ENABLE_PERL
35##########################################
36# Perl binding
37
38BUILT_SOURCES += hamlibperl_wrap.c
39MOSTLYCLEANFILES += hamlibperl_wrap.c Hamlib.pm Hamlib.bs Hamlib-pl.mk.old
40example_DATA += perltest.pl
41
42hamlibperl_wrap.c: hamlib.swg $(SWIGDEP)
43	$(AM_V_GEN)$(SWIG) -perl5 -shadow $(AM_CPPFLAGS) -I$(top_srcdir)/bindings \
44		-o $@ $$(test -f hamlib.swg || echo '$(srcdir)/')hamlib.swg
45
46Hamlib-pl.mk: $(srcdir)/Makefile.PL
47	$(AM_V_at)test -f Makefile.PL || $(LN_S) $(srcdir)/Makefile.PL Makefile.PL
48	$(AM_V_at)perl $$(test -f Makefile.PL || echo '$(srcdir)/')Makefile.PL \
49			MAKEFILE="Hamlib-pl.mk" \
50			PREFIX="$(prefix)" \
51			INC="$(AM_CPPFLAGS)"  \
52			CC="$(CC)"  \
53			OBJECT="hamlibperl_wrap.o" \
54			VERSION="$(PACKAGE_VERSION)" \
55			LIBS="-L$(top_builddir)/src/.libs -lhamlib"
56	$(AM_V_at)sed -e 's/^LD_RUN_PATH.*/LD_RUN_PATH =/' Hamlib-pl.mk > Hamlib-pl-norpath.mk
57	$(AM_V_at)mv Hamlib-pl-norpath.mk Hamlib-pl.mk
58
59all-perl: Hamlib-pl.mk hamlibperl_wrap.c
60	$(AM_V_at)$(MAKE) $(AM_MAKEFLAGS) -f Hamlib-pl.mk all
61
62check-perl: all-perl
63	$(AM_V_at)LD_LIBRARY_PATH=$(top_builddir)/src/.libs perl $(top_srcdir)/bindings/perltest.pl
64
65clean-perl: Hamlib-pl.mk
66	$(AM_V_at)$(MAKE) $(AM_MAKEFLAGS) -f Hamlib-pl.mk clean
67
68## 'distclean' target is a NOOP in Hamlib-pl.mk
69distclean-perl: ## Hamlib-pl.mk
70##	$(MAKE) $(AM_MAKEFLAGS) -f Hamlib-pl.mk distclean
71
72distcheck-perl: Hamlib-pl.mk
73	$(AM_V_at)$(MAKE) $(AM_MAKEFLAGS) -f Hamlib-pl.mk distcheck
74
75install-perl: Hamlib-pl.mk
76	$(AM_V_at)$(MAKE) $(AM_MAKEFLAGS) -f Hamlib-pl.mk install_site
77
78## ExtUtils::MakeMaker says uninstall is deprecated and won't remove the files
79## anyway, so we'll have to figure out another way to remove the installed files.
80uninstall-perl: ## Hamlib-pl.mk
81##	$(MAKE) $(AM_MAKEFLAGS) -f Hamlib-pl.mk uninstall
82
83endif
84# Perl
85
86
87if ENABLE_PYTHON
88##########################################
89# Python binding
90
91pyexec_ltlib = _Hamlib.la
92
93MOSTLYCLEANFILES += hamlibpy_wrap.c Hamlib.py *.pyc
94BUILT_SOURCES += hamlibpy_wrap.c Hamlib.py
95
96# Set by AM_CONDITIONAL in configure.ac
97if PYVER_3
98pytest = py3test.py
99else !PYVER_3
100pytest = pytest.py
101endif
102# PYVER_3
103
104example_DATA += $(pytest)
105
106nodist_pyexec_PYTHON = Hamlib.py
107nodist__Hamlib_la_SOURCES = hamlibpy_wrap.c
108
109_Hamlib_la_LDFLAGS = -no-undefined -module -avoid-version
110_Hamlib_la_LIBADD = $(top_builddir)/src/libhamlib.la $(PYTHON_LIBS)
111_Hamlib_ladir = $(pyexecdir)
112_Hamlib_la_LTLIBRARIES = $(pyexec_ltlib)
113
114all-py: $(pyexec_ltlib)
115
116check-py: all-py
117	$(AM_V_at)PYTHONPATH=$(builddir):$(builddir)/.libs \
118		$(PYTHON) $(srcdir)/$(pytest) \
119		|| echo "Python test failed" 1>&2
120
121Hamlib.py: hamlibpy_wrap.c
122
123hamlibpy_wrap.c: hamlib.swg $(SWGDEP)
124	$(AM_V_GEN)$(SWIG) -python $(AM_CPPFLAGS) $(PYTHON_CPPFLAGS) -I$(top_srcdir)/bindings \
125		-o $@ $$(test -f hamlib.swg || echo '$(srcdir)/')hamlib.swg
126
127install-py:
128clean-py:
129distclean-py:
130uninstall-py:
131
132endif
133# Python
134
135
136if ENABLE_TCL
137##########################################
138# Tcl binding
139
140BUILT_SOURCES += hamlibtcl_wrap.c
141MOSTLYCLEANFILES += hamlibtcl_wrap.c pkgIndex.tcl tcltest.tcl
142example_DATA += tcltest.tcl
143
144tcl_ltlib = hamlibtcl.la
145
146tcldir = $(libdir)/tcl$(TCL_VERSION)/Hamlib
147
148PKG_VER = $(ABI_VERSION).$(ABI_REVISION)
149DLL = hamlibtcl-$(PKG_VER)$(TCL_SHLIB_SUFFIX)
150
151nodist_hamlibtcl_la_SOURCES = hamlibtcl_wrap.c
152hamlibtcl_la_LDFLAGS = -no-undefined -module -release $(PKG_VER) -avoid-version
153hamlibtcl_la_LIBADD = $(top_builddir)/src/libhamlib.la $(TCL_LIB_SPEC)
154
155hamlibtcl_ladir = $(tcldir)
156hamlibtcl_la_DATA = pkgIndex.tcl
157
158# Install hamlibtcl.la into the $(tcldir)/Hamlib directory
159# set by $(hamlibtcl_ladir)
160hamlibtcl_la_LTLIBRARIES = $(tcl_ltlib)
161
162# Having the first occurrence of 'hamlib' capitalized seemed to cause confusion
163# for the TCL interpreter loading the Hamlib module.
164pkgIndex.tcl: Makefile
165	$(AM_V_at)echo 'package ifneeded hamlib $(PKG_VER) [list load [file join $$dir $(DLL)] Hamlib]' > pkgIndex.tcl
166
167hamlibtcl_wrap.c: hamlib.swg $(SWGDEP)
168	$(AM_V_GEN)$(SWIG) -tcl -pkgversion $(PKG_VER) $(AM_CPPFLAGS) \
169		-I$(top_srcdir)/bindings \
170		-o $@ $$(test -f hamlib.swg || echo '$(srcdir)/')hamlib.swg
171
172do_subst = sed -e 's,[@]tcldir[@],$(tcldir),g'
173
174tcltest.tcl: tcltest.tcl.in Makefile
175	$(AM_V_GEN)$(do_subst) < $(srcdir)/tcltest.tcl.in > tcltest.tcl
176
177all-tcl: pkgIndex.tcl $(tcl_ltlib) tcltest.tcl
178
179check-tcl: all-tcl
180	$(AM_V_at)cp $(builddir)/pkgIndex.tcl $(builddir)/.libs
181	$(AM_V_at)TCLLIBPATH=$(builddir)/.libs tclsh $(builddir)/tcltest.tcl \
182		|| echo "Tcl test failed" 1>&2
183	$(AM_V_at)rm -f $(builddir)/.libs/pkgIndex.tcl
184
185install-tcl:
186clean-tcl:
187distclean-tcl: clean-tcl
188uninstall-tcl:
189
190endif
191# TCL
192
193if ENABLE_LUA
194##########################################
195# Lua binding
196
197luaexec_ltlib = Hamliblua.la
198
199MOSTLYCLEANFILES += hamliblua_wrap.c
200BUILT_SOURCES += hamliblua_wrap.c
201example_DATA += luatest.lua
202
203nodist_luaexec_LUA = Hamlib.lua
204nodist_Hamliblua_la_SOURCES = hamliblua_wrap.c
205
206Hamliblua_la_CPPFLAGS = $(LUA_INCLUDE) -I$(top_srcdir)/include -I$(top_srcdir)/src
207Hamliblua_la_LDFLAGS = -no-undefined -module -avoid-version
208Hamliblua_la_LIBADD = $(top_builddir)/src/libhamlib.la
209Hamliblua_ladir = $(luaexecdir)
210Hamliblua_la_LTLIBRARIES = $(luaexec_ltlib)
211
212all-lua: $(luaexec_ltlib)
213
214check-lua: all-lua
215	$(AM_V_at)LUA_CPATH="$(abs_builddir)/.libs/?.so" $(LUA) $(srcdir)/luatest.lua \
216		|| echo "Lua test failed" 1>&2
217
218Hamlib.lua: hamliblua_wrap.c
219
220hamliblua_wrap.c: hamlib.swg $(SWGDEP)
221	$(AM_V_GEN)$(SWIG) -lua $(AM_CPPFLAGS) -I$(top_srcdir)/bindings \
222		-o $@ $$(test -f hamlib.swg || echo '$(srcdir)/')hamlib.swg
223
224install-lua:
225clean-lua:
226distclean-lua:
227uninstall-lua:
228
229endif
230# Lua
231
232
233all-local: @BINDING_ALL@
234
235check-local: @BINDING_CHECK@
236clean-local: @BINDING_CLEAN@
237distclean-local: @BINDING_DISTCLEAN@
238distcheck-local: @BINDING_DISTCHECK@
239install-exec-local: @BINDING_INSTALL_EXEC@
240uninstall-local: @BINDING_UNINSTALL@
241