0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-28 00:14:07 +01:00

Merge pull request #203 from jevolk/master

Bison C++ linkage + build improvements
This commit is contained in:
Jason Volk 2016-07-25 10:56:37 -07:00 committed by GitHub
commit b68010df31
19 changed files with 150 additions and 117 deletions

View file

@ -108,6 +108,11 @@ cache:
script: script:
- export CC=$CCOMPILER CXX=$CXXCOMPILER - export CC=$CCOMPILER CXX=$CXXCOMPILER
- git rev-parse --verify HEAD
- m4 --version
- autoconf --version
- automake --version
- make --version
- $CC --version - $CC --version
- $CXX --version - $CXX --version
- time bash autogen.sh - time bash autogen.sh

View file

@ -18,6 +18,9 @@ SUBDIRS += tools
SUBDIRS += help SUBDIRS += help
SUBDIRS += doc SUBDIRS += doc
.PHONY: subdirs $(SUBDIRS)
$(SUBDIRS):
$(MAKE) -C $@
mrproper-local: mrproper-local:
rm -f aclocal.m4 rm -f aclocal.m4

View file

@ -76,12 +76,13 @@
* - Dianora * - Dianora
*/ */
#ifndef _WIN32
#include <netdb.h>
#endif
#include <rb/rb.h> #include <rb/rb.h>
#ifndef _WIN32 #ifndef _WIN32
#include <netdb.h>
typedef struct addrinfo rb_addrinfo; typedef struct addrinfo rb_addrinfo;
#else #else

View file

