Clean up the libunbound build to avoid accidentally regenerating the

configuration lexer and parser during buildworld.  Instead of being
included in the source as it is in the upstream distribution, the code is
now always generated (in ${.OBJDIR}) at build time.

PR:		190739
MFC after:	1 week
This commit is contained in:
Dag-Erling Smørgrav 2014-07-19 18:38:48 +00:00
parent 34a856a200
commit e8263e185c
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=268883
8 changed files with 50 additions and 6217 deletions

View file

@ -32,13 +32,6 @@ autoheader
--with-run-dir=/var/unbound \
--with-username=unbound
# Regenerate the configuration parser
{
cat <<EOF
#include "config.h"
#include "util/configyyrename.h"
EOF
/usr/bin/flex -L -t util/configlexer.lex
} >util/configlexer.c
/usr/bin/yacc -d -o util/configparser.c util/configparser.y
# Don't try to provide bogus memory usage statistics based on sbrk(2).
sed -n -i.orig -e '/HAVE_SBRK/!p' config.status
./config.status config.h

View file

@ -48,7 +48,7 @@
#include "util/log.h"
#include "util/configyyrename.h"
#include "util/config_file.h"
#include "util/configparser.h"
#include "configparser.h"
#include "util/net_help.h"
#include "util/data/msgparse.h"
#include "util/module.h"

File diff suppressed because it is too large Load diff

View file

