added ./configure --with-psl-file to set PSL file path

This commit is contained in:
Tim Ruehsen 2014-04-13 16:35:28 +02:00
parent 3fd48b9328
commit c93268ce25
5 changed files with 17 additions and 7 deletions

View File

@ -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}
])

View File

@ -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

View File

@ -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

View File

@ -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++;
}

View File

@ -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));