diff --git a/configure.ac b/configure.ac index 3c75d10..d6d31f8 100644 --- a/configure.ac +++ b/configure.ac @@ -89,6 +89,14 @@ else TESTS_INFO="Valgrind testing not enabled" fi +# Check for custom PSL file +AC_ARG_WITH(psl-file, + AC_HELP_STRING([--with-psl-file=[PATH]], + [path to PSL file]), + PSL_FILE=$withval, + PSL_FILE="\$(top_srcdir)/data/effective_tld_names.dat") +AC_SUBST(PSL_FILE) + # Override the template file name of the generated .pc file, so that there # is no need to rename the template file when the API version changes. AC_CONFIG_FILES([Makefile @@ -111,5 +119,6 @@ AC_MSG_NOTICE([Summary of build options: CFlags: ${CFLAGS} ${CPPFLAGS} LDFlags: ${LDFLAGS} Builtin PSL: ${enable_builtin} + PSL File: ${PSL_FILE} Tests: ${TESTS_INFO} ]) diff --git a/src/Makefile.am b/src/Makefile.am index 05d4e13..0f70961 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -19,5 +19,6 @@ psl2c_CPPFLAGS = -I$(top_srcdir)/include -D _GNU_SOURCE #psl2c_LDADD = -lidn2 # Build rule for suffix.c -suffixes.c: $(top_srcdir)/data/effective_tld_names.dat psl2c$(EXEEXT) - ./psl2c$(EXEEXT) $(top_srcdir)/data/effective_tld_names.dat suffixes.c +# PSL_FILE can be set by ./configure --with-psl-file=[PATH] +suffixes.c: $(PSL_FILE) psl2c$(EXEEXT) + ./psl2c$(EXEEXT) "$(PSL_FILE)" suffixes.c diff --git a/tests/Makefile.am b/tests/Makefile.am index d5b9e06..e867f17 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,4 +1,4 @@ -DEFS = @DEFS@ -DDATADIR=\"$(top_srcdir)/data\" -DSRCDIR=\"$(srcdir)\" +DEFS = @DEFS@ -DDATADIR=\"$(top_srcdir)/data\" -DSRCDIR=\"$(srcdir)\" -DPSL_FILE=\"$(PSL_FILE)\" AM_CPPFLAGS = -I$(top_srcdir)/include LDADD = ../src/libpsl-@LIBPSL_API_VERSION@.la diff --git a/tests/test-is-public-all.c b/tests/test-is-public-all.c index a784dec..91f6098 100644 --- a/tests/test-is-public-all.c +++ b/tests/test-is-public-all.c @@ -50,11 +50,11 @@ static void test_psl(void) int result; char buf[256], domain[64], *linep, *p; - psl = psl_load_file(DATADIR "/effective_tld_names.dat"); + psl = psl_load_file(PSL_FILE); // PSL_FILE can be set by ./configure --with-psl-file=[PATH] printf("loaded %d suffixes and %d exceptions\n", psl_suffix_count(psl), psl_suffix_exception_count(psl)); - if ((fp = fopen(DATADIR "/effective_tld_names.dat", "r"))) { + if ((fp = fopen(PSL_FILE, "r"))) { while ((linep = fgets(buf, sizeof(buf), fp))) { while (isspace(*linep)) linep++; // ignore leading whitespace if (!*linep) continue; // skip empty lines @@ -105,7 +105,7 @@ static void test_psl(void) fclose(fp); } else { - printf("Failed to open %s\n", DATADIR "/effective_tld_names.dat"); + printf("Failed to open %s\n", PSL_FILE); failed++; } diff --git a/tests/test-is-public.c b/tests/test-is-public.c index c6dc149..24cb32e 100644 --- a/tests/test-is-public.c +++ b/tests/test-is-public.c @@ -70,7 +70,7 @@ static void test_psl(void) unsigned it; psl_ctx_t *psl; - psl = psl_load_file(DATADIR "/effective_tld_names.dat"); + psl = psl_load_file(PSL_FILE); printf("loaded %d suffixes and %d exceptions\n", psl_suffix_count(psl), psl_suffix_exception_count(psl));