@ -8,6 +8,8 @@
*
*/
#include "config.h"
#include <ctype.h>
#include <string.h>
#include <strings.h>
@ -16,7 +18,7 @@
#endif
#include "util/config_file.h"
#include "util/configparser.h"
#include "configparser.h"
void ub_c_error(const char *message);
#if 0
@ -26,13 +28,13 @@ void ub_c_error(const char *message);
#endif
/** avoid warning in about fwrite return value */
#define ECHO ub_c_error_msg("syntax error at text: %s", yytext)
#define ECHO ub_c_error_msg("syntax error at text: %s", ub_c_text)
/** A parser variable, this is a statement in the config file which is
* of the form variable: value1 value2 ... nargs is the number of values. */
#define YDVAR(nargs, var) \
num_args=(nargs); \
LEXOUT(("v(%s%d) ", yytext, num_args)); \
LEXOUT(("v(%s%d) ", ub_c_text, num_args)); \
if(num_args > 0) { BEGIN(val); } \
return (var);
@ -166,7 +168,7 @@ static void config_end_include(void)
#define yy_set_bol(at_bol) \
{ \
if ( ! yy_current_buffer ) \
yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \
yy_current_buffer = yy_create_buffer( ub_c_in, YY_BUF_SIZE ); \
yy_current_buffer->yy_ch_buf[0] = ((at_bol)?'\n':' '); \
}
#endif
@ -200,7 +202,7 @@ SQANY [^\'\n\r\\]|\\.
LEXOUT(("SP ")); /* ignore */ }
<INITIAL,val>{SPACE}*{COMMENT}.* {
/* note that flex makes the longest match and '.' is any but not nl */
LEXOUT(("comment(%s) ", yytext)); /* ignore */ }
LEXOUT(("comment(%s) ", ub_c_text)); /* ignore */ }
server{COLON} { YDVAR(0, VAR_SERVER) }
num-threads{COLON} { YDVAR(1, VAR_NUM_THREADS) }
verbosity{COLON} { YDVAR(1, VAR_VERBOSITY) }
@ -331,71 +333,71 @@ max-udp-size{COLON} { YDVAR(1, VAR_MAX_UDP_SIZE) }
/* Quoted strings. Strip leading and ending quotes */
<val>\" { BEGIN(quotedstring); LEXOUT(("QS ")); }
<quotedstring><<EOF>> {
yyerror("EOF inside quoted string");
ub_c_error("EOF inside quoted string");
if(--num_args == 0) { BEGIN(INITIAL); }
else { BEGIN(val); }
}
<quotedstring>{DQANY}* { LEXOUT(("STR(%s) ", yytext)); yymore(); }
<quotedstring>{NEWLINE} { yyerror("newline inside quoted string, no end \"");
<quotedstring>{DQANY}* { LEXOUT(("STR(%s) ", ub_c_text)); yymore(); }
<quotedstring>{NEWLINE} { ub_c_error("newline inside quoted string, no end \"");
cfg_parser->line++; BEGIN(INITIAL); }
<quotedstring>\" {
LEXOUT(("QE "));
if(--num_args == 0) { BEGIN(INITIAL); }
else { BEGIN(val); }
yytext[yyleng - 1] = '\0';
yylval.str = strdup(yytext);
if(!yylval.str)
yyerror("out of memory");
ub_c_text[ub_c_leng - 1] = '\0';
ub_c_lval.str = strdup(ub_c_text);
if(!ub_c_lval.str)
ub_c_error("out of memory");
return STRING_ARG;
}
/* Single Quoted strings. Strip leading and ending quotes */
<val>\' { BEGIN(singlequotedstr); LEXOUT(("SQS ")); }
<singlequotedstr><<EOF>> {
yyerror("EOF inside quoted string");
ub_c_error("EOF inside quoted string");
if(--num_args == 0) { BEGIN(INITIAL); }
else { BEGIN(val); }
}
<singlequotedstr>{SQANY}* { LEXOUT(("STR(%s) ", yytext)); yymore(); }
<singlequotedstr>{NEWLINE} { yyerror("newline inside quoted string, no end '");
<singlequotedstr>{SQANY}* { LEXOUT(("STR(%s) ", ub_c_text)); yymore(); }
<singlequotedstr>{NEWLINE} { ub_c_error("newline inside quoted string, no end '");
cfg_parser->line++; BEGIN(INITIAL); }
<singlequotedstr>\' {
LEXOUT(("SQE "));
if(--num_args == 0) { BEGIN(INITIAL); }
else { BEGIN(val); }
yytext[yyleng - 1] = '\0';
yylval.str = strdup(yytext);
if(!yylval.str)
yyerror("out of memory");
ub_c_text[ub_c_leng - 1] = '\0';
ub_c_lval.str = strdup(ub_c_text);
if(!ub_c_lval.str)
ub_c_error("out of memory");
return STRING_ARG;
}
/* include: directive */
<INITIAL,val>include{COLON} {
LEXOUT(("v(%s) ", yytext)); inc_prev = YYSTATE; BEGIN(include); }
LEXOUT(("v(%s) ", ub_c_text)); inc_prev = YYSTATE; BEGIN(include); }
<include><<EOF>> {
yyerror("EOF inside include directive");
ub_c_error("EOF inside include directive");
BEGIN(inc_prev);
}
<include>{SPACE}* { LEXOUT(("ISP ")); /* ignore */ }
<include>{NEWLINE} { LEXOUT(("NL\n")); cfg_parser->line++;}
<include>\" { LEXOUT(("IQS ")); BEGIN(include_quoted); }
<include>{UNQUOTEDLETTER}* {
LEXOUT(("Iunquotedstr(%s) ", yytext));
config_start_include_glob(yytext);
LEXOUT(("Iunquotedstr(%s) ", ub_c_text));
config_start_include_glob(ub_c_text);
BEGIN(inc_prev);
}
<include_quoted><<EOF>> {
yyerror("EOF inside quoted string");
ub_c_error("EOF inside quoted string");
BEGIN(inc_prev);
}
<include_quoted>{DQANY}* { LEXOUT(("ISTR(%s) ", yytext)); yymore(); }
<include_quoted>{NEWLINE} { yyerror("newline before \" in include name");
<include_quoted>{DQANY}* { LEXOUT(("ISTR(%s) ", ub_c_text)); yymore(); }
<include_quoted>{NEWLINE} { ub_c_error("newline before \" in include name");
cfg_parser->line++; BEGIN(inc_prev); }
<include_quoted>\" {
LEXOUT(("IQE "));
yytext[yyleng - 1] = '\0';
config_start_include_glob(yytext);
ub_c_text[ub_c_leng - 1] = '\0';
config_start_include_glob(ub_c_text);
BEGIN(inc_prev);
}
<INITIAL,val><<EOF>> {
@ -404,21 +406,21 @@ max-udp-size{COLON} { YDVAR(1, VAR_MAX_UDP_SIZE) }
if (!config_include_stack) {
yyterminate();
} else {
fclose(yyin);
fclose(ub_c_in);
config_end_include();
}
}
<val>{UNQUOTEDLETTER}* { LEXOUT(("unquotedstr(%s) ", yytext));
<val>{UNQUOTEDLETTER}* { LEXOUT(("unquotedstr(%s) ", ub_c_text));
if(--num_args == 0) { BEGIN(INITIAL); }
yylval.str = strdup(yytext); return STRING_ARG; }
ub_c_lval.str = strdup(ub_c_text); return STRING_ARG; }
{UNQUOTEDLETTER_NOCOLON}* {
ub_c_error_msg("unknown keyword '%s'", yytext);
ub_c_error_msg("unknown keyword '%s'", ub_c_text);
}
<*>. {
ub_c_error_msg("stray '%s'", yytext);
ub_c_error_msg("stray '%s'", ub_c_text);
}
%%

