diff --git a/configure.ac b/configure.ac index 9fb937d..9807e79 100644 --- a/configure.ac +++ b/configure.ac @@ -25,6 +25,19 @@ AM_GNU_GETTEXT_VERSION([0.18.1]) AC_SUBST([LIBPSL_SO_VERSION], [0:0:0]) 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 ac_enable_valgrind=no AC_ARG_ENABLE(valgrind-tests, @@ -63,6 +76,6 @@ AC_MSG_NOTICE([Summary of build options: Compiler: ${CC} CFlags: ${CFLAGS} ${CPPFLAGS} LDFlags: ${LDFLAGS} + Builtin PSL: ${enable_builtin} Tests: ${TESTS_INFO} ]) - diff --git a/src/psl2c.c b/src/psl2c.c index 7c9f826..1c29d84 100644 --- a/src/psl2c.c +++ b/src/psl2c.c @@ -43,6 +43,8 @@ //# include //#endif +#ifdef WITH_BUILTIN + #include typedef struct { @@ -340,11 +342,14 @@ static void _add_punycode_if_needed(_psl_vector_t *v) _vector_sort(v); } +#endif // WITH_BUILTIN int main(int argc, const char **argv) { FILE *fpout; +#ifdef WITH_BUILTIN psl_ctx_t *psl; +#endif int ret = 0; if (argc != 3) { @@ -354,6 +359,7 @@ int main(int argc, const char **argv) return 1; } +#ifdef WITH_BUILTIN if (!(psl = psl_load_file(argv[1]))) return 2; @@ -389,5 +395,22 @@ int main(int argc, const char **argv) } 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; } diff --git a/tests/test-is-public-builtin.c b/tests/test-is-public-builtin.c index f563038..13f7e5b 100644 --- a/tests/test-is-public-builtin.c +++ b/tests/test-is-public-builtin.c @@ -112,7 +112,9 @@ int main(int argc, const char * const *argv) } } +#ifdef WITH_BUILTIN test_psl(); +#endif if (failed) { printf("Summary: %d out of %d tests failed\n", failed, ok + failed); diff --git a/tests/test-registrable-domain.c b/tests/test-registrable-domain.c index 8534ea9..7afecf8 100644 --- a/tests/test-registrable-domain.c +++ b/tests/test-registrable-domain.c @@ -150,8 +150,10 @@ int main(int argc, const char * const *argv) } } +#ifdef WITH_BUILTIN test_psl(); - +#endif + if (failed) { printf("Summary: %d out of %d tests failed\n", failed, ok + failed); return 1;