@ -3,7 +3,7 @@ dnl the most major changes have already been made and it looks like
dnl said functions need to be just about as complex as they already are. dnl said functions need to be just about as complex as they already are.
AC_PREREQ(2.63) AC_PREREQ(2.63)
AUTOMAKE_OPTIONS = 1.14 AUTOMAKE_OPTIONS = 1.11
AC_INIT([charybdis], [5-dev]) AC_INIT([charybdis], [5-dev])
AC_GNU_SOURCE AC_GNU_SOURCE
@ -254,12 +254,7 @@ AC_DEFUN([RB_CHK_SYSHEADER],
AC_DEFINE([HAVE_$2], [1], [ Indication $1 is available. ]) AC_DEFINE([HAVE_$2], [1], [ Indication $1 is available. ])
RB_DEFINE_UNQUOTED([INC_$2], [$1>], [ The computed-include location of $1. ]) RB_DEFINE_UNQUOTED([INC_$2], [$1>], [ The computed-include location of $1. ])
], [ ], [
AM_COND_IF([MINGW], RB_DEFINE_UNQUOTED([INC_$2], [stddef.h>], [ The dead-header in place of $1. ])
[
RB_DEFINE_UNQUOTED([INC_$2], [stdint.h>], [ The dead-header in place of $1. ])
], [
RB_DEFINE_UNQUOTED([INC_$2], [/dev/null>], [ The dead-header in place of $1. ])
])
]) ])
]) ])
@ -780,7 +775,7 @@ dnl
AC_MSG_CHECKING([whether to use boost sources included here]) AC_MSG_CHECKING([whether to use boost sources included here])
AC_ARG_WITH(included-boost, AC_ARG_WITH(included-boost,
AC_HELP_STRING([--with-included-boost], [Use the boost sources from included submodule]), AC_HELP_STRING([--with-included-boost[[[=shared]]]], [Use the boost sources from included submodule]),
[ [
AC_MSG_RESULT([yes]) AC_MSG_RESULT([yes])
AC_MSG_NOTICE([Bootstrapping boost]) AC_MSG_NOTICE([Bootstrapping boost])
@ -798,17 +793,30 @@ AC_HELP_STRING([--with-included-boost], [Use the boost sources from included sub
AC_MSG_ERROR([Failed to build included boost.]) AC_MSG_ERROR([Failed to build included boost.])
fi fi
AC_MSG_NOTICE([Bootstrapping boost: done])
AC_SUBST(BOOST_CPPFLAGS, "-isystem $PWD/boost/include")
AM_COND_IF([MINGW], AM_COND_IF([MINGW],
[ [
AC_SUBST(BOOST_LDFLAGS, "-L$PWD/boost/stage/lib") boost_libdir="$PWD/boost/stage/lib"
], [ ], [
AC_SUBST(BOOST_LDFLAGS, "-L$PWD/boost/lib") boost_libdir="$PWD/boost/lib"
]) ])
AC_SUBST(BOOST_CPPFLAGS, ["-isystem $PWD/boost/include"])
AC_SUBST(BOOST_LDFLAGS, ["-L$boost_libdir"])
boost_linkage="$withval"
AC_MSG_CHECKING([whether to use shared boost])
if [[ $withval = "shared" ]]; then
AC_MSG_RESULT([yes])
BOOST_LDFLAGS += " -Wl,-rpath -Wl,$boost_libdir"
else
AC_MSG_RESULT([no])
fi
AC_DEFINE(HAVE_LIB_BOOST_SYSTEM, 1, [Define if you have boost_system])
AC_MSG_NOTICE([Bootstrapping boost: done])
],[ ],[
AC_MSG_RESULT([no])
AC_SEARCH_LIBS(boost_system, boost_system, AC_SEARCH_LIBS(boost_system, boost_system,
[ [
AC_DEFINE(HAVE_LIB_BOOST_SYSTEM, 1, [Define if you have boost_system]) AC_DEFINE(HAVE_LIB_BOOST_SYSTEM, 1, [Define if you have boost_system])
@ -818,17 +826,23 @@ AC_HELP_STRING([--with-included-boost], [Use the boost sources from included sub
AC_SUBST(BOOST_CPPFLAGS, "") AC_SUBST(BOOST_CPPFLAGS, "")
AC_SUBST(BOOST_LDFLAGS, "") AC_SUBST(BOOST_LDFLAGS, "")
AC_MSG_RESULT([no])
])
AM_COND_IF([MINGW],
[
dnl TODO
AC_SUBST(BOOST_LIBS, "-lboost_system-mgw53-1_61.dll")
], [
AC_SUBST(BOOST_LIBS, "-lboost_system")
]) ])
if [[ "$boost_linkage" = "shared" ]]; then
AM_COND_IF([MINGW],
[
AC_SUBST(BOOST_LIBS, ["-lboost_system-mgw53-1_61.dll"])
], [
AC_SUBST(BOOST_LIBS, ["-lboost_system"])
])
else
AM_COND_IF([MINGW],
[
AC_SUBST(BOOST_LIBS, ["$boost_libdir/libboost_system-mgw53-1_61.dll.a"])
], [
AC_SUBST(BOOST_LIBS, ["$boost_libdir/libboost_system.a"])
])
fi
AC_DEFINE([HAVE_BOOST_ASIO_HPP], [1], [ boost asio. ]) AC_DEFINE([HAVE_BOOST_ASIO_HPP], [1], [ boost asio. ])
RB_DEFINE_UNQUOTED([INC_BOOST_ASIO_HPP], [boost/asio.hpp>], [ boost asio. ]) RB_DEFINE_UNQUOTED([INC_BOOST_ASIO_HPP], [boost/asio.hpp>], [ boost asio. ])

View file

@ -5,6 +5,10 @@ AM_CPPFLAGS = \
$(LTDLINCL) \ $(LTDLINCL) \
@BOOST_CPPFLAGS@ @BOOST_CPPFLAGS@
if BUILD_PCH
AM_CPPFLAGS += -include $(top_srcdir)/include/rb/rb.pic.h
endif
AM_LDFLAGS = \ AM_LDFLAGS = \
-L$(top_srcdir)/ircd \ -L$(top_srcdir)/ircd \
-L$(top_srcdir)/rb \ -L$(top_srcdir)/rb \

View file

@ -54,7 +54,7 @@ struct Client;
extern void init_main_logfile(void); extern void init_main_logfile(void);
extern void open_logfiles(void); extern void open_logfiles(void);
extern void close_logfiles(void); extern void close_logfiles(void);
RB_EXTERN_C void ilog(ilogfile dest, const char *fmt, ...) AFP(2, 3); void ilog(ilogfile dest, const char *fmt, ...) AFP(2, 3);
extern void idebug(const char *fmt, ...) AFP(1, 2); extern void idebug(const char *fmt, ...) AFP(1, 2);
extern void inotice(const char *fmt, ...) AFP(1, 2); extern void inotice(const char *fmt, ...) AFP(1, 2);
extern void iwarn(const char *fmt, ...) AFP(1, 2); extern void iwarn(const char *fmt, ...) AFP(1, 2);

View file

@ -189,9 +189,9 @@ extern void load_all_modules(bool warn);
extern void load_core_modules(bool); extern void load_core_modules(bool);
extern bool unload_one_module(const char *, bool); extern bool unload_one_module(const char *, bool);
RB_EXTERN_C bool load_one_module(const char *, int, bool); bool load_one_module(const char *, int, bool);
extern bool load_a_module(const char *, bool, int, bool); extern bool load_a_module(const char *, bool, int, bool);
RB_EXTERN_C struct module *findmodule_byname(const char *); struct module *findmodule_byname(const char *);
extern void init_modules(void); extern void init_modules(void);
extern rb_dlink_list module_list; extern rb_dlink_list module_list;

View file

@ -63,11 +63,11 @@ extern struct TopConf *conf_cur_block;
extern char *current_file; extern char *current_file;
int read_config(char *); int read_config(char *);
RB_EXTERN_C int conf_start_block(char *, char *); int conf_start_block(char *, char *);
RB_EXTERN_C int conf_end_block(struct TopConf *); int conf_end_block(struct TopConf *);
RB_EXTERN_C int conf_call_set(struct TopConf *, char *, conf_parm_t *); int conf_call_set(struct TopConf *, char *, conf_parm_t *);
RB_EXTERN_C void conf_report_error(const char *, ...); void conf_report_error(const char *, ...);
RB_EXTERN_C void conf_report_warning(const char *, ...); void conf_report_warning(const char *, ...);
void newconf_init(void); void newconf_init(void);
int add_conf_item(const char *topconf, const char *name, int type, void (*func) (void *)); int add_conf_item(const char *topconf, const char *name, int type, void (*func) (void *));
int remove_conf_item(const char *topconf, const char *name); int remove_conf_item(const char *topconf, const char *name);

View file

@ -357,9 +357,9 @@ extern char *get_user_ban_reason(struct ConfItem *aconf);
extern void get_printable_kline(struct Client *, struct ConfItem *, extern void get_printable_kline(struct Client *, struct ConfItem *,
char **, char **, char **, char **); char **, char **, char **, char **);
RB_EXTERN_C void yyerror(const char *); void yyerror(const char *);
RB_EXTERN_C int conf_yy_fatal_error(const char *); int conf_yy_fatal_error(const char *);
RB_EXTERN_C int conf_fgets(char *, int, FILE *); int conf_fgets(char *, int, FILE *);
extern int valid_wild_card(const char *, const char *); extern int valid_wild_card(const char *, const char *);
extern void add_temp_kline(struct ConfItem *); extern void add_temp_kline(struct ConfItem *);

View file

@ -22,64 +22,4 @@
*/ */
#include <rb/rb.h> #include <rb/rb.h>
#include "defaults.h" /* Needed for some reasons here -- dwr */ #include "defaults.h"
/* AIX requires this to be the first thing in the file. */
#ifdef __GNUC__
#undef alloca
#define alloca __builtin_alloca
#else
# ifdef _MSC_VER
# include <malloc.h>
# define alloca _alloca
# else
# if HAVE_ALLOCA_H
# include <alloca.h>
# else
# ifdef _AIX
#pragma alloca
# else
# ifndef alloca /* predefined by HP cc +Olibcalls */
char *alloca ();
# endif
# endif
# endif
# endif
#endif
#ifdef HAVE_ERRNO_H
#else
extern int errno;
#endif
#if defined(__INTEL_COMPILER) || defined(__GNUC__)
# ifdef __unused
# undef __unused
# endif
# ifdef __printf
# undef __printf
# endif
# ifdef __noreturn
# undef __noreturn
# endif
# define __unused __attribute__((__unused__))
# define __printf(x) __attribute__((__format__ (__printf__, x, x + 1)))
# define __noreturn __attribute__((__noreturn__))
#else
# define __unused
# define __printf
# define __noreturn
#endif
#ifdef strdupa
#define LOCAL_COPY(s) strdupa(s)
#else
#if defined(__INTEL_COMPILER) || defined(__GNUC__)
# define LOCAL_COPY(s) __extension__({ char *_s = (char *)alloca(strlen(s) + 1); strcpy(_s, s); _s; })
#else
# define LOCAL_COPY(s) strcpy((char *)alloca(strlen(s) + 1), s)
#endif /* defined(__INTEL_COMPILER) || defined(__GNUC__) */
#endif /* strdupa */

View file

@ -1 +1,2 @@
config.h* config.h*
rb.pic.h

View file

@ -7,14 +7,20 @@ AM_CXXFLAGS = -fpch-deps
endif endif
if BUILD_PCH if BUILD_PCH
BUILT_SOURCES = rb.h.gch BUILT_SOURCES = rb.h.gch rb.pic.h.gch
endif endif
rb.h.gch: rb.h.gch:
$(CXX) $(CXXFLAGS) $(AM_CXXFLAGS) -o rb.h.gch $(DEFS) $(CPPFLAGS) $(AM_CPPFLAGS) rb.h $(CXX) $(CXXFLAGS) $(AM_CXXFLAGS) -o rb.h.gch $(DEFS) $(CPPFLAGS) $(AM_CPPFLAGS) rb.h
rb.pic.h.gch:
cp rb.h rb.pic.h
$(CXX) $(CXXFLAGS) $(AM_CXXFLAGS) -fPIC -o rb.pic.h.gch $(DEFS) $(CPPFLAGS) $(AM_CPPFLAGS) rb.pic.h
clean-local: clean-local:
rm -f rb.h.gch rm -f rb.h.gch
rm -f rb.pic.h
rm -f rb.pic.h.gch
mrproper-local: mrproper-local:
rm -f config.h rm -f config.h

View file

@ -92,6 +92,41 @@ char *alloca();
#define rb_unlikely(x) (x) #define rb_unlikely(x) (x)
#endif #endif
#if defined(__INTEL_COMPILER) || defined(__GNUC__)
#ifdef __unused
#undef __unused
#endif
#ifdef __printf
#undef __printf
#endif
#ifdef __noreturn
#undef __noreturn
#endif
#define __unused __attribute__((__unused__))
#define __printf(x) __attribute__((__format__ (__printf__, x, x + 1)))
#define __noreturn __attribute__((__noreturn__))
#else
#ifndef __unused
#define __unused
#endif
#ifndef __printf
#define __printf
#endif
#ifndef __noreturn
#define __noreturn
#endif
#endif
#ifdef _WIN32 #ifdef _WIN32
#define rb_get_errno() do { errno = WSAGetLastError(); WSASetLastError(errno); } while(0) #define rb_get_errno() do { errno = WSAGetLastError(); WSASetLastError(errno); } while(0)
typedef SOCKET rb_platform_fd_t; typedef SOCKET rb_platform_fd_t;
@ -321,6 +356,17 @@ while(0)
#endif #endif
#ifdef strdupa
#define LOCAL_COPY(s) strdupa(s)
#else
#if defined(__INTEL_COMPILER) || defined(__GNUC__)
#define LOCAL_COPY(s) __extension__({ char *_s = (char *)alloca(strlen(s) + 1); strcpy(_s, s); _s; })
#else
#define LOCAL_COPY(s) strcpy((char *)alloca(strlen(s) + 1), s)
#endif
#endif
#ifdef __cplusplus #ifdef __cplusplus
} // extern "C" } // extern "C"
#endif #endif

7
ircd/.gitignore vendored
View file

@ -1,3 +1,4 @@
ircd_parser.h ircd_parser.h*
ircd_parser.c ircd_parser.c*
ircd_lexer.c ircd_lexer.c*
stack.hh

View file

@ -2,14 +2,19 @@ AUTOMAKE_OPTIONS = foreign
libircddir = @libdir@ libircddir = @libdir@
AM_YFLAGS = -d # --language=c++ # NOTE: the c++ version has a radically different API
AM_LFLAGS = # --c++ #AM_YFLAGS = -d --language=c++
AM_YFLAGS = -d
AM_CPPFLAGS = \ AM_CPPFLAGS = \
-I$(top_srcdir)/include \ -I$(top_srcdir)/include \
@LTDLINCL@ \ @LTDLINCL@ \
@BOOST_CPPFLAGS@ @BOOST_CPPFLAGS@
if BUILD_PCH
AM_CPPFLAGS += -include $(top_srcdir)/include/rb/rb.pic.h
endif
if MINGW if MINGW
PLATFORM_LDFLAGS = -Wl,--enable-runtime-pseudo-reloc -export-symbols-regex '*' PLATFORM_LDFLAGS = -Wl,--enable-runtime-pseudo-reloc -export-symbols-regex '*'
endif endif
@ -24,8 +29,7 @@ AM_LDFLAGS += \
-L$(top_srcdir)/rb \ -L$(top_srcdir)/rb \
@BOOST_LDFLAGS@ @BOOST_LDFLAGS@
BUILT_SOURCES = ircd_parser.h BUILT_SOURCES = ircd_lexer.cc ircd_parser.cc
libircd_LTLIBRARIES = libircd.la libircd_LTLIBRARIES = libircd.la
@ -50,8 +54,8 @@ libircd_la_SOURCES = \
hook.cc \ hook.cc \
hostmask.cc \ hostmask.cc \
ircd.cc \ ircd.cc \
ircd_parser.y \ ircd_lexer.cc \
ircd_lexer.l \ ircd_parser.cc \
ircd_signal.cc \ ircd_signal.cc \
listener.cc \ listener.cc \
logger.cc \ logger.cc \
@ -82,11 +86,17 @@ libircd_la_SOURCES = \
whowas.cc \ whowas.cc \
wsproc.cc wsproc.cc
ircd_lexer.cc:
flex $(AM_LFLAGS) -o ircd_lexer.cc ircd_lexer.ll
ircd_parser.cc:
$(YACC) $(AM_YFLAGS) -o ircd_parser.cc ircd_parser.yy
install-data-local: install-data-local:
test -d $(prefix)/@logdir@ || mkdir -p $(prefix)/@logdir@ test -d $(prefix)/@logdir@ || mkdir -p $(prefix)/@logdir@
clean-local: clean-local:
rm -f ircd_lexer.c rm -f ircd_lexer.c ircd_lexer.cc
rm -f ircd_parser.c rm -f ircd_parser.c ircd_parser.cc
rm -f ircd_parser.h rm -f ircd_parser.h ircd_parser.hh
rm -f stack.hh

View file

@ -30,9 +30,8 @@
#include <ircd/newconf.h> #include <ircd/newconf.h>
#include <ircd/s_conf.h> #include <ircd/s_conf.h>
#include <ircd/logger.h> #include <ircd/logger.h>
#include "ircd_parser.h" #include "ircd_parser.hh"
int yyparse(void);
void yyerror(const char *); void yyerror(const char *);
YY_BUFFER_STATE include_stack[MAX_INCLUDE_DEPTH]; YY_BUFFER_STATE include_stack[MAX_INCLUDE_DEPTH];
@ -144,11 +143,11 @@ int c;
/* log(L_NOTICE, "got comment"); */ /* log(L_NOTICE, "got comment"); */
while (1) while (1)
{ {
while ((c = input()) != '*' && c != EOF) while ((c = yyinput()) != '*' && c != EOF)
if (c == '\n') ++lineno; if (c == '\n') ++lineno;
if (c == '*') if (c == '*')
{ {
while ((c = input()) == '*'); while ((c = yyinput()) == '*');
if (c == '/') if (c == '/')
break; break;
if (c == '\n') ++lineno; if (c == '\n') ++lineno;

View file

@ -11,7 +11,6 @@
#include <ircd/newconf.h> #include <ircd/newconf.h>
#include <ircd/s_conf.h> #include <ircd/s_conf.h>
#include <ircd/logger.h> #include <ircd/logger.h>
#include "ircd_parser.h"
int yylex(); int yylex();
void yyerror(const char *); void yyerror(const char *);

View file

@ -54,7 +54,7 @@
struct config_server_hide ConfigServerHide; struct config_server_hide ConfigServerHide;
RB_EXTERN_C int yyparse(void); int yyparse(void);
extern char yy_linebuf[16384]; /* defined in ircd_lexer.l */ extern char yy_linebuf[16384]; /* defined in ircd_lexer.l */
static rb_bh *confitem_heap = NULL; static rb_bh *confitem_heap = NULL;

View file

@ -6,6 +6,10 @@ AM_CPPFLAGS = \
$(LTDLINCL) \ $(LTDLINCL) \
@BOOST_CPPFLAGS@ @BOOST_CPPFLAGS@
if BUILD_PCH
AM_CPPFLAGS += -include $(top_srcdir)/include/rb/rb.pic.h
endif
AM_LDFLAGS = \ AM_LDFLAGS = \
-L$(top_srcdir)/ircd \ -L$(top_srcdir)/ircd \
-L$(top_srcdir)/rb \ -L$(top_srcdir)/rb \