Distinguish between private and public dependencies in the dot file.
[gd/samba/.git] / source4 / build / m4 / public.m4
1 dnl SMB Build System
2 dnl ----------------
3 dnl Copyright (C) 2004 Stefan Metzmacher
4 dnl Copyright (C) 2004-2005 Jelmer Vernooij
5 dnl Published under the GPL
6 dnl
7 dnl SMB_SUBSYSTEM(name,obj_files,required_subsystems)
8 dnl
9 dnl SMB_EXT_LIB_FROM_PKGCONFIG(name,pkg-config name,[ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND])
10 dnl
11 dnl SMB_EXT_LIB(name,libs,cflags,cppflags,ldflags)
12 dnl
13 dnl SMB_ENABLE(name,default_build)
14 dnl
15 dnl SMB_INCLUDE_MK(file)
16 dnl
17 dnl #######################################################
18 dnl ### And now the implementation                      ###
19 dnl #######################################################
20
21 dnl SMB_SUBSYSTEM(name,obj_files,required_subsystems,cflags)
22 AC_DEFUN([SMB_SUBSYSTEM],
23 [
24 MAKE_SETTINGS="$MAKE_SETTINGS
25 $1_OBJ_FILES = $2
26 $1_CFLAGS = $4
27 $1_ENABLE = YES
28 "
29
30 SMB_INFO_SUBSYSTEMS="$SMB_INFO_SUBSYSTEMS
31 ###################################
32 # Start Subsystem $1
33 @<:@SUBSYSTEM::$1@:>@
34 PRIVATE_DEPENDENCIES = $3
35 CFLAGS = \$($1_CFLAGS)
36 ENABLE = YES
37 # End Subsystem $1
38 ###################################
39 "
40 ])
41
42 dnl SMB_LIBRARY(name,obj_files,required_subsystems,cflags,ldflags)
43 AC_DEFUN([SMB_LIBRARY],
44 [
45 MAKE_SETTINGS="$MAKE_SETTINGS
46 $1_OBJ_FILES = $2
47 $1_CFLAGS = $4
48 $1_LDFLAGS = $5
49 $1_ENABLE = YES
50 "
51
52 SMB_INFO_LIBRARIES="$SMB_INFO_LIBRARIES
53 ###################################
54 # Start Library $1
55 @<:@LIBRARY::$1@:>@
56 PRIVATE_DEPENDENCIES = $3
57 CFLAGS = \$($1_CFLAGS)
58 LDFLAGS = \$($1_LDFLAGS)
59 ENABLE = YES
60 # End Library $1
61 ###################################
62 "
63 ])
64
65 dnl SMB_EXT_LIB_FROM_PKGCONFIG(name,pkg-config name,[ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND])
66 AC_DEFUN([SMB_EXT_LIB_FROM_PKGCONFIG], 
67 [
68         dnl Figure out the correct variables and call SMB_EXT_LIB()
69
70         if test -z "$PKG_CONFIG"; then
71                 AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
72         fi
73
74         if test "$PKG_CONFIG" = "no" ; then
75                 echo "*** The pkg-config script could not be found. Make sure it is"
76                 echo "*** in your path, or set the PKG_CONFIG environment variable"
77                 echo "*** to the full path to pkg-config."
78                 echo "*** Or see http://pkg-config.freedesktop.org/ to get pkg-config."
79                         ac_cv_$1_found=no
80         else
81                 if $PKG_CONFIG --atleast-pkgconfig-version 0.9.0; then
82                         AC_MSG_CHECKING(for $2)
83
84                         if $PKG_CONFIG --exists '$2' ; then
85                                 AC_MSG_RESULT(yes)
86
87                                 $1_CFLAGS="`$PKG_CONFIG --cflags '$2'`"
88                                 OLD_CFLAGS="$CFLAGS"
89                                 CFLAGS="$CFLAGS $$1_CFLAGS"
90                                 AC_MSG_CHECKING([that the C compiler can use the $1_CFLAGS])
91                                 AC_TRY_RUN([#include "${srcdir-.}/build/tests/trivial.c"],
92                                         SMB_ENABLE($1, YES)
93                                         AC_MSG_RESULT(yes),
94                                         AC_MSG_RESULT(no),
95                                         AC_MSG_WARN([cannot run when cross-compiling]))
96                                 CFLAGS="$OLD_CFLAGS"
97
98                                 SMB_EXT_LIB($1, 
99                                         [`$PKG_CONFIG --libs-only-l '$2'`], 
100                                         [`$PKG_CONFIG --cflags-only-other '$2'`],
101                                         [`$PKG_CONFIG --cflags-only-I '$2'`],
102                                         [`$PKG_CONFIG --libs-only-other '$2'` `$PKG_CONFIG --libs-only-L '$2'`])
103                                 ac_cv_$1_found=yes
104
105                         else
106                                 AC_MSG_RESULT(no)
107                                 $PKG_CONFIG --errors-to-stdout --print-errors '$2'
108                                 ac_cv_$1_found=no
109                         fi
110                 else
111                         echo "*** Your version of pkg-config is too old. You need version $PKG_CONFIG_MIN_VERSION or newer."
112                         echo "*** See http://pkg-config.freedesktop.org/"
113                         ac_cv_$1_found=no
114                 fi
115         fi
116         if test x$ac_cv_$1_found = x"yes"; then
117                 ifelse([$3], [], [echo -n ""], [$3])
118         else
119                 ifelse([$4], [], [
120                           SMB_EXT_LIB($1)
121                           SMB_ENABLE($1, NO)
122                 ], [$4])
123         fi
124 ])
125
126 dnl SMB_INCLUDE_MK(file)
127 AC_DEFUN([SMB_INCLUDE_MK],
128 [
129 SMB_INFO_EXT_LIBS="$SMB_INFO_EXT_LIBS
130 mkinclude $1
131 "
132 ])
133
134 dnl SMB_EXT_LIB(name,libs,cflags,cppflags,ldflags)
135 AC_DEFUN([SMB_EXT_LIB],
136 [
137 MAKE_SETTINGS="$MAKE_SETTINGS
138 $1_LIBS = $2
139 $1_CFLAGS = $3
140 $1_CPPFLAGS = $4
141 $1_LDFLAGS = $5
142 "
143
144 ])
145
146 dnl SMB_ENABLE(name,default_build)
147 AC_DEFUN([SMB_ENABLE],
148 [
149         MAKE_SETTINGS="$MAKE_SETTINGS
150 $1_ENABLE = $2
151 "
152 SMB_INFO_ENABLES="$SMB_INFO_ENABLES
153 \$enabled{$1} = \"$2\";"
154 ])