added ./configure --disable-builtin to build without PSL data

This commit is contained in:
Tim Ruehsen 2014-03-30 17:02:56 +02:00
parent 51daebd295
commit 31319a3dc7
4 changed files with 42 additions and 2 deletions

View File

@ -25,6 +25,19 @@ AM_GNU_GETTEXT_VERSION([0.18.1])
AC_SUBST([LIBPSL_SO_VERSION], [0:0:0]) AC_SUBST([LIBPSL_SO_VERSION], [0:0:0])
AC_SUBST([LIBPSL_API_VERSION], [0.1]) AC_SUBST([LIBPSL_API_VERSION], [0.1])
# Check for idn2
AC_CHECK_PROG(HAVE_IDN2, idn2, yes, AC_MSG_ERROR(Cannot find required tool 'idn2'.))
# Check for enable/disable builtin PSL data
AC_ARG_ENABLE(builtin,
AS_HELP_STRING([--disable-builtin], [do not compile PSL data into library]),
[
enable_builtin=no
], [
enable_builtin=yes
AC_DEFINE([WITH_BUILTIN], [1], [compile PSL data into library])
])
# Check for valgrind # Check for valgrind
ac_enable_valgrind=no ac_enable_valgrind=no
AC_ARG_ENABLE(valgrind-tests, AC_ARG_ENABLE(valgrind-tests,
@ -63,6 +76,6 @@ AC_MSG_NOTICE([Summary of build options:
Compiler: ${CC} Compiler: ${CC}
CFlags: ${CFLAGS} ${CPPFLAGS} CFlags: ${CFLAGS} ${CPPFLAGS}
LDFlags: ${LDFLAGS} LDFlags: ${LDFLAGS}
Builtin PSL: ${enable_builtin}
Tests: ${TESTS_INFO} Tests: ${TESTS_INFO}
]) ])

View File

@ -43,6 +43,8 @@
//# include <idn2.h> //# include <idn2.h>
//#endif //#endif
#ifdef WITH_BUILTIN
#include <libpsl.h> #include <libpsl.h>
typedef struct { typedef struct {
@ -340,11 +342,14 @@ static void _add_punycode_if_needed(_psl_vector_t *v)
_vector_sort(v); _vector_sort(v);
} }
#endif // WITH_BUILTIN
int main(int argc, const char **argv) int main(int argc, const char **argv)
{ {
FILE *fpout; FILE *fpout;
#ifdef WITH_BUILTIN
psl_ctx_t *psl; psl_ctx_t *psl;
#endif
int ret = 0; int ret = 0;
if (argc != 3) { if (argc != 3) {
@ -354,6 +359,7 @@ int main(int argc, const char **argv)
return 1; return 1;
} }
#ifdef WITH_BUILTIN
if (!(psl = psl_load_file(argv[1]))) if (!(psl = psl_load_file(argv[1])))
return 2; return 2;
@ -389,5 +395,22 @@ int main(int argc, const char **argv)
} }
psl_free(psl); psl_free(psl);
#else
if ((fpout = fopen(argv[2], "w"))) {
fprintf(fpout, "static _psl_entry_t suffixes[0];\n");
fprintf(fpout, "static _psl_entry_t suffix_exceptions[0];\n");
fprintf(fpout, "static time_t _psl_file_time;\n");
fprintf(fpout, "static time_t _psl_compile_time;\n");
fprintf(fpout, "static char _psl_sha1_checksum[]= \"\";\n");
if (fclose(fpout) != 0)
ret = 4;
} else {
fprintf(stderr, "Failed to write open '%s'\n", argv[2]);
ret = 3;
}
#endif // WITH_BUILTIN
return ret; return ret;
} }

View File

@ -112,7 +112,9 @@ int main(int argc, const char * const *argv)
} }
} }
#ifdef WITH_BUILTIN
test_psl(); test_psl();
#endif
if (failed) { if (failed) {
printf("Summary: %d out of %d tests failed\n", failed, ok + failed); printf("Summary: %d out of %d tests failed\n", failed, ok + failed);

View File

@ -150,8 +150,10 @@ int main(int argc, const char * const *argv)
} }
} }
#ifdef WITH_BUILTIN
test_psl(); test_psl();
#endif
if (failed) { if (failed) {
printf("Summary: %d out of %d tests failed\n", failed, ok + failed); printf("Summary: %d out of %d tests failed\n", failed, ok + failed);
return 1; return 1;