summaryrefslogtreecommitdiff
path: root/source4/build/m4/public.m4
blob: 6e8be7fa5e25e8e18f8a096a0902545e014cd87f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
dnl SMB Build System
dnl ----------------
dnl Copyright (C) 2004 Stefan Metzmacher
dnl Copyright (C) 2004-2005 Jelmer Vernooij
dnl Published under the GPL
dnl
dnl SMB_SUBSYSTEM(name,obj_files,required_subsystems)
dnl
dnl SMB_EXT_LIB_ENABLE(name,default_build)
dnl
dnl SMB_EXT_LIB_FROM_PKGCONFIG(name,pkg-config name)
dnl
dnl SMB_EXT_LIB(name,libs,cflags,cppflags,ldflags)
dnl
dnl SMB_ENABLE(name,default_build)
dnl
dnl #######################################################
dnl ### And now the implementation			###
dnl #######################################################

dnl SMB_SUBSYSTEM(name,obj_files,required_subsystems)
AC_DEFUN([SMB_SUBSYSTEM],
[
	if test -z "$[SMB_SUBSYSTEM_NOPROTO_][$1]"; then
		[SMB_SUBSYSTEM_NOPROTO_][$1]="NO";
	fi

SMB_INFO_SUBSYSTEMS="$SMB_INFO_SUBSYSTEMS
###################################
# Start Subsystem $1
@<:@SUBSYSTEM::$1@:>@
OBJ_FILES = $2
PRIVATE_DEPENDENCIES = $3
ENABLE = YES
# End Subsystem $1
###################################
"
])

dnl SMB_EXT_LIB_ENABLE(name,default_build)
AC_DEFUN([SMB_EXT_LIB_ENABLE],
[
[SMB_EXT_LIB_ENABLE_][$1]="$2"
SMB_INFO_ENABLES="$SMB_INFO_ENABLES
\$enabled{EXT_LIB_$1} = \"$2\";"
])

dnl SMB_EXT_LIB_FROM_PKGCONFIG(name,pkg-config name)
AC_DEFUN([SMB_EXT_LIB_FROM_PKGCONFIG], 
[
	dnl Figure out the correct variables and call SMB_EXT_LIB()

	if test -z "$PKG_CONFIG"; then
		AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
	fi

	if test "$PKG_CONFIG" = "no" ; then
    		echo "*** The pkg-config script could not be found. Make sure it is"
    		echo "*** in your path, or set the PKG_CONFIG environment variable"
    		echo "*** to the full path to pkg-config."
    		echo "*** Or see http://www.freedesktop.org/software/pkgconfig to get pkg-config."
			SMB_EXT_LIB($1)
			SMB_EXT_LIB_ENABLE($1, NO)
	else
		if $PKG_CONFIG --atleast-pkgconfig-version 0.9.0; then
        		AC_MSG_CHECKING(for $2)

          		if test "$SMB_EXT_LIB_$1"x = "NO"x ; then
				SMB_EXT_LIB_ENABLE($1, NO)
				AC_MSG_RESULT(disabled)		
          		elif $PKG_CONFIG --exists '$2' ; then
            			AC_MSG_RESULT(yes)


				$1_CFLAGS="`$PKG_CONFIG --cflags '$2'`"
    			OLD_CFLAGS="$CFLAGS"
	    		CFLAGS="$CFLAGS $$1_CFLAGS"
		    	AC_MSG_CHECKING([that the C compiler can use the $1_CFLAGS])
    			AC_TRY_RUN([#include "${srcdir-.}/build/tests/trivial.c"],
					SMB_EXT_LIB_ENABLE($1, YES)
			    	AC_MSG_RESULT(yes),
					AC_MSG_RESULT(no),
					AC_MSG_WARN([cannot run when cross-compiling]))
    			CFLAGS="$OLD_CFLAGS"


				SMB_EXT_LIB($1, 
					[`$PKG_CONFIG --libs-only-l '$2'`], 
					[`$PKG_CONFIG --cflags-only-other '$2'`],
					[`$PKG_CONFIG --cflags-only-I '$2'`],
					[`$PKG_CONFIG --libs-only-other '$2'` `$PKG_CONFIG --libs-only-L '$2'`])

        		else
				SMB_EXT_LIB($1)
				SMB_EXT_LIB_ENABLE($1, NO)
				AC_MSG_RESULT(no)
            			$PKG_CONFIG --errors-to-stdout --print-errors '$2'
        		fi
     		else
        		echo "*** Your version of pkg-config is too old. You need version $PKG_CONFIG_MIN_VERSION or newer."
        			echo "*** See http://www.freedesktop.org/software/pkgconfig"
				SMB_EXT_LIB($1)
				SMB_EXT_LIB_ENABLE($1, NO)
     		fi
  	fi
])

dnl SMB_EXT_LIB(name,libs,cflags,cppflags,ldflags)
AC_DEFUN([SMB_EXT_LIB],
[

SMB_INFO_EXT_LIBS="$SMB_INFO_EXT_LIBS
###################################
# Start Ext Lib $1
@<:@EXT_LIB::EXT_LIB_$1@:>@
LIBS = $2
CFLAGS = $3
CPPFLAGS = $4
LDFLAGS = $5
# End Ext Lib $1
###################################
"
])

dnl SMB_ENABLE(name,default_build)
AC_DEFUN([SMB_ENABLE],
[
	[SMB_ENABLE_][$1]="$2";

SMB_INFO_ENABLES="$SMB_INFO_ENABLES
\$enabled{$1} = \"$2\";"
])