-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathacinclude.m4
159 lines (130 loc) · 4.29 KB
/
acinclude.m4
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
#######################################################################################
##
## GB_FIND() macro is part of gambas2 project
## by Benoit Minisini
## others are from me (Laurent Carlier)
##
#######################################################################################
## ---------------------------------------------------------------------------
## GB_INIT_PROJECT
## Initialization and checking for gambas things
##
## $1 = gambas2 project to build
## ---------------------------------------------------------------------------
AC_DEFUN([GB_INIT_PROJECT],
[
if !(test -e src/$1/.project); then
AC_MSG_ERROR(Cannot find .project file for src/$1 !)
fi
##AM_INIT_AUTOMAKE(src/$1, `cat src/$1/.project | grep "Version=" | sed s/"Version="//g`)
AM_INIT_AUTOMAKE(src/$1, 0.1)
## List of needed components
COMPONENTS=`cat src/$1/.project | grep "Library=" | sed s/"Library="//g`
## Check if the project is a component
COMPONENT_build=`cat src/$1/.project | grep "MakeComponent=" | sed s/"MakeComponent="//g`
AC_SUBST(COMPONENT_build)
AC_MSG_CHECKING(for gambas2 binaries)
GAMBAS_path=`gbx2 -e system.path`/bin
if test "$?" != "0"; then
AC_MSG_RESULT(No)
AC_MSG_WARN(Failed to find gambas2 utilities, check your gambas2 installation !)
enable_gb_enviorment="no"
else
AC_MSG_RESULT(Ok)
AC_SUBST(GAMBAS_path)
enable_gb_enviorment="yes"
fi
## Find component components path
AC_MSG_CHECKING(for gambas2 components path)
GBLIBRARY_path=`gbx2 -e component.path`
if test "$?" != "0"; then
AC_MSG_RESULT(No)
AC_MSG_WARN(Failed to find gambas2 library path !)
enable_gb_enviorment="no"
else
AC_MSG_RESULT(Ok)
AC_SUBST(GBLIBRARY_path)
enable_gb_enviorment="yes"
fi
GBINFO_path=`echo $GBLIBRARY_path | sed s/"\/lib\/gambas2"/"\/share\/gambas2\/info"/`
AC_SUBST(GBINFO_path)
GBCONTROL_path=`echo $GBLIBRARY_path | sed s/"\/lib\/gambas2"/"\/share\/gambas2\/control"/`
AC_SUBST(GBCONTROL_path)
GBHOME_path=`gbx2 -e user.home`/.local/lib/gambas2
for comp in $COMPONENTS; do
if test "$comp" = "src/$1"; then continue; fi
AC_MSG_CHECKING(for $comp component)
GB_FIND(${comp}.component, $GBLIBRARY_path $GBHOME_path, ./)
if test "$gb_val" = "no"; then
AC_MSG_RESULT(No)
AC_MSG_WARN(Failed to find $comp component !)
enable_gb_enviorment="no"
else
AC_MSG_RESULT(Ok)
enable_gb_enviorment="yes"
fi
done
AM_CONDITIONAL(GB_READY, [ test "$enable_gb_enviorment" = "yes" ])
])
## ---------------------------------------------------------------------------
## GB_FIND
## Find files in directories
##
## $1 = Files to search
## $2 = Directories
## $3 = Sub-directories patterns
##
## Returns a path list in $gb_val
## ---------------------------------------------------------------------------
AC_DEFUN([GB_FIND],
[
dnl echo "Searching $1, $2, $3"
gb_val=""
gb_save=`pwd`
gb_file_list="$1"
for gb_main_dir in $2; do
if test -d $gb_main_dir; then
cd $gb_main_dir
for gb_search_dir in $3; do
for gb_dir in $gb_search_dir/ $gb_search_dir/*/ $gb_search_dir/*/*/; do
gb_new_file_list=""
gb_find_dir=""
for gb_file in $gb_file_list; do
gb_find=no
if test -r "$gb_main_dir/$gb_dir/$gb_file" || test -d "$gb_main_dir/$gb_dir/$gb_file"; then
ifelse($4,[],
gb_find=yes,
for gb_test in $4; do
gb_output=`ls -la $gb_main_dir/$gb_dir/$gb_file | grep "$gb_test"`
if test "x$gb_output" != "x"; then
gb_find=yes
fi
done
)
fi
if test "$gb_find" = "yes"; then
if test "x$gb_find_dir" = "x"; then
if test "x$gb_val" = "x"; then
gb_val="$gb_main_dir/$gb_dir"
else
gb_val="$gb_val $gb_main_dir/$gb_dir"
fi
fi
gb_find_dir=yes
else
gb_new_file_list="$gb_new_file_list $gb_file"
fi
done
gb_file_list=$gb_new_file_list
if test "x$gb_file_list" = "x " || test "x$gb_file_list" = "x"; then
break 3
fi
done
done
fi
done
if test "x$gb_file_list" != "x " && test "x$gb_file_list" != "x"; then
gb_val=no
fi
cd $gb_save
])