File diff suppressed because it is too large Load diff

View file

@ -1,142 +0,0 @@
#define SPACE 257
#define LETTER 258
#define NEWLINE 259
#define COMMENT 260
#define COLON 261
#define ANY 262
#define ZONESTR 263
#define STRING_ARG 264
#define VAR_SERVER 265
#define VAR_VERBOSITY 266
#define VAR_NUM_THREADS 267
#define VAR_PORT 268
#define VAR_OUTGOING_RANGE 269
#define VAR_INTERFACE 270
#define VAR_DO_IP4 271
#define VAR_DO_IP6 272
#define VAR_DO_UDP 273
#define VAR_DO_TCP 274
#define VAR_CHROOT 275
#define VAR_USERNAME 276
#define VAR_DIRECTORY 277
#define VAR_LOGFILE 278
#define VAR_PIDFILE 279
#define VAR_MSG_CACHE_SIZE 280
#define VAR_MSG_CACHE_SLABS 281
#define VAR_NUM_QUERIES_PER_THREAD 282
#define VAR_RRSET_CACHE_SIZE 283
#define VAR_RRSET_CACHE_SLABS 284
#define VAR_OUTGOING_NUM_TCP 285
#define VAR_INFRA_HOST_TTL 286
#define VAR_INFRA_LAME_TTL 287
#define VAR_INFRA_CACHE_SLABS 288
#define VAR_INFRA_CACHE_NUMHOSTS 289
#define VAR_INFRA_CACHE_LAME_SIZE 290
#define VAR_NAME 291
#define VAR_STUB_ZONE 292
#define VAR_STUB_HOST 293
#define VAR_STUB_ADDR 294
#define VAR_TARGET_FETCH_POLICY 295
#define VAR_HARDEN_SHORT_BUFSIZE 296
#define VAR_HARDEN_LARGE_QUERIES 297
#define VAR_FORWARD_ZONE 298
#define VAR_FORWARD_HOST 299
#define VAR_FORWARD_ADDR 300
#define VAR_DO_NOT_QUERY_ADDRESS 301
#define VAR_HIDE_IDENTITY 302
#define VAR_HIDE_VERSION 303
#define VAR_IDENTITY 304
#define VAR_VERSION 305
#define VAR_HARDEN_GLUE 306
#define VAR_MODULE_CONF 307
#define VAR_TRUST_ANCHOR_FILE 308
#define VAR_TRUST_ANCHOR 309
#define VAR_VAL_OVERRIDE_DATE 310
#define VAR_BOGUS_TTL 311
#define VAR_VAL_CLEAN_ADDITIONAL 312
#define VAR_VAL_PERMISSIVE_MODE 313
#define VAR_INCOMING_NUM_TCP 314
#define VAR_MSG_BUFFER_SIZE 315
#define VAR_KEY_CACHE_SIZE 316
#define VAR_KEY_CACHE_SLABS 317
#define VAR_TRUSTED_KEYS_FILE 318
#define VAR_VAL_NSEC3_KEYSIZE_ITERATIONS 319
#define VAR_USE_SYSLOG 320
#define VAR_OUTGOING_INTERFACE 321
#define VAR_ROOT_HINTS 322
#define VAR_DO_NOT_QUERY_LOCALHOST 323
#define VAR_CACHE_MAX_TTL 324
#define VAR_HARDEN_DNSSEC_STRIPPED 325
#define VAR_ACCESS_CONTROL 326
#define VAR_LOCAL_ZONE 327
#define VAR_LOCAL_DATA 328
#define VAR_INTERFACE_AUTOMATIC 329
#define VAR_STATISTICS_INTERVAL 330
#define VAR_DO_DAEMONIZE 331
#define VAR_USE_CAPS_FOR_ID 332
#define VAR_STATISTICS_CUMULATIVE 333
#define VAR_OUTGOING_PORT_PERMIT 334
#define VAR_OUTGOING_PORT_AVOID 335
#define VAR_DLV_ANCHOR_FILE 336
#define VAR_DLV_ANCHOR 337
#define VAR_NEG_CACHE_SIZE 338
#define VAR_HARDEN_REFERRAL_PATH 339
#define VAR_PRIVATE_ADDRESS 340
#define VAR_PRIVATE_DOMAIN 341
#define VAR_REMOTE_CONTROL 342
#define VAR_CONTROL_ENABLE 343
#define VAR_CONTROL_INTERFACE 344
#define VAR_CONTROL_PORT 345
#define VAR_SERVER_KEY_FILE 346
#define VAR_SERVER_CERT_FILE 347
#define VAR_CONTROL_KEY_FILE 348
#define VAR_CONTROL_CERT_FILE 349
#define VAR_EXTENDED_STATISTICS 350
#define VAR_LOCAL_DATA_PTR 351
#define VAR_JOSTLE_TIMEOUT 352
#define VAR_STUB_PRIME 353
#define VAR_UNWANTED_REPLY_THRESHOLD 354
#define VAR_LOG_TIME_ASCII 355
#define VAR_DOMAIN_INSECURE 356
#define VAR_PYTHON 357
#define VAR_PYTHON_SCRIPT 358
#define VAR_VAL_SIG_SKEW_MIN 359
#define VAR_VAL_SIG_SKEW_MAX 360
#define VAR_CACHE_MIN_TTL 361
#define VAR_VAL_LOG_LEVEL 362
#define VAR_AUTO_TRUST_ANCHOR_FILE 363
#define VAR_KEEP_MISSING 364
#define VAR_ADD_HOLDDOWN 365
#define VAR_DEL_HOLDDOWN 366
#define VAR_SO_RCVBUF 367
#define VAR_EDNS_BUFFER_SIZE 368
#define VAR_PREFETCH 369
#define VAR_PREFETCH_KEY 370
#define VAR_SO_SNDBUF 371
#define VAR_SO_REUSEPORT 372
#define VAR_HARDEN_BELOW_NXDOMAIN 373
#define VAR_IGNORE_CD_FLAG 374
#define VAR_LOG_QUERIES 375
#define VAR_TCP_UPSTREAM 376
#define VAR_SSL_UPSTREAM 377
#define VAR_SSL_SERVICE_KEY 378
#define VAR_SSL_SERVICE_PEM 379
#define VAR_SSL_PORT 380
#define VAR_FORWARD_FIRST 381
#define VAR_STUB_FIRST 382
#define VAR_MINIMAL_RESPONSES 383
#define VAR_RRSET_ROUNDROBIN 384
#define VAR_MAX_UDP_SIZE 385
#define VAR_DELAY_CLOSE 386
#define VAR_UNBLOCK_LAN_ZONES 387
#ifdef YYSTYPE
#undef YYSTYPE_IS_DECLARED
#define YYSTYPE_IS_DECLARED 1
#endif
#ifndef YYSTYPE_IS_DECLARED
#define YYSTYPE_IS_DECLARED 1
typedef union {
char* str;
} YYSTYPE;
#endif /* !YYSTYPE_IS_DECLARED */
extern YYSTYPE yylval;

View file

@ -44,7 +44,6 @@
#include <stdlib.h>
#include <assert.h>
#include "util/configyyrename.h"
#include "util/config_file.h"
#include "util/net_help.h"

View file

@ -10,9 +10,9 @@ UNBOUNDDIR= ${.CURDIR}/../../contrib/unbound
LIB= unbound
PRIVATELIB=
CFLAGS= -I${UNBOUNDDIR} -I${LDNSDIR}
CFLAGS= -I${UNBOUNDDIR} -I${LDNSDIR} -I${.OBJDIR}
SRCS= alloc.c autotrust.c config_file.c configlexer.c configparser.c \
SRCS= alloc.c autotrust.c config_file.c configlexer.l configparser.y \
context.c dname.c dns.c dnstree.c fptr_wlist.c infra.c \
iter_delegpt.c iter_donotq.c iter_fwd.c iter_hints.c iter_priv.c \
iter_resptype.c iter_scrub.c iter_utils.c iterator.c keyraw.c \
@ -31,4 +31,13 @@ WARNS?= 3
DPADD+= ${LIBSSL} ${LIBCRYPTO} ${LIBPTHREAD}
LDADD+= -lssl -lcrypto -lpthread
# Misnamed file in upstream source
configlexer.l: configlexer.lex
cp -p ${.ALLSRC} ${.TARGET}
CLEANFILES+= configlexer.l
# Symbol prefix for lex and yacc
LFLAGS= -Pub_c_
YFLAGS= -pub_c_ -d
.include <bsd.lib.mk>