From 26aeb0ebec546899168d98f9fe0b25de2bc7a8c5 Mon Sep 17 00:00:00 2001 From: Rinigus Date: Thu, 5 Jan 2017 07:34:24 +0200 Subject: [PATCH] drop AC_FUNC_MALLOC and _REALLOC and check for them as regular functions; add extra cflags for scanner --- configure.ac | 18 +++++++++++++++--- src/Makefile.am | 4 +++- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/configure.ac b/configure.ac index f7cbc42d..321e8f0a 100644 --- a/configure.ac +++ b/configure.ac @@ -45,10 +45,8 @@ AC_TYPE_UINT8_T AC_CHECK_TYPES([ptrdiff_t]) # Checks for library functions. -AC_FUNC_MALLOC AC_FUNC_MMAP -AC_FUNC_REALLOC -AC_CHECK_FUNCS([getcwd gettimeofday memmove memset munmap regcomp setlocale sqrt strdup strndup]) +AC_CHECK_FUNCS([malloc realloc getcwd gettimeofday memmove memset munmap regcomp setlocale sqrt strdup strndup]) AC_CONFIG_FILES([Makefile libpostal.pc @@ -70,4 +68,18 @@ AC_ARG_ENABLE([data-download], AM_CONDITIONAL([DOWNLOAD_DATA], [test "x$DOWNLOAD_DATA" = "xtrue"]) +AC_ARG_WITH(cflags-scanner-extra, [AS_HELP_STRING([--with-cflags-scanner-extra@<:@=VALUE@:>@], [Extra compilation options for scanner.c])], +[ + if test "x$withval" = "xno"; then + CFLAGS_SCANNER_EXTRA="" + else + CFLAGS_SCANNER_EXTRA="$withval" + fi +], +[ CFLAGS_SCANNER_EXTRA="" ] +) + +AC_MSG_NOTICE([extra cflags for scanner.c: $CFLAGS_SCANNER_EXTRA]) +AC_SUBST(CFLAGS_SCANNER_EXTRA) + AC_OUTPUT diff --git a/src/Makefile.am b/src/Makefile.am index 82c9cecc..887f7c78 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -22,9 +22,11 @@ libpostal_la_CFLAGS = $(CFLAGS_O2) dist_bin_SCRIPTS = libpostal_data # Scanner can take a very long time to compile with higher optimization levels, so always use -O0, scanner is fast enough +# On cross-compilation for ARM using gcc-4.7, there are "out of range" errors during compilation that can be fixed by adding +# -marm option. For that, CFLAGS_SCANNER_EXTRA is provided that can be filled during configuration stage (see ./configure --help). noinst_LTLIBRARIES = libscanner.la libscanner_la_SOURCES = scanner.c -libscanner_la_CFLAGS = $(CFLAGS_O0) +libscanner_la_CFLAGS = $(CFLAGS_O0) $(CFLAGS_SCANNER_EXTRA) noinst_PROGRAMS = libpostal bench build_address_dictionary build_geodb build_numex_table build_trans_table address_parser_train address_parser_test address_parser language_classifier_train language_classifier language_classifier_test libpostal_SOURCES = main.c json_encode.c