]> git.draconx.ca Git - dxcommon.git/blob - m4/cneartree.m4
Add simple detection macros for libcneartree and libgerbv.
[dxcommon.git] / m4 / cneartree.m4
1 dnl Copyright © 2018 Nick Bowler
2 dnl
3 dnl License WTFPL2: Do What The Fuck You Want To Public License, version 2.
4 dnl This is free software: you are free to do what the fuck you want to.
5 dnl There is NO WARRANTY, to the extent permitted by law.
6
7 dnl DX_LIB_CNEARTREE([min-version], [action-if-ok], [acton-if-failed])
8 dnl
9 dnl Search for a working CNearTree installation.  If such a library is found,
10 dnl appropriate compiler and linker flags are stored in CNEARTREE_CFLAGS and
11 dnl CNEARTREE_LIBS, respectively, and the action-if-ok is performed (may be
12 dnl empty).  If no suitable library is found, then action-if-failed is
13 dnl performed if non-empty, otherwise configure will stop with a fatal error.
14 AC_DEFUN([DX_LIB_CNEARTREE],
15 [DX_LIB_SETUP([cneartree])AC_MSG_CHECKING([for libCNearTree])
16 DX_LIB_SEARCH_LINK([cneartree],
17   [m4_apply([_DX_LIB_CNEARTREE_TEST], m4_split([$1], [\.]))],
18   [ [[$CNEARTREE_CFLAGS], [$CNEARTREE_LIBS]],
19     [[], [-lCNearTree]],
20     [[], [-lCNearTree -lCVector]] ])
21 AS_IF([test x"$dx_cv_cneartree_lib_found" = x"yes"], [$2],
22   [m4_default([$3], [AC_MSG_FAILURE([dnl
23 libCNearTree is required.  The latest
24 version may be found at <http://neartree.sourceforge.net/>.
25 m4_newline([DX_LIB_USERFLAG_BLURB([cneartree])])
26 ])])])])
27
28 dnl Internal test program for CNearTree.  The version test is currently
29 dnl unimplemented.
30 m4_define([_DX_LIB_CNEARTREE_TEST], [AC_LANG_PROGRAM([dnl
31 #include <CNearTree.h>
32 ], [dnl
33 CNearTreeHandle t;
34 CVectorHandle v;
35 void *p;
36 CNearTreeCreate(&t, 2, CNEARTREE_TYPE_DOUBLE|CNEARTREE_NORM_L2);
37 CNearTreeObjects(t, &v);
38 CVectorGetElement(v, &p, 0);
39 CNearTreeFree(&t);
40 ])])