Skip to content

Commit

Permalink
build: config_for_build.h for cross, bootstrap config.
Browse files Browse the repository at this point in the history
This should be enough to fix the main bug as reported in #314.
Other cross-compile limitations may still exist.

Signed-off-by: Kang-Che Sung <[email protected]>
  • Loading branch information
Explorer09 committed Jul 14, 2018
1 parent ad3ff0c commit 5956327
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 2 deletions.
3 changes: 3 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,9 @@ AC_CHECK_FUNCS([dup2 memset regcomp strcasecmp strchr strdup strtol], [],
# reallocarray - OpenBSD function. We have replacement if not available.
AC_CHECK_FUNCS([pow setlocale reallocarr reallocarray])

AS_IF([test "$cross_compiling" = yes],
[AC_CONFIG_FILES([src/config_for_build.h])])

AC_CONFIG_FILES(
Makefile
doc/Makefile
Expand Down
1 change: 1 addition & 0 deletions src/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*.o
config.h
config.h.in
config_for_build.h
flex
libfl.pc
parse.c
Expand Down
2 changes: 1 addition & 1 deletion src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ stage1flex_LINK = $(LIBTOOL) --tag=CC --mode=link $(CC_FOR_BUILD) \
$(CFLAGS_FOR_BUILD) $(LDFLAGS_FOR_BUILD) -o $@

$(stage1flex_OBJECTS): CC=$(CC_FOR_BUILD)
$(stage1flex_OBJECTS): CFLAGS=$(CFLAGS_FOR_BUILD)
$(stage1flex_OBJECTS): CFLAGS=$(CFLAGS_FOR_BUILD) -DUSE_CONFIG_FOR_BUILD
$(stage1flex_OBJECTS): CPP=$(CPP_FOR_BUILD)
$(stage1flex_OBJECTS): CPPFLAGS=$(CPPFLAGS_FOR_BUILD)
$(stage1flex_OBJECTS): LDFLAGS=$(LDFLAGS_FOR_BUILD)
Expand Down
81 changes: 81 additions & 0 deletions src/config_for_build.h.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/* config_for_build - minimal config header for bootstrapping flex */

/* This file is part of flex. */

/* Redistribution and use in source and binary forms, with or without */
/* modification, are permitted provided that the following conditions */
/* are met: */

/* 1. Redistributions of source code must retain the above copyright */
/* notice, this list of conditions and the following disclaimer. */
/* 2. Redistributions in binary form must reproduce the above copyright */
/* notice, this list of conditions and the following disclaimer in the */
/* documentation and/or other materials provided with the distribution. */

/* Neither the name of the University nor the names of its contributors */
/* may be used to endorse or promote products derived from this software */
/* without specific prior written permission. */

/* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR */
/* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED */
/* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR */
/* PURPOSE. */

/* The "config_for_build.in" file is intended to be processed by "configure"
* in order to produce working PACKAGE, VERSION and M4 definitions.
* Add "config_for_build.in" to AC_CONFIG_FILES. Do not add it to
* AC_CONFIG_HEADERS as it would break our intentional #undef's and mess up
* with the #define statements.
*/
#define PACKAGE "@PACKAGE@"
#define VERSION "@VERSION@"
#define M4 "@M4@"

#undef ENABLE_NLS
/* Flex includes <locale.h> only if NLS is enabled, but we undef it anyway. */
#undef HAVE_LOCALE_H

#undef HAVE_NETINET_IN_H
#ifdef __has_include
# if __has_include(<netinet/in.h>)
# define HAVE_NETINET_IN_H 1
# endif
#endif

#undef HAVE_REALLOCARRAY
#undef HAVE_REALLOCARR

/* Always use malloc/realloc wrappers. */
#undef malloc
#define malloc rpl_malloc
#undef realloc
#define realloc rpl_realloc

/* The Bison-generated parser in flex code controls the use of alloca() through
* its own macro (YYSTACK_USE_ALLOCA) and not defines from Autoconf.
* alloca() is not used in other parts of flex code.
*/
#undef HAVE_ALLOCA_H
#undef HAVE_ALLOCA
#undef C_ALLOCA

/* HAVE_INTTYPES_H is defined by Autoconf but not used in flex code. Flex has
* flexint.h that provides fallback definitions.
*/
/*
#if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L
# undef HAVE_INTTYPES_H
#endif
*/

#undef HAVE_STDBOOL_H
#if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L
# undef HAVE__BOOL
#endif

/* Standard C89 stuff which "configure" provides fallback #define's for. */
#ifndef __STDC__
# undef HAVE_LIMITS_H
# define const /* const */
# define size_t unsigned int
#endif
6 changes: 5 additions & 1 deletion src/flexdef.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,12 @@
#ifndef FLEXDEF_H
#define FLEXDEF_H 1

#ifdef HAVE_CONFIG_H
#ifndef USE_CONFIG_FOR_BUILD
# ifdef HAVE_CONFIG_H
#include <config.h>
# endif
#else
#include <config_for_build.h>
#endif

#include <stdio.h>
Expand Down

0 comments on commit 5956327

Please sign in to comment.