Remove generated files
[framework/connectivity/libgphoto2.git] / libgphoto2_port / m4 / gp-camlibs.m4
1 dnl GP_CAMLIB & Co.
2 dnl
3 dnl Redundancy free definition of libgphoto2 camlibs.
4 dnl
5 dnl Removes the redundany from the camlib lists, and executes
6 dnl additional consistency checks, e.g. to ensure that subdirectories
7 dnl actually exist.
8 dnl
9 dnl You can mark camlibs as obsolete, i.e. they won't be listed
10 dnl explicitly but still be recognized.
11 dnl
12 dnl Example usage:
13 dnl
14 dnl   GP_CAMLIB([canon])
15 dnl   GP_CAMLIB([casio])
16 dnl   [...]
17 dnl   GP_CAMLIB([ptp],[obsolete])
18 dnl   GP_CAMLIB([ptp2])
19 dnl   [...]
20 dnl   GP_CAMLIB([toshiba])
21 dnl   GP_CAMLIBS_DEFINE([camlibs])
22 dnl
23 dnl The camlibs basedir parameter of GP_CAMLIBS_DEFINE is optional.
24 dnl
25 dnl ####################################################################
26 dnl
27 AC_DEFUN([GP_CAMLIBS_INIT],[dnl
28 AC_BEFORE([$0],[GP_CAMLIB])dnl
29 m4_define_default([gp_camlib_srcdir], [camlibs])dnl
30 m4_define_default([gp_camlibs], [])dnl
31 m4_define_default([gp_camlibs_obsolete], [])dnl
32 ])dnl
33 dnl
34 dnl ####################################################################
35 dnl
36 AC_DEFUN([GP_CAMLIB],[dnl
37 AC_REQUIRE([GP_CAMLIBS_INIT])dnl
38 AC_BEFORE([$0],[GP_CAMLIBS_DEFINE])dnl
39 m4_if([$2],[obsolete],[dnl
40 # $0($1,$2)
41 m4_append([gp_camlibs_obsolete], [$1], [ ])dnl
42 ],[$#],[1],[dnl
43 # $0($1)
44 m4_append([gp_camlibs], [$1], [ ])dnl
45 ],[dnl
46 m4_errprint(__file__:__line__:[ Error:
47 *** Illegal parameter 2 to $0: `$2'
48 *** Valid values are: undefined or [obsolete]
49 ])dnl
50 m4_exit(1)dnl
51 ])dnl
52 ])dnl
53 dnl
54 dnl ####################################################################
55 dnl
56 AC_DEFUN([GP_CAMLIBS_DEFINE],[dnl
57 AC_REQUIRE([GP_CAMLIBS_INIT])dnl
58 m4_pattern_allow([m4_strip])dnl
59 m4_ifval([$1],[m4_define([gp_camlib_srcdir],[$1])])dnl
60 dnl for camlib in m4_strip(gp_camlibs) m4_strip(gp_camlibs_obsolete)
61 dnl do
62 dnl     if test -d "$srcdir/m4_strip(gp_camlib_srcdir)/$camlib"; then :; else
63 dnl             AC_MSG_ERROR([
64 dnl * Fatal:
65 dnl * Source subdirectory for camlib \`$camlib' not found in
66 dnl * directory \`$srcdir/m4_strip(gp_camlib_srcdir)/'
67 dnl ])
68 dnl     fi
69 dnl done
70 AC_MSG_CHECKING([which drivers to compile])
71 dnl Yes, that help output won't be all that pretty, but we at least
72 dnl do not have to edit it by hand.
73 AC_ARG_WITH([drivers],[AS_HELP_STRING(
74         [--with-drivers=<list>],
75         [Compile drivers in <list>. ]dnl
76         [Drivers may be separated with commas. ]dnl
77         ['all' is the default and compiles all drivers. ]dnl
78         [Possible drivers are: ]dnl
79         m4_strip(gp_camlibs))],
80         [drivers="$withval"],
81         [drivers="all"])dnl
82 dnl
83 ALL_DEFINED_CAMLIBS="m4_strip(gp_camlibs) m4_strip(gp_camlibs_obsolete)"
84 ALL_CURRENT_CAMLIBS="m4_strip(gp_camlibs)"
85 BUILD_THESE_CAMLIBS_BASE=""
86 if test "$drivers" = "all"; then
87         BUILD_THESE_CAMLIBS_BASE="$ALL_CURRENT_CAMLIBS"
88         AC_MSG_RESULT([all])
89 else
90         # drivers=$(echo $drivers | sed 's/,/ /g')
91         IFS_save="$IFS"
92         IFS=",$IFS"
93         for driver in $drivers; do
94                 IFS="$IFS_save"
95                 found=false
96                 for camlib in ${ALL_DEFINED_CAMLIBS}; do
97                         if test "$driver" = "$camlib"; then
98                                 BUILD_THESE_CAMLIBS_BASE="$BUILD_THESE_CAMLIBS_BASE $driver"
99                                 found=:
100                                 break
101                         fi
102                 done
103                 if $found; then :; else
104                         AC_MSG_ERROR([Unknown driver $driver!])         
105                 fi
106         done
107         if test "x$BUILD_THESE_CAMLIBS_BASE" = "x canon" ; then
108                 # Gentoo mode... if user just said "canon", add "ptp2" ... should save support requests.
109                 BUILD_THESE_CAMLIBS_BASE="$BUILD_THESE_CAMLIBS_BASE ptp2"
110                 camlibs="$camlibs ptp2"
111                 AC_MSG_WARN([
112                         You have just selected the old canon driver. However most current Canons
113                         are supported by the PTP2 driver.
114                         Autoselecting ptp2 driver too to avoid support requests.
115                 ])
116         fi
117         IFS="$IFS_save"
118         AC_MSG_RESULT([$drivers])
119 fi
120 BUILD_THESE_CAMLIBS=""
121 for f in $BUILD_THESE_CAMLIBS_BASE
122 do
123     BUILD_THESE_CAMLIBS="${BUILD_THESE_CAMLIBS}${BUILD_THESE_CAMLIBS+ }${f}.la"
124 done
125 AC_SUBST([BUILD_THESE_CAMLIBS])
126 AC_SUBST([ALL_DEFINED_CAMLIBS])
127 AC_SUBST([ALL_CURRENT_CAMLIBS])
128 ])dnl
129 dnl
130 dnl ####################################################################
131 dnl
132 dnl Local Variables:
133 dnl mode: autoconf
134 dnl End: