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
|
# Copyright (C) 2006-2011 G.P. Halkes
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 3, as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
EXTENSIONS="c verbose_compile gettext"
SWITCHES="+unicode +dwfilter"
COMPILERULE='$(CC) $(CFLAGS) $(GETTEXTFLAGS) $(ICUFLAGS) -c -o $@ $<'
LINKRULE='$(CC) $(CFLAGS) $(LDFLAGS) -o .config .config.o $(LDLIBS) $(GETTEXTLIBS) $(ICULIBS)'
DEFAULT_LINGUAS="de es fr nl"
[ -f config.pkg.langpack ] && . config.pkg.langpack
USER_HELP=" --without-unicode Disable Unicode support
Environment variables:
LINGUAS List of languages to install. Available languages are:
${DEFAULT_LINGUAS}"
checkfunction() {
clean .config.o
CHECKFOR="$1"
CODE="$2"
shift 2
{
for INCLUDE
do
echo "#include ${INCLUDE}"
done
cat <<EOF
int main(int argc, char *argv[]) {
${CODE}
return 0;
}
EOF
} > .config.c
clean .config.o
test_link "${CHECKFOR}"
}
config() {
# Test for all required functionality
cat > .config.c <<EOF
#include <stdlib.h>
#include <stdio.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
int main(int argc, char *argv[]) {
int fd;
char buffer[10];
fd = mkstemp("fooXXXXXX");
fd = open("foo", O_RDONLY);
read(fd, buffer, 10);
lseek(fd, 0, SEEK_SET);
write(fd, buffer, 10);
close(fd);
umask(~S_IRWXU);
snprintf(buffer, 10, "%s", "foo");
return 0;
}
EOF
clean .config.o
test_link "required functions" || {
check_message_result "Testing required functions seperatly for debugging purposes"
checkfunction "mkstemp" 'int fd; fd = mkstemp("fooXXXXXX");' "<stdlib.h>"
checkfunction "open" 'int fd; fd = open("foo", O_RDONLY);' "<unistd.h>" "<fcntl.h>"
checkfunction "read" 'int fd; char buffer[10]; read(fd, buffer, 10);' "<unistd.h>"
checkfunction "lseek" "int fd; lseek(fd, 0, SEEK_SET);" "<unistd.h>"
checkfunction "write" "int fd; char buffer[10]; write(fd, buffer, 10);" "<unistd.h>"
checkfunction "close" 'int fd; close(fd);' "<unistd.h>"
checkfunction "umask" 'umask(~S_IRWXU);' "<sys/stat.h>"
checkfunction "snprintf" 'char buffer[10]; snprintf(buffer, 10, "%s", "foo");' "<stdio.h>"
check_message_result "!! A required function is not available."
exit 1
}
if [ "yes" = "${with_dwfilter}" ] ; then
cat > .config.c <<EOF
#include <sys/types.h>
#include <unistd.h>
int main(int argc, char *argv[]) {
pid_t pid = fork();
execvp("test", NULL);
}
EOF
clean .config.o
test_link "required functions for dwfilter" || {
checkfunction "fork" 'pid_t pid = fork();' "<unistd.h>" "<sys/types.h>"
checkfunction "execvp" 'execvp("test", NULL);' "<unistd.h>"
check_message_result "!! A required function for dwfilter is not availabe. Try configuring with --without-dwfilter"
exit 1
}
DWFILTER="DWFILTER=yes"
else
DWFILTER="DWFILTER="
fi
checkfunction "strdup" "strdup(\"foo\");" "<string.h>" || CFLAGS="${CFLAGS} -DNO_STRDUP"
if [ "yes" = "${with_gettext}" ] || [ "yes" = "${with_unicode}" ] ; then
checkfunction "setlocale" "setlocale(LC_ALL, \"\");" "<locale.h>" || {
check_message_result "!! Gettext and Unicode support unavailable. Try configuring with --without-gettext --without-unicode"
exit 1
}
fi
if [ "yes" = "${with_unicode}" ] ; then
: "${PKG_CONFIG:=pkg-config}"
{
check_message "Checking for ICU pkg-config... "
{
echo "Running $PKG_CONFIG --cflags --libs icu-uc" >> config.log
if $PKG_CONFIG --cflags --libs icu-uc 2>&1 > /dev/null ; then
check_message_result "yes"
true
else
check_message_result "no"
false
fi
} && {
cat > .config.c <<EOF
#include <unicode/uchar.h>
#include <unicode/unorm2.h>
#include <unicode/ustring.h>
int main(int argc, char *argv[]) {
UChar32 c;
UChar *a, *b;
UErrorCode error = U_ZERO_ERROR;
u_isUWhiteSpace(c);
U_GET_GC_MASK(c);
u_strFoldCase(a, 10, b, 10, U_FOLD_CASE_DEFAULT, &error);
unorm2_normalize(unorm2_getNFDInstance(&error), a, 10, b, 10, &error);
u_getIntPropertyValue(c, UCHAR_GRAPHEME_CLUSTER_BREAK);
return 0;
}
EOF
clean .config.o
test_link "functions in libicu" ICUFLAGS="\`$PKG_CONFIG --cflags icu-uc\`" ICULIBS="\`$PKG_CONFIG --libs icu-uc\`"
}
} || {
check_message_result "!! Could not compile with Unicode support. Try configuring with --without-unicode."
exit 1
}
ICUFLAGS="-DUSE_UNICODE \`$PKG_CONFIG --cflags icu-uc\`"
ICULIBS="\`$PKG_CONFIG --libs icu-uc\`"
if checkfunction "nl_langinfo" "nl_langinfo(CODESET);" "<langinfo.h>" ; then
ICUFLAGS="${ICUFLAGS} -DUSE_NL_LANGINFO"
fi
fi
create_makefile ${option_localedir:+"LOCALEDIR=${option_localedir}"} \
"ICUFLAGS=${ICUFLAGS}" "ICULIBS=${ICULIBS}" $DWFILTER
}
sed_lines() {
add_replace_settings "$@"
}
|