# Copyright (C) 2006-2007 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 . SWITCHES="+gettext" OPTIONS="localedir diff" COMPILERULE='$(CC) $(CFLAGS) $(GETTEXTFLAGS) -c -o $@ $<' LINKRULE='$(CC) $(CFLAGS) $(LDFLAGS) -o .config .config.o $(LDLIBS) $(GETTEXTLIBS)' USERRULES='.SUFFIXES: .mo .po .po.mo: msgfmt -o $@ $< ' TEST_INSTALL="install ./install.sh" DEFAULT_LINGUAS="de nl" [ -f config.pkg.langpack ] && . config.pkg.langpack USER_HELP=" --without-gettext Disable gettext translations --localedir= Installation directory for locales [prefix/share/locale] --diff= The diff program to use. Environment variables: LINGUAS List of languages to install. Available languages are: ${DEFAULT_LINGUAS}" rundiff() { echo "Running ${DIFF} $@" >> config.log LANG="C" "${DIFF}" "$@" > .config.diff 2>&1 RESULT=$? cat .config.diff >> config.log return "${RESULT}" } checkdiff() { echo "Checking output for '1c1'" >> config.log grep '^1c1$' config.log > /dev/null } config() { # Check the diff program for correct operation if [ -n "${option_diff}" ] ; then DIFF="${option_diff}" echo "${DIFF}" | grep "^\." > /dev/null && error "!! Do not use a relative path for the diff program" else DIFF=diff fi check_message "Checking for working diff program (${DIFF})... " clean .config.a .config.b .config.c echo "text" > .config.a echo "text" > .config.b echo "TEXT" > .config.c clean .config.diff if not rundiff .config.a .config.b || rundiff .config.a .config.c || not checkdiff ; then check_message_result "no" exit 1 fi check_message_result "yes" check_message "Checking for diff program has -a... " if not rundiff -a .config.a .config.b ; then check_message_result "no" DIFF_FLAGS="-DNO_MINUS_A" else check_message_result "yes" fi check_message "Checking for diff program has -i... " if not rundiff -i .config.a .config.c ; then check_message_result "no" DIFF_FLAGS="-DNO_MINUS_I ${DIFF_FLAGS}" else check_message_result "yes" fi clean .config.a .config.b .config.c .config.diff # Test for all required functionality cat > .config.c < #include #include #include int main(int argc, char *argv[]) { FILE *file; int fd; char buffer[10]; fd = mkstemp("fooXXXXXX"); fdopen(fd, "r+"); umask(~S_IRWXU); file = popen("echo", "r"); pclose(file); 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" cat > .config.c < int main(int argc, char *argv[]) { mkstemp("fooXXXXXX"); return 0; } EOF test_link "mkstemp" cat > .config.c < int main(int argc, char *argv[]) { fdopen(0, "r+"); return 0; } EOF test_link "fdopen" cat > .config.c < #include int main(int argc, char *argv[]) { umask(~S_IRWXU); return 0; } EOF test_link "umask" cat > .config.c < int main(int argc, char *argv[]) { popen("echo", "r"); return 0; } EOF test_link "popen" cat > .config.c < int main(int argc, char *argv[]) { pclose((void *)0); return 0; } EOF test_link "pclose" cat > .config.c < int main(int argc, char *argv[]) { char buffer[10]; snprintf(buffer, 10, "%s", "foo"); return 0; } EOF test_link "snprintf" exit 1 } # Check for gettext functionality if [ "yes" = "${with_gettext}" ] ; then cat > .config.c < .config.po <> config.log 2>&1 ; then check_message_result "yes" true else check_message_result "no" false fi } } || { clean .config.po .config.mo check_message_result "!! Could not compile with gettext. Try configuring with --without-gettext." exit 1 } clean .config.po .config.mo unset linguas if [ -n "${LINGUAS+set}" ] ; then check_message "Checking for available selected translations... " for lingua in ${LINGUAS} do if [ -f "po/${lingua}.po" ] && echo "${linguas}" | not grep "^\\(.* \\)*${lingua}\\( .*\\)*$" > /dev/null ; then linguas="${linguas}${linguas:+ }${lingua}" fi done check_message_result "done [${linguas}]" else linguas="${DEFAULT_LINGUAS}" fi fi if [ "yes" = "${with_gettext}" ] ; then create_makefile GETTEXTFLAGS=-DUSE_GETTEXT "GETTEXTLIBS=${GETTEXTLIBS}" "LINGUAS=${linguas}" "DIFF=${DIFF}" "DIFF_FLAGS=${DIFF_FLAGS}" ${option_localedir:+"LOCALEDIR=${option_localedir}"} else create_makefile GETTEXTFLAGS= GETTEXTLIBS= "DIFF=${DIFF}" "DIFF_FLAGS=${DIFF_FLAGS}" LINGUAS= LOCALEDIR= fi } sed_lines() { add_replace_settings "$@" }