-
Notifications
You must be signed in to change notification settings - Fork 1
/
configure.ac
216 lines (190 loc) · 7.69 KB
/
configure.ac
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
# configure defaults
m4_define([v_maj], [3])
m4_define([v_min], [9])
m4_define([v_mic], [0])
## AC_PREREQ([2.71])
AC_INIT([libtrash],[v_maj.v_min.v_mic],[marriaga@stern.nyu.edu or pete@peterhyman.com],[],[http://pages.stern.nyu.edu/~marriaga/software/libtrash/])
AM_INIT_AUTOMAKE([-Wall -Werror foreign])
AM_PROG_AR
AC_CONFIG_SRCDIR([src/main.c])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_MACRO_DIRS([m4])
# only shared libraries
AC_DISABLE_STATIC
LT_INIT
# for linking
AC_SUBST([LT_VER], [v_maj:v_min:v_mic])
# Defines for libtrash (needed because defines are set programmatically)
AH_TEMPLATE([CREAT_VERSION], [Holder for GLIBC Version])
AH_TEMPLATE([CREAT64_VERSION], [Holder for GLIBC Version])
AH_TEMPLATE([FOPEN_VERSION], [Holder for GLIBC Version])
AH_TEMPLATE([FOPEN64_VERSION], [Holder for GLIBC Version])
AH_TEMPLATE([FREOPEN_VERSION], [Holder for GLIBC Version])
AH_TEMPLATE([FREOPEN64_VERSION], [Holder for GLIBC Version])
AH_TEMPLATE([OPEN_VERSION], [Holder for GLIBC Version])
AH_TEMPLATE([OPEN64_VERSION], [Holder for GLIBC Version])
AH_TEMPLATE([RENAME_VERSION], [Holder for GLIBC Version])
AH_TEMPLATE([UNLINK_VERSION], [Holder for GLIBC Version])
AH_TEMPLATE([OPENAT_VERSION], [Holder for GLIBC Version])
AH_TEMPLATE([OPENAT64_VERSION], [Holder for GLIBC Version])
AH_TEMPLATE([RENAMEAT_VERSION], [Holder for GLIBC Version])
AH_TEMPLATE([UNLINKAT_VERSION], [Holder for GLIBC Version])
AH_TEMPLATE([AT_FUNCTIONS], [Holder for GLIBC AT Function #define])
# Defaults for compilation
# Constants YES, NO, PROTECT and ALLOW_DESTRUCTION
AC_DEFINE([YES],[1],[Default for YES])
AC_DEFINE([NO],[0],[Default for NO])
AC_DEFINE([ALLOW_DESTRUCTION],[1],[Default for ALLOW_DESTRUCTION])
AC_DEFINE([PROTECT],[0],[Default for PROTECT])
AC_DEFINE([PERSONAL_CONF_FILE],".libtrash",[Personal Configuration File])
AC_DEFINE([WARNING_STRING],"Remember that libtrash is disabled.",[Disabled Warning String])
AC_DEFINE([INTERCEPT_UNLINK],[YES],[Trap unlink])
AC_DEFINE([INTERCEPT_RENAME],[YES],[Trap rename])
AC_DEFINE([INTERCEPT_FOPEN],[YES],[Trap fopen])
AC_DEFINE([INTERCEPT_FREOPEN],[YES],[Trap freopen])
AC_DEFINE([INTERCEPT_OPEN],[YES],[Trap open])
AC_DEFINE([TRASH_CAN],"Trash",[Trash Can Directory Name])
AC_DEFINE([IN_CASE_OF_FAILURE],[PROTECT],[Failure Protection])
AC_DEFINE([SHOULD_WARN],[NO],[Remove Warning])
AC_DEFINE([PROTECT_TRASH],[YES],[Protect Trash Can Contents])
AC_DEFINE([IGNORE_EXTENSIONS],"o;log;aux",[Default Extensions NOT to preserve])
AC_DEFINE([IGNORE_HIDDEN],[YES],[Ignore Hidden Files])
AC_DEFINE([IGNORE_EDITOR_BACKUP],[YES],[Ignore Backup Files])
AC_DEFINE([IGNORE_EDITOR_TEMPORARY],[YES],[Ignore Temporary Directory])
AC_DEFINE([LIBTRASH_CONFIG_FILE_UNREMOVABLE],[YES],[Protect libtrash configuration file])
AC_DEFINE([GLOBAL_PROTECTION],[YES],[Global Protection])
AC_DEFINE([TRASH_SYSTEM_ROOT],"SYSTEM_ROOT",[Trash Directory for non HOME files])
AC_DEFINE([UNREMOVABLE_DIRS],"/bin;/boot;/dev;/etc;/lib;/lib64;/opt;/sbin;/usr",[Protect These directories])
AC_DEFINE([TEMPORARY_DIRS],"/run;/tmp;/var",[Ignore Temporary Direcgtories])
AC_DEFINE([REMOVABLE_MEDIA_MOUNT_POINTS],"/cdrom;/media;/mnt/run",[Ignore Removable Media])
AC_DEFINE([EXCEPTIONS],"/etc/mtab;/etc/resolv.conf;/etc/adjtime;/etc/upsstatus;/etc/dhcpc",[Ignore these files and allow removal])
AC_DEFINE([USER_TEMPORARY_DIRS],"",[Ignore User Temporary Directories])
AC_DEFINE([IGNORE_RE],"",[Ignore Regex])
# Debug?
AC_ARG_ENABLE(
debug,
[AS_HELP_STRING([--enable-debug],[Enable Debug Messages @<:@default=no@:>@])],
debug=$enableval
)
if test x"$debug" = xyes; then
AC_DEFINE([DEBUG], [1], [Debug Flag])
fi
# Checks for programs.
AC_PROG_CC
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_SED
AC_PROG_MKDIR_P
# Checks for libraries.
AC_CHECK_LIB([dl], [dlvsym])
# Checks for header files.
AC_CHECK_HEADERS([ctype.h dlfcn.h errno.h fcntl.h pwd.h regex.h sys/stat.h \
stdarg.h stdlib.h string.h sys/types.h unistd.h ])
# Checks for typedefs, structures, and compiler characteristics.
AC_C_INLINE
AC_TYPE_MODE_T
AC_TYPE_SIZE_T
AC_TYPE_UID_T
AC_LANG([C])
# Checks for library functions.
AC_FUNC_ALLOCA
AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK
AC_FUNC_MALLOC
AC_FUNC_REALLOC
AC_CHECK_FUNCS([mkdir regcomp rmdir strchr strrchr strstr])
AC_CHECK_FUNCS([creat creat64 fopen fopen64 freopen freopen64 open open64 rename unlink], ,
[AC_MSG_ERROR([Function `$ac_func' not found...Cannot continue])])
AC_MSG_NOTICE([Checking AT Functions])
AC_CHECK_FUNCS([openat openat64 renameat unlinkat], ,[AC_MSG_WARN([AT Function `$ac_func' not found...Ignoring])])
if test x"$ac_cv_func_openat" = "xyes" -a \
x"$ac_cv_func_openat64" = "xyes" -a \
x"$ac_cv_func_renameat" = "xyes" -a \
x"$ac_cv_func_unlinkat" = "xyes" ; then
AC_DEFINE([HAVE_ATFUNCTIONS], [1], [AT Functions Found])
have_atfunctions=yes
else
AC_MSG_WARN([AT Functions ignored])
fi
AC_MSG_NOTICE([Getting GLIBC Versions for libtrash functions])
AC_LINK_IFELSE([AC_LANG_PROGRAM([[/* test program */
#define _GNU_SOURCE
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>]], [[fopen("", "r");
fopen64("", "r");
freopen("", "r", NULL);
freopen64("", "r", NULL);
open("", O_RDONLY);
open64("", O_RDONLY);
creat("", S_IRWXU);
creat64("", S_IRWXU);
unlink("");
rename("", "");
#ifdef HAVE_ATFUNCTIONS
unlinkat(0, "", 0);
renameat(0, "", 0, "");
openat(0, "", 0);
openat64(0, "", 0);
#endif]])],[AC_MSG_RESULT([Linking Test Program: Success]);
readelf -W --dyn-syms conftest > glibc_symbols;
sed -i -e 's/ (.*)//' glibc_symbols],[AC_MSG_FAILURE([Link Test Program: Failure])])
AC_MSG_NOTICE([Assigning GLIBC Versions to libtrash functions])
# Read in glibc_symbols and define
for TMPVAR in creat creat64 fopen fopen64 freopen freopen64 open open64 rename unlink
do
VERSIONVAR=$(grep -m1 $TMPVAR@ glibc_symbols | cut -d@ -f2)
FUNCVAR=$(echo $TMPVAR | tr a-z A-Z)_VERSION
if test "x$VERSIONVAR" != "x" ; then
AC_DEFINE_UNQUOTED([$FUNCVAR],"$VERSIONVAR",[$TMPVAR Define for dlvsym call])
else
AC_MSG_ERROR([Cannot get GLIBC Version for $FUNCVAR...Cannot continue])
fi
done
if test x"$have_atfunctions" = xyes; then
AC_DEFINE([AT_FUNCTIONS],[1])
for TMPVAR in openat openat64 renameat unlinkat
do
VERSIONVAR=$(grep -m1 $TMPVAR@ glibc_symbols | cut -d@ -f2)
FUNCVAR=$(echo $TMPVAR | tr a-z A-Z)_VERSION
if test "x$VERSIONVAR" != "x" ; then
AC_DEFINE_UNQUOTED([$FUNCVAR],"$VERSIONVAR",[$TMPVAR Define for dlvsym call])
else
AC_MSG_ERROR([Cannot get GLIBC Version for $FUNCVAR...Cannot continue])
fi
done
fi
# All pre processing done
AC_CONFIG_FILES([Makefile
src/Makefile
man/Makefile])
AC_OUTPUT
# Show what we have
echo "System defaults"
echo "==============="
if test x"$debug" = xyes; then
echo "Debug Output Enabled"
fi
for VAR in PERSONAL_CONF_FILE WARNING_STRING INTERCEPT_UNLINK INTERCEPT_RENAME \
INTERCEPT_FOPEN INTERCEPT_FREOPEN INTERCEPT_OPEN TRASH_CAN IN_CASE_OF_FAILURE \
SHOULD_WARN PROTECT_TRASH IGNORE_EXTENSIONS IGNORE_HIDDEN IGNORE_EDITOR_BACKUP \
IGNORE_EDITOR_TEMPORARY LIBTRASH_CONFIG_FILE_UNREMOVABLE GLOBAL_PROTECTION \
TRASH_SYSTEM_ROOT UNREMOVABLE_DIRS TEMPORARY_DIRS REMOVABLE_MEDIA_MOUNT_POINTS \
EXCEPTIONS USER_TEMPORARY_DIRS IGNORE_RE
do
echo $(grep -m1 $VAR config.h | sed -e 's/^#define //')
done
echo "Library Functions and GLIBC Versions"
echo "===================================="
for VAR in CREAT_VERSION CREAT64_VERSION FOPEN_VERSION FOPEN64_VERSION FREOPEN_VERSION \
FREOPEN64_VERSION OPEN_VERSION OPEN64_VERSION RENAME_VERSION UNLINK_VERSION
do
echo $(grep -m1 $VAR config.h | sed -e 's/^#define //')
done
if test x"$have_atfunctions" = xyes; then
for VAR in OPENAT_VERSION OPENAT64_VERSION RENAMEAT_VERSION UNLINKAT_VERSION
do
echo $(grep -m1 $VAR config.h | sed -e 's/^#define //')
done
fi
echo "====="
echo "See directories cleanTrash and strash-0.9 for additional utilities that are not installed."