From 887c203a6e4406b6bdbfb233ab967604b140e6b0 Mon Sep 17 00:00:00 2001 From: Ildar Musin Date: Tue, 14 May 2019 10:47:45 +0200 Subject: [PATCH 01/16] Introduce modules --- src/consumer.c | 46 ------------------------------- src/consumer.h | 14 +--------- src/dummy.c | 21 ++++++++++++--- src/dummy.h | 19 +------------ src/exports.c | 21 ++++++++++++--- src/exports.h | 21 +-------------- src/file.c | 45 ++++++++++++++++++++----------- src/file.h | 19 +------------ src/kafka.c | 26 +++++++++++++++--- src/kafka.h | 19 +------------ src/main.c | 35 ++++++++++++++++++------ src/modules.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++ src/modules.h | 33 +++++++++++++++++++++++ src/postgres.c | 33 +++++++++++++++++------ src/postgres.h | 19 +------------ src/producer.c | 54 ------------------------------------- src/producer.h | 10 ------- src/redis.c | 21 ++++++++++++--- src/redis.h | 18 +------------ src/utils/config.c | 10 ++++++- src/validator.c | 38 -------------------------- 21 files changed, 271 insertions(+), 318 deletions(-) delete mode 100644 src/consumer.c create mode 100644 src/modules.c create mode 100644 src/modules.h delete mode 100644 src/producer.c delete mode 100644 src/validator.c diff --git a/src/consumer.c b/src/consumer.c deleted file mode 100644 index d35079a..0000000 --- a/src/consumer.c +++ /dev/null @@ -1,46 +0,0 @@ -#include "consumer.h" -#include "dummy.h" -#include "file.h" -#include "kafka.h" -#include "redis.h" - - -Consumer -consumer_init(char kind, config_setting_t *config) -{ - Consumer c; - switch (kind) - { - case 'd': - c = dummy_consumer_init(config); - break; - case 'f': - c = file_consumer_init(config); - break; - case 'r': - c = redis_consumer_init(config); - break; - case 'k': - c = kafka_consumer_init(config); - break; - default: - return NULL; - } - return c; -} - -void -consumer_free(Consumer *c) -{ - if ((*c) == NULL) - return; - (*c)->consumer_free(c); -} - -int -consumer_consume(Consumer c, Message msg) -{ - if (c == NULL) - return -1; - return c->consume(c, msg); -} diff --git a/src/consumer.h b/src/consumer.h index e68ee22..cb81694 100644 --- a/src/consumer.h +++ b/src/consumer.h @@ -1,23 +1,11 @@ #ifndef _SCHAUFEL_CONSUMER_H_ #define _SCHAUFEL_CONSUMER_H_ -#include - #include "queue.h" -typedef struct Consumer *Consumer; - typedef struct Consumer{ - int (*consume) (Consumer c, Message msg); - void (*consumer_free) (Consumer *c); void *meta; -}*Consumer; - -Consumer consumer_init(char kind, config_setting_t *config); - -void consumer_free(Consumer *c); - -int consumer_consume(Consumer c, Message msg); +} *Consumer; #endif diff --git a/src/dummy.c b/src/dummy.c index c6d4b06..9b3f796 100644 --- a/src/dummy.c +++ b/src/dummy.c @@ -3,6 +3,7 @@ #include #include "dummy.h" +#include "modules.h" #include "utils/helper.h" #include "utils/logger.h" #include "utils/scalloc.h" @@ -13,8 +14,6 @@ dummy_producer_init(UNUSED config_setting_t *config) { Producer dummy = SCALLOC(1, sizeof(*dummy)); - dummy->producer_free = dummy_producer_free; - dummy->produce = dummy_producer_produce; return dummy; } @@ -36,8 +35,6 @@ dummy_consumer_init(UNUSED config_setting_t *config) { Consumer dummy = SCALLOC(1, sizeof(*dummy)); - dummy->consumer_free = dummy_consumer_free; - dummy->consume = dummy_consumer_consume; return dummy; } @@ -73,3 +70,19 @@ dummy_validator_init() v->validate_producer = &dummy_validator; return v; } + +void register_dummy_module(void) +{ + ModuleHandler *handler = SCALLOC(1, sizeof(ModuleHandler)); + + handler->consumer_init = dummy_consumer_init; + handler->consume = dummy_consumer_consume; + handler->consumer_free = dummy_consumer_free; + handler->producer_init = dummy_producer_init; + handler->produce = dummy_producer_produce; + handler->producer_free = dummy_producer_free; + handler->validator_init = dummy_validator_init; + + register_module("dummy", handler); +} + diff --git a/src/dummy.h b/src/dummy.h index a5b9467..9c44dfc 100644 --- a/src/dummy.h +++ b/src/dummy.h @@ -1,24 +1,7 @@ #ifndef _SCHAUFEL_DUMMY_H_ #define _SCHAUFEL_DUMMY_H_ -#include "consumer.h" -#include "producer.h" -#include "queue.h" -#include "validator.h" - -Producer dummy_producer_init(config_setting_t *config); - -void dummy_producer_free(Producer *p); - -void dummy_producer_produce(Producer p, Message msg); - -Consumer dummy_consumer_init(); - -void dummy_consumer_free(Consumer *c); - -int dummy_consumer_consume(Consumer c, Message msg); - -Validator dummy_validator_init(); +void register_dummy_module(void); #endif diff --git a/src/exports.c b/src/exports.c index dd6a179..f2e097f 100644 --- a/src/exports.c +++ b/src/exports.c @@ -7,6 +7,7 @@ #include #include "exports.h" +#include "modules.h" #include "utils/config.h" #include "utils/helper.h" #include "utils/logger.h" @@ -366,8 +367,6 @@ exports_producer_init(config_setting_t *config) Producer exports = SCALLOC(1, sizeof(*exports)); exports->meta = exports_meta_init(host, topic, needlestack); - exports->producer_free = exports_producer_free; - exports->produce = exports_producer_produce; if (pthread_create(&((Meta)(exports->meta))->commit_worker, NULL, @@ -509,8 +508,6 @@ exports_consumer_init(config_setting_t *config) Consumer exports = SCALLOC(1, sizeof(*exports)); exports->meta = exports_meta_init(host, NULL, needles); - exports->consumer_free = exports_consumer_free; - exports->consume = exports_consumer_consume; return exports; } @@ -594,3 +591,19 @@ exports_validator_init() v->validate_producer = &exporter_validate; return v; } + +void register_exports_module(void) +{ + ModuleHandler *handler = SCALLOC(1, sizeof(ModuleHandler)); + + handler->consumer_init = exports_consumer_init; + handler->consume = exports_consumer_consume; + handler->consumer_free = exports_consumer_free; + handler->producer_init = exports_producer_init; + handler->produce = exports_producer_produce; + handler->producer_free = exports_producer_free; + handler->validator_init = exports_validator_init; + + register_module("exports", handler); +} + diff --git a/src/exports.h b/src/exports.h index 30f902e..ba472bb 100644 --- a/src/exports.h +++ b/src/exports.h @@ -1,26 +1,7 @@ #ifndef _SCHAUFEL_EXPORTS_H_ #define _SCHAUFEL_EXPORTS_H_ -#include -#include "producer.h" -#include "consumer.h" -#include "validator.h" -#include "queue.h" - - -Producer exports_producer_init(config_setting_t *config); - -void exports_producer_free(Producer *p); - -void exports_producer_produce(Producer p, Message msg); - -Consumer exports_consumer_init(config_setting_t *config); - -void exports_consumer_free(Consumer *c); - -int exports_consumer_consume(Consumer c, Message msg); - -Validator exports_validator_init(); +void register_exports_module(void); #endif diff --git a/src/file.c b/src/file.c index 1b39d44..1031586 100644 --- a/src/file.c +++ b/src/file.c @@ -1,8 +1,10 @@ #include #include +#include #include #include "file.h" +#include "modules.h" #include "utils/logger.h" #include "utils/scalloc.h" @@ -38,21 +40,19 @@ file_meta_free(Meta *m) *m = NULL; } -Producer +static Producer file_producer_init(config_setting_t *config) { Producer file = SCALLOC(1, sizeof(*file)); const char *fname = NULL; - config_setting_lookup_string(config, "file", &fname); - file->meta = file_meta_init(fname, "a"); - file->producer_free = file_producer_free; - file->produce = file_producer_produce; + config_setting_lookup_string(config, "file", &fname); + file->meta = file_meta_init(fname, "a"); return file; } -void +static void file_producer_produce(Producer p, Message msg) { char *line = message_get_data(msg); @@ -61,7 +61,7 @@ file_producer_produce(Producer p, Message msg) fwrite(line, len, sizeof(*line),((Meta) p->meta)->fp); } -void +static void file_producer_free(Producer *p) { Meta m = (Meta) ((*p)->meta); @@ -70,20 +70,19 @@ file_producer_free(Producer *p) *p = NULL; } -Consumer +static Consumer file_consumer_init(config_setting_t *config) { Consumer file = SCALLOC(1, sizeof(*file)); const char *fname = NULL; + config_setting_lookup_string(config, "file", &fname); + file->meta = file_meta_init(fname, "r"); - file->meta = file_meta_init(fname, "r"); - file->consumer_free = file_consumer_free; - file->consume = file_consumer_consume; return file; } -int +static int file_consumer_consume(Consumer c, Message msg) { char *line = NULL; @@ -100,7 +99,7 @@ file_consumer_consume(Consumer c, Message msg) return 0; } -void +static void file_consumer_free(Consumer *c) { Meta m = (Meta) ((*c)->meta); @@ -109,7 +108,7 @@ file_consumer_free(Consumer *c) *c = NULL; } -bool +static bool file_validate(config_setting_t* config) { int t = 0; @@ -123,7 +122,7 @@ file_validate(config_setting_t* config) return true; } -Validator +static Validator file_validator_init() { Validator v = SCALLOC(1,sizeof(*v)); @@ -132,3 +131,19 @@ file_validator_init() v->validate_consumer = file_validate; return v; } + +void register_file_module(void) +{ + ModuleHandler *handler = SCALLOC(1, sizeof(ModuleHandler)); + + handler->consumer_init = file_consumer_init; + handler->consume = file_consumer_consume; + handler->consumer_free = file_consumer_free; + handler->producer_init = file_producer_init; + handler->produce = file_producer_produce; + handler->producer_free = file_producer_free; + handler->validator_init = file_validator_init; + + register_module("file", handler); +} + diff --git a/src/file.h b/src/file.h index 29ce083..a093975 100644 --- a/src/file.h +++ b/src/file.h @@ -1,24 +1,7 @@ #ifndef _SCHAUFEL_FILE_H_ #define _SCHAUFEL_FILE_H_ -#include "consumer.h" -#include "producer.h" -#include "queue.h" -#include "validator.h" - -Producer file_producer_init(config_setting_t *config); - -void file_producer_free(Producer *p); - -void file_producer_produce(Producer p, Message msg); - -Consumer file_consumer_init(config_setting_t *config); - -void file_consumer_free(Consumer *c); - -int file_consumer_consume(Consumer c, Message msg); - -Validator file_validator_init(); +void register_file_module(void); #endif diff --git a/src/kafka.c b/src/kafka.c index c06626b..9e3d45d 100644 --- a/src/kafka.c +++ b/src/kafka.c @@ -1,13 +1,18 @@ #include #include #include +#include #include +#include "consumer.h" #include "kafka.h" +#include "modules.h" +#include "producer.h" #include "utils/config.h" #include "utils/helper.h" #include "utils/logger.h" #include "utils/scalloc.h" +#include "validator.h" static void @@ -234,8 +239,6 @@ kafka_producer_init(config_setting_t *config) Producer kafka = SCALLOC(1, sizeof(*kafka)); kafka->meta = kafka_producer_meta_init(broker, topic); - kafka->producer_free = kafka_producer_free; - kafka->produce = kafka_producer_produce; return kafka; } @@ -293,8 +296,6 @@ kafka_consumer_init(config_setting_t *config) Consumer kafka = SCALLOC(1, sizeof(*kafka)); kafka->meta = kafka_consumer_meta_init(broker, topic, groupid); - kafka->consumer_free = kafka_consumer_free; - kafka->consume = kafka_consumer_consume; return kafka; } @@ -407,3 +408,20 @@ kafka_validator_init() return(v); } + +void +register_kafka_module(void) +{ + ModuleHandler *handler = SCALLOC(1, sizeof(ModuleHandler)); + + handler->consumer_init = kafka_consumer_init; + handler->consume = kafka_consumer_consume; + handler->consumer_free = kafka_consumer_free; + handler->producer_init = kafka_producer_init; + handler->produce = kafka_producer_produce; + handler->producer_free = kafka_producer_free; + handler->validator_init = kafka_validator_init; + + register_module("kafka", handler); +} + diff --git a/src/kafka.h b/src/kafka.h index 184c8ca..00542fe 100644 --- a/src/kafka.h +++ b/src/kafka.h @@ -1,24 +1,7 @@ #ifndef _SCHAUFEL_KAFKA_H_ #define _SCHAUFEL_KAFKA_H_ -#include "consumer.h" -#include "producer.h" -#include "queue.h" -#include "validator.h" - -Producer kafka_producer_init(config_setting_t *config); - -void kafka_producer_free(Producer *p); - -void kafka_producer_produce(Producer p, Message msg); - -Consumer kafka_consumer_init(config_setting_t *config); - -void kafka_consumer_free(Consumer *c); - -int kafka_consumer_consume(Consumer c, Message msg); - -Validator kafka_validator_init(); +void register_kafka_module(void); #endif diff --git a/src/main.c b/src/main.c index 1f0f526..cdea659 100644 --- a/src/main.c +++ b/src/main.c @@ -9,6 +9,7 @@ #include #include "consumer.h" +#include "modules.h" #include "producer.h" #include "utils/config.h" #include "utils/helper.h" @@ -117,8 +118,17 @@ consume(void *config) logger_log("%s %d: could not init message", __FILE__, __LINE__); return NULL; } - Consumer c = consumer_init(*consumer_type, - (config_setting_t *) config); + + ModuleHandler *handler = lookup_module(consumer_type); + if (!handler) + { + logger_log("%s %d: module %s is not found", __FILE__, __LINE__, consumer_type); + return NULL; + } + + /* TODO: check that consumer_init routine is not NULL */ + + Consumer c = handler->consumer_init((config_setting_t *) config); if (c == NULL) { logger_log("%s %d: could not init consumer", __FILE__, __LINE__); @@ -132,7 +142,7 @@ consume(void *config) while (get_state(&consume_state)) { - if (consumer_consume(c, msg) == -1) + if (handler->consume(c, msg) == -1) break; if (message_get_data(msg) != NULL) { @@ -142,7 +152,7 @@ consume(void *config) } } message_free(&msg); - consumer_free(&c); + handler->consumer_free(&c); return NULL; } @@ -153,8 +163,15 @@ produce(void *config) const char *producer_type = NULL; config_setting_lookup_string((config_setting_t *) config, "type", &producer_type); - Producer p = producer_init(*producer_type, - (config_setting_t *) config); + + ModuleHandler *handler = lookup_module(producer_type); + if (!handler) + { + logger_log("%s %d: module %s is not found", __FILE__, __LINE__, producer_type); + return NULL; + } + + Producer p = handler->producer_init((config_setting_t *) config); if (p == NULL) { logger_log("%s %d: could not init producer", __FILE__, __LINE__); @@ -177,14 +194,14 @@ produce(void *config) if (message_get_data(msg) != NULL) { //TODO: check success - producer_produce(p, msg); + handler->produce(p, msg); //message was handled: free it free(message_get_data(msg)); message_set_data(msg, NULL); } } message_free(&msg); - producer_free(&p); + handler->producer_free(&p); return NULL; } @@ -240,6 +257,8 @@ main(int argc, char **argv) void *res; + register_builtin_modules(); + pthread_t *c_thread; pthread_t *p_thread; pthread_t stat_thread; diff --git a/src/modules.c b/src/modules.c new file mode 100644 index 0000000..e8b87e6 --- /dev/null +++ b/src/modules.c @@ -0,0 +1,67 @@ +#include + +#include "modules.h" +#include "utils/scalloc.h" + +/* TODO: temporary */ +#include "dummy.h" +#include "exports.h" +#include "file.h" +#include "kafka.h" +#include "postgres.h" +#include "redis.h" + + +/* modules list struct */ +typedef struct ModuleNode ModuleNode; + +struct ModuleNode +{ + const char *name; + ModuleHandler *handler; + ModuleNode *next; +}; + +/* modules list */ +ModuleNode *modules_head = NULL; + + +extern void +register_module(const char *name, ModuleHandler *handler) +{ + ModuleNode *node = SCALLOC(1, sizeof(ModuleNode)); + + node->name = name; + node->handler = handler; + node->next = modules_head; + + modules_head = node; +} + +ModuleHandler * +lookup_module(const char *name) +{ + ModuleNode *node = modules_head; + + while(node) + { + if (strcmp(node->name, name) == 0) + return node->handler; + + node = node->next; + } + + return NULL; +} + +/* TODO: temporary */ +void +register_builtin_modules(void) +{ + register_file_module(); + register_dummy_module(); + register_kafka_module(); + register_postgres_module(); + register_redis_module(); + register_exports_module(); +} diff --git a/src/modules.h b/src/modules.h new file mode 100644 index 0000000..cc32ce7 --- /dev/null +++ b/src/modules.h @@ -0,0 +1,33 @@ +#ifndef MODULES_H +#define MODULES_H + +#include + +#include "consumer.h" +#include "producer.h" +#include "validator.h" + + +typedef struct ModuleHandler +{ + /* consumer routines */ + Consumer (*consumer_init) (config_setting_t *config); + int (*consume) (Consumer c, Message msg); + void (*consumer_free) (Consumer *c); + + /* producer routines */ + Producer (*producer_init) (config_setting_t *config); + void (*produce) (Producer p, Message msg); + void (*producer_free) (Producer *p); + + /* validator routine */ + Validator (*validator_init) (void); +} ModuleHandler; + +extern void register_module(const char *name, ModuleHandler *handler); +ModuleHandler *lookup_module(const char *name); + +/* TODO: temporary */ +void register_builtin_modules(void); + +#endif diff --git a/src/postgres.c b/src/postgres.c index d5d3259..c31db73 100644 --- a/src/postgres.c +++ b/src/postgres.c @@ -1,7 +1,9 @@ #include #include +#include #include +#include "modules.h" #include "postgres.h" #include "utils/array.h" #include "utils/config.h" @@ -128,10 +130,7 @@ postgres_producer_init(config_setting_t *config) config_setting_lookup_string(config,"topic", &generation); Producer postgres = SCALLOC(1, sizeof(*postgres)); - - postgres->meta = postgres_meta_init(host, host_replica, generation); - postgres->producer_free = postgres_producer_free; - postgres->produce = postgres_producer_produce; + postgres->meta = postgres_meta_init(host, host_replica, generation); if (pthread_create(&((Meta)(postgres->meta))->commit_worker, NULL, @@ -242,13 +241,14 @@ postgres_producer_free(Producer *p) } Consumer -postgres_consumer_init(char *host) +postgres_consumer_init(config_setting_t *config) { Consumer postgres = SCALLOC(1, sizeof(*postgres)); + const char *host; + + config_setting_lookup_string(config, "host", &host); - postgres->meta = postgres_meta_init(host, NULL, NULL); - postgres->consumer_free = postgres_consumer_free; - postgres->consume = postgres_consumer_consume; + postgres->meta = postgres_meta_init(host, NULL, NULL); return postgres; } @@ -365,3 +365,20 @@ postgres_validator_init() v->validate_producer = postgres_validate; return v; } + +void +register_postgres_module(void) +{ + ModuleHandler *handler = SCALLOC(1, sizeof(ModuleHandler)); + + handler->consumer_init = postgres_consumer_init; + handler->consume = postgres_consumer_consume; + handler->consumer_free = postgres_consumer_free; + handler->producer_init = postgres_producer_init; + handler->produce = postgres_producer_produce; + handler->producer_free = postgres_producer_free; + handler->validator_init = postgres_validator_init; + + register_module("postgres", handler); +} + diff --git a/src/postgres.h b/src/postgres.h index 9f354e9..7e79d7c 100644 --- a/src/postgres.h +++ b/src/postgres.h @@ -1,24 +1,7 @@ #ifndef _SCHAUFEL_POSTGRES_H_ #define _SCHAUFEL_POSTGRES_H_ -#include "consumer.h" -#include "producer.h" -#include "queue.h" -#include "validator.h" - -Producer postgres_producer_init(config_setting_t *config); - -void postgres_producer_free(Producer *p); - -void postgres_producer_produce(Producer p, Message msg); - -Consumer postgres_consumer_init(char *host); - -void postgres_consumer_free(Consumer *c); - -int postgres_consumer_consume(Consumer c, Message msg); - -Validator postgres_validator_init(); +void register_postgres_module(void); #endif diff --git a/src/producer.c b/src/producer.c deleted file mode 100644 index 07f6873..0000000 --- a/src/producer.c +++ /dev/null @@ -1,54 +0,0 @@ -#include "dummy.h" -#include "exports.h" -#include "file.h" -#include "kafka.h" -#include "postgres.h" -#include "producer.h" -#include "redis.h" - - -Producer -producer_init(char kind, config_setting_t *config) -{ - Producer p; - switch (kind) - { - case 'd': - p = dummy_producer_init(config); - break; - case 'f': - p = file_producer_init(config); - break; - case 'r': - p = redis_producer_init(config); - break; - case 'e': - p = exports_producer_init(config); - break; - case 'p': - p = postgres_producer_init(config); - break; - case 'k': - p = kafka_producer_init(config); - break; - default: - return NULL; - } - return p; -} - -void -producer_free(Producer *p) -{ - if ((*p) == NULL) - return; - (*p)->producer_free(p); -} - -void -producer_produce(Producer p, Message msg) -{ - if (p == NULL) - return; - p->produce(p, msg); -} diff --git a/src/producer.h b/src/producer.h index 29a3937..c8d509b 100644 --- a/src/producer.h +++ b/src/producer.h @@ -1,23 +1,13 @@ #ifndef _SCHAUFEL_PRODUCER_H_ #define _SCHAUFEL_PRODUCER_H_ -#include - #include "queue.h" typedef struct Producer *Producer; struct Producer { - void (*produce) (Producer p, Message msg); - void (*producer_free)(Producer *p); void *meta; }; -Producer producer_init(char kind, config_setting_t *config); - -void producer_free(Producer *p); - -void producer_produce(Producer p, Message msg); - #endif diff --git a/src/redis.c b/src/redis.c index ffb8e47..535e50e 100644 --- a/src/redis.c +++ b/src/redis.c @@ -3,6 +3,7 @@ #include #include +#include "modules.h" #include "redis.h" #include "utils/config.h" #include "utils/logger.h" @@ -106,8 +107,6 @@ redis_producer_init(config_setting_t *config) Producer redis = SCALLOC(1, sizeof(*redis)); redis->meta = redis_meta_init(host, topic, pipeline); - redis->producer_free = redis_producer_free; - redis->produce = redis_producer_produce; return redis; } @@ -150,8 +149,6 @@ redis_consumer_init(config_setting_t *config) Consumer redis = SCALLOC(1, sizeof(*redis)); redis->meta = redis_meta_init(host, topic, pipeline); - redis->consumer_free = redis_consumer_free; - redis->consume = redis_consumer_consume; return redis; } @@ -240,3 +237,19 @@ redis_validator_init() v->validate_producer = &redis_validator; return v; } + +void register_redis_module(void) +{ + ModuleHandler *handler = SCALLOC(1, sizeof(ModuleHandler)); + + handler->consumer_init = redis_consumer_init; + handler->consume = redis_consumer_consume; + handler->consumer_free = redis_consumer_free; + handler->producer_init = redis_producer_init; + handler->produce = redis_producer_produce; + handler->producer_free = redis_producer_free; + handler->validator_init = redis_validator_init; + + register_module("redis", handler); +} + diff --git a/src/redis.h b/src/redis.h index de50e44..7bb42bc 100644 --- a/src/redis.h +++ b/src/redis.h @@ -1,23 +1,7 @@ #ifndef _SCHAUFEL_REDIS_H_ #define _SCHAUFEL_REDIS_H_ -#include "consumer.h" -#include "producer.h" -#include "queue.h" -#include "validator.h" +void register_redis_module(void); -Producer redis_producer_init(config_setting_t *config); - -void redis_producer_free(Producer *p); - -void redis_producer_produce(Producer p, Message msg); - -Consumer redis_consumer_init(config_setting_t *config); - -void redis_consumer_free(Consumer *c); - -int redis_consumer_consume(Consumer c, Message msg); - -Validator redis_validator_init(); #endif diff --git a/src/utils/config.c b/src/utils/config.c index 9707f7e..3cd40d6 100644 --- a/src/utils/config.c +++ b/src/utils/config.c @@ -1,6 +1,7 @@ #include #include +#include "modules.h" #include "utils/config.h" #include "utils/logger.h" #include "validator.h" @@ -149,7 +150,14 @@ static bool _thread_validate(config_t* config, int type) child = config_setting_get_elem(setting, i); config_setting_lookup_string(child, "type", &conf_str); - v = validator_init(conf_str); + ModuleHandler *handler = lookup_module(conf_str); + if (!handler) + { + logger_log("%s %d: module %s is not found", __FILE__, __LINE__, conf_str); + return NULL; + } + + v = handler->validator_init(); if(!v) { fprintf(stderr, "Type %s has no validator!\n", conf_str); ret = false; diff --git a/src/validator.c b/src/validator.c deleted file mode 100644 index 28c8cab..0000000 --- a/src/validator.c +++ /dev/null @@ -1,38 +0,0 @@ -#include "dummy.h" -#include "exports.h" -#include "file.h" -#include "kafka.h" -#include "postgres.h" -#include "redis.h" -#include "validator.h" - -Validator -validator_init(const char* kind) -{ - Validator v; - switch (*kind) - { - case 'd': - v = dummy_validator_init(); - break; - case 'f': - v = file_validator_init(); - break; - case 'e': - v = exports_validator_init(); - break; - case 'p': - v = postgres_validator_init(); - break; - case 'r': - v = redis_validator_init(); - break; - case 'k': - v = kafka_validator_init(); - break; - default: - return NULL; - } - - return v; -} From 3151a9e15bb51356eea216707362a6f2df81ae94 Mon Sep 17 00:00:00 2001 From: Ildar Musin Date: Tue, 14 May 2019 11:55:07 +0200 Subject: [PATCH 02/16] Make Validator a part of ModuleHandler --- src/dummy.c | 16 ++++------------ src/exports.c | 37 ++++++++++++++----------------------- src/file.c | 16 ++++------------ src/kafka.c | 17 ++--------------- src/modules.h | 7 ++++--- src/postgres.c | 13 ++----------- src/redis.c | 17 ++++------------- src/utils/config.c | 34 ++++++++++++++++++++-------------- src/validator.h | 15 --------------- t/dummy_consumer_test.c | 24 ++++++++++++++++++------ t/dummy_producer_test.c | 26 ++++++++++++++------------ t/file_consumer_test.c | 26 +++++++++++++++----------- 12 files changed, 101 insertions(+), 147 deletions(-) delete mode 100644 src/validator.h diff --git a/src/dummy.c b/src/dummy.c index 9b3f796..e8ddced 100644 --- a/src/dummy.c +++ b/src/dummy.c @@ -61,17 +61,8 @@ dummy_validator(UNUSED config_setting_t *config) return true; } -Validator -dummy_validator_init() -{ - Validator v = SCALLOC(1,sizeof(*v)); - - v->validate_consumer = &dummy_validator; - v->validate_producer = &dummy_validator; - return v; -} - -void register_dummy_module(void) +void +register_dummy_module(void) { ModuleHandler *handler = SCALLOC(1, sizeof(ModuleHandler)); @@ -81,7 +72,8 @@ void register_dummy_module(void) handler->producer_init = dummy_producer_init; handler->produce = dummy_producer_produce; handler->producer_free = dummy_producer_free; - handler->validator_init = dummy_validator_init; + handler->validate_consumer = dummy_validator; + handler->validate_producer = dummy_validator; register_module("dummy", handler); } diff --git a/src/exports.c b/src/exports.c index f2e097f..6fb0e08 100644 --- a/src/exports.c +++ b/src/exports.c @@ -304,7 +304,7 @@ _cpycmd(const char *host, const char *table) } -Meta +static Meta exports_meta_init(const char *host, const char *topic, config_setting_t *needlestack) { Meta m = SCALLOC(1, sizeof(*m)); @@ -332,7 +332,7 @@ exports_meta_init(const char *host, const char *topic, config_setting_t *needles return m; } -void +static void exports_meta_free(Meta *m) { Internal internal = (*m)->internal; @@ -356,7 +356,7 @@ exports_meta_free(Meta *m) *m = NULL; } -Producer +static Producer exports_producer_init(config_setting_t *config) { const char *host = NULL, *topic = NULL; @@ -379,7 +379,7 @@ exports_producer_init(config_setting_t *config) return exports; } -bool +static bool _deref(json_object *haystack, Internal internal) { json_object *found; @@ -403,7 +403,7 @@ _deref(json_object *haystack, Internal internal) return true; } -void +static void exports_producer_produce(Producer p, Message msg) { Meta m = (Meta)p->meta; @@ -480,7 +480,7 @@ exports_producer_produce(Producer p, Message msg) pthread_mutex_unlock(&m->commit_mutex); } -void +static void exports_producer_free(Producer *p) { Meta m = (Meta) ((*p)->meta); @@ -499,7 +499,7 @@ exports_producer_free(Producer *p) *p = NULL; } -Consumer +static Consumer exports_consumer_init(config_setting_t *config) { const char *host = NULL; @@ -519,7 +519,7 @@ exports_consumer_consume(UNUSED Consumer c, UNUSED Message msg) return -1; } -void +static void exports_consumer_free(Consumer *c) { Meta m = (Meta) ((*c)->meta); @@ -528,8 +528,8 @@ exports_consumer_free(Consumer *c) *c = NULL; } -bool -exporter_validate(UNUSED config_setting_t *config) +static bool +exports_validate(UNUSED config_setting_t *config) { config_setting_t *setting = NULL, *member = NULL, *child = NULL; const char *conf = NULL; @@ -581,18 +581,8 @@ exporter_validate(UNUSED config_setting_t *config) return false; } - -Validator -exports_validator_init() -{ - Validator v = SCALLOC(1,sizeof(*v)); - - v->validate_consumer = &exporter_validate; - v->validate_producer = &exporter_validate; - return v; -} - -void register_exports_module(void) +void +register_exports_module(void) { ModuleHandler *handler = SCALLOC(1, sizeof(ModuleHandler)); @@ -602,7 +592,8 @@ void register_exports_module(void) handler->producer_init = exports_producer_init; handler->produce = exports_producer_produce; handler->producer_free = exports_producer_free; - handler->validator_init = exports_validator_init; + handler->validate_consumer = exports_validate; + handler->validate_producer = exports_validate; register_module("exports", handler); } diff --git a/src/file.c b/src/file.c index 1031586..b573083 100644 --- a/src/file.c +++ b/src/file.c @@ -122,17 +122,8 @@ file_validate(config_setting_t* config) return true; } -static Validator -file_validator_init() -{ - Validator v = SCALLOC(1,sizeof(*v)); - - v->validate_producer = file_validate; - v->validate_consumer = file_validate; - return v; -} - -void register_file_module(void) +void +register_file_module(void) { ModuleHandler *handler = SCALLOC(1, sizeof(ModuleHandler)); @@ -142,7 +133,8 @@ void register_file_module(void) handler->producer_init = file_producer_init; handler->produce = file_producer_produce; handler->producer_free = file_producer_free; - handler->validator_init = file_validator_init; + handler->validate_consumer = file_validate; + handler->validate_producer = file_validate; register_module("file", handler); } diff --git a/src/kafka.c b/src/kafka.c index 9e3d45d..74657fb 100644 --- a/src/kafka.c +++ b/src/kafka.c @@ -4,15 +4,12 @@ #include #include -#include "consumer.h" #include "kafka.h" #include "modules.h" -#include "producer.h" #include "utils/config.h" #include "utils/helper.h" #include "utils/logger.h" #include "utils/scalloc.h" -#include "validator.h" static void @@ -398,17 +395,6 @@ kafka_consumer_validator(config_setting_t *config) return kafka_validator(config); } -Validator -kafka_validator_init() -{ - Validator v = SCALLOC(1,sizeof(*v)); - - v->validate_consumer = &kafka_consumer_validator; - v->validate_producer = &kafka_producer_validator; - - return(v); -} - void register_kafka_module(void) { @@ -420,7 +406,8 @@ register_kafka_module(void) handler->producer_init = kafka_producer_init; handler->produce = kafka_producer_produce; handler->producer_free = kafka_producer_free; - handler->validator_init = kafka_validator_init; + handler->validate_consumer = kafka_consumer_validator; + handler->validate_producer = kafka_producer_validator; register_module("kafka", handler); } diff --git a/src/modules.h b/src/modules.h index cc32ce7..95d97e3 100644 --- a/src/modules.h +++ b/src/modules.h @@ -2,10 +2,10 @@ #define MODULES_H #include +#include #include "consumer.h" #include "producer.h" -#include "validator.h" typedef struct ModuleHandler @@ -20,8 +20,9 @@ typedef struct ModuleHandler void (*produce) (Producer p, Message msg); void (*producer_free) (Producer *p); - /* validator routine */ - Validator (*validator_init) (void); + /* validator routines */ + bool (*validate_consumer) (config_setting_t* config); + bool (*validate_producer) (config_setting_t* config); } ModuleHandler; extern void register_module(const char *name, ModuleHandler *handler); diff --git a/src/postgres.c b/src/postgres.c index c31db73..498b7ff 100644 --- a/src/postgres.c +++ b/src/postgres.c @@ -356,16 +356,6 @@ postgres_validate(config_setting_t *config) return ret; } -Validator -postgres_validator_init() -{ - Validator v = SCALLOC(1,sizeof(*v)); - - v->validate_consumer = postgres_validate; - v->validate_producer = postgres_validate; - return v; -} - void register_postgres_module(void) { @@ -377,7 +367,8 @@ register_postgres_module(void) handler->producer_init = postgres_producer_init; handler->produce = postgres_producer_produce; handler->producer_free = postgres_producer_free; - handler->validator_init = postgres_validator_init; + handler->validate_consumer = postgres_validate; + handler->validate_producer = postgres_validate; register_module("postgres", handler); } diff --git a/src/redis.c b/src/redis.c index 535e50e..d202b6f 100644 --- a/src/redis.c +++ b/src/redis.c @@ -227,18 +227,8 @@ redis_validator(config_setting_t *config) return true; } - -Validator -redis_validator_init() -{ - Validator v = SCALLOC(1,sizeof(*v)); - - v->validate_consumer = &redis_validator; - v->validate_producer = &redis_validator; - return v; -} - -void register_redis_module(void) +void +register_redis_module(void) { ModuleHandler *handler = SCALLOC(1, sizeof(ModuleHandler)); @@ -248,7 +238,8 @@ void register_redis_module(void) handler->producer_init = redis_producer_init; handler->produce = redis_producer_produce; handler->producer_free = redis_producer_free; - handler->validator_init = redis_validator_init; + handler->validate_consumer = redis_validator; + handler->validate_producer = redis_validator; register_module("redis", handler); } diff --git a/src/utils/config.c b/src/utils/config.c index 3cd40d6..fc19c94 100644 --- a/src/utils/config.c +++ b/src/utils/config.c @@ -4,7 +4,6 @@ #include "modules.h" #include "utils/config.h" #include "utils/logger.h" -#include "validator.h" int get_thread_count(config_t* config, int type) @@ -100,7 +99,6 @@ static bool _thread_validate(config_t* config, int type) const char *conf_str = NULL; char *typestr; - Validator v; bool ret = true; switch(type) @@ -157,26 +155,34 @@ static bool _thread_validate(config_t* config, int type) return NULL; } - v = handler->validator_init(); - if(!v) { - fprintf(stderr, "Type %s has no validator!\n", conf_str); - ret = false; - goto error; - } - - if(type == SCHAUFEL_TYPE_CONSUMER) { - if(!v->validate_consumer(child)) { + if(type == SCHAUFEL_TYPE_CONSUMER) + { + if (!handler->validate_consumer) + { + fprintf(stderr, "Type %s has no consumer validator!\n", conf_str); + ret = false; + goto error; + } + if(!handler->validate_consumer(child)) + { ret = false; goto error; } } - if(type == SCHAUFEL_TYPE_PRODUCER) { - if(!v->validate_producer(child)) { + else if(type == SCHAUFEL_TYPE_PRODUCER) + { + if (!handler->validate_producer) + { + fprintf(stderr, "Type %s has no producer validator!\n", conf_str); + ret = false; + goto error; + } + if(!handler->validate_producer(child)) + { ret = false; goto error; } } - free(v); } error: diff --git a/src/validator.h b/src/validator.h deleted file mode 100644 index d99ffdd..0000000 --- a/src/validator.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef _SCHAUFEL_VALIDATOR_H -#define _SCHAUFEL_VALIDATOR_H - -#include -#include - -typedef struct Validator *Validator; - -struct Validator { - bool (*validate_consumer) (config_setting_t* config); - bool (*validate_producer) (config_setting_t* config); -}; - -Validator validator_init(const char* kind); -#endif diff --git a/t/dummy_consumer_test.c b/t/dummy_consumer_test.c index 2d0681b..83defea 100644 --- a/t/dummy_consumer_test.c +++ b/t/dummy_consumer_test.c @@ -1,7 +1,8 @@ #include #include -#include "consumer.h" +#include "dummy.h" +#include "modules.h" #include "queue.h" #include "test/test.h" @@ -9,16 +10,27 @@ int main(void) { - Message msg = message_init(); - Consumer c = consumer_init('d', NULL); - consumer_consume(c, msg); - char *string =(char *) message_get_data(msg); + ModuleHandler *dummy; + Consumer c; + Message msg; + char *string; + + register_dummy_module(); + msg = message_init(); + + dummy = lookup_module("dummy"); + c = dummy->consumer_init(NULL); + dummy->consume(c, msg); + string =(char *) message_get_data(msg); pretty_assert(string != NULL); if (string != NULL) + { pretty_assert(strncmp(string, "{\"type\":\"dummy\"}", 16) == 0); printf("%s\n", string); + } + message_free(&msg); free(string); - consumer_free(&c); + dummy->consumer_free(&c); return 0; } diff --git a/t/dummy_producer_test.c b/t/dummy_producer_test.c index ee45607..582fbbb 100644 --- a/t/dummy_producer_test.c +++ b/t/dummy_producer_test.c @@ -1,24 +1,26 @@ #include +#include "dummy.h" +#include "modules.h" #include "queue.h" -#include "producer.h" int main(void) { - Message msg = message_init(); - char *test = malloc(5); - test[0] = 'm'; - test[1] = 'o'; - test[2] = 'e'; - test[3] = 'p'; - test[4] = '\0'; + ModuleHandler *dummy; + Producer p; + Message msg = message_init(); + char test[] = "moep"; + message_set_data(msg, test); - Producer p = producer_init('d', NULL); - producer_produce(p, msg); + + register_dummy_module(); + dummy = lookup_module("dummy"); + p = dummy->producer_init(NULL); + dummy->produce(p, msg); + message_free(&msg); - producer_free(&p); - free(test); + dummy->producer_free(&p); return 0; } diff --git a/t/file_consumer_test.c b/t/file_consumer_test.c index 5665f1c..68fdb52 100644 --- a/t/file_consumer_test.c +++ b/t/file_consumer_test.c @@ -1,6 +1,7 @@ #include -#include "consumer.h" +#include "file.h" +#include "modules.h" #include "queue.h" #include "test/test.h" #include "utils/config.h" @@ -12,7 +13,9 @@ int main(void) { config_t config; - config_setting_t *croot, *logger, *file, *setting; + config_setting_t *croot, *logger, *file_setting, *setting; + char *string; + config_init(&config); croot = config_root_setting(&config); @@ -21,28 +24,29 @@ main(void) setting = config_setting_add(logger, "file", CONFIG_TYPE_STRING); config_setting_set_string(setting, "sample/dummy_log"); //file - file = config_setting_add(croot,"file",CONFIG_TYPE_GROUP); - setting = config_setting_add(file, "file", CONFIG_TYPE_STRING); + file_setting = config_setting_add(croot,"file",CONFIG_TYPE_GROUP); + setting = config_setting_add(file_setting, "file", CONFIG_TYPE_STRING); config_setting_set_string(setting, "sample/dummy_file"); + register_file_module(); + ModuleHandler *file = lookup_module("file"); + Consumer c = file->consumer_init(file_setting); + logger_init(logger); Message msg = message_init(); - Consumer c = consumer_init('f', file); - char *string; - - consumer_consume(c, msg); + file->consume(c, msg); string =(char *) message_get_data(msg); pretty_assert(string != NULL); if (string != NULL) pretty_assert(strncmp(string, "first", 5) == 0); free(string); - consumer_consume(c, msg); + file->consume(c, msg); string =(char *) message_get_data(msg); pretty_assert(string != NULL); if (string != NULL) pretty_assert(strncmp(string, "second", 6) == 0); free(string); - consumer_consume(c, msg); + file->consume(c, msg); string =(char *) message_get_data(msg); pretty_assert(string != NULL); if (string != NULL) @@ -50,7 +54,7 @@ main(void) free(string); message_free(&msg); - consumer_free(&c); + file->consumer_free(&c); config_destroy(&config); logger_free(); return 0; From 858e10102b9d17fe26f04d02562b15b4e4f4060c Mon Sep 17 00:00:00 2001 From: Ildar Musin Date: Tue, 14 May 2019 18:13:36 +0200 Subject: [PATCH 03/16] A step forward pluggable modules: * Add `load_module` function that dynamically opens shared object and calls special `schaufel_module_init` func; * Create `contrib` directory for modules and a Makefile to build modules in the directory; * Extracted postgres module to `contrib` directory and added a Makefile to build it as a shared library. --- Makefile | 10 ++++++-- contrib/Makefile | 8 +++++++ contrib/postgres/Makefile | 24 +++++++++++++++++++ {src => contrib/postgres}/postgres.c | 4 ++-- {src => contrib/postgres}/postgres.h | 2 +- src/modules.c | 36 ++++++++++++++++++++++++++-- src/modules.h | 1 + 7 files changed, 78 insertions(+), 7 deletions(-) create mode 100644 contrib/Makefile create mode 100644 contrib/postgres/Makefile rename {src => contrib/postgres}/postgres.c (99%) rename {src => contrib/postgres}/postgres.h (63%) diff --git a/Makefile b/Makefile index 446383f..58cfb13 100644 --- a/Makefile +++ b/Makefile @@ -13,8 +13,9 @@ CFLAGS += -std=c11 CFLAGS += -D_POSIX_C_SOURCE=200809L CFLAGS += -D_SCHAUFEL_VERSION='"$(SCHAUFEL_VERSION)"' CFLAGS += -D_BSD_SOURCE -LIB = -lpthread -lhiredis -lrdkafka -lpq -lconfig -ljson-c +LIB = -lpthread -ldl -lhiredis -lrdkafka -lpq -lconfig -ljson-c INC = -Isrc/ +LDFLAGS += -Wl,-E OBJDIR = obj OUT = bin/schaufel @@ -32,6 +33,9 @@ SCHAUFEL_VERSION ?= 0.5 all: release +contrib: + $(MAKE) -C contrib + docs: $(DOCS) doc/%.pdf: man/* @@ -53,7 +57,7 @@ clean_release: rm -rf doc/*.pdf out_release: $(OBJ) - $(LD) $(LIBDIR) $(OBJ) $(LIB) -o $(OUT) + $(LD) $(LIBDIR) $(LDFLAGS) $(OBJ) $(LIB) -o $(OUT) $(OBJDIR)/%.o: src/%.c $(CC) $(INC) $(CFLAGS) -c $< -o $@ @@ -68,3 +72,5 @@ install: all $(INSTALL) -m 0644 -t $(DESTDIR)$(DOCDIR) doc/* $(INSTALL) -m 0644 man/schaufel.1 $(DESTDIR)$(MAN1DIR)/schaufel.1 $(INSTALL) -m 0644 man/schaufel.conf.5 $(DESTDIR)$(MAN5DIR)/schaufel.conf.5 + +.PHONY: all contrib docs release test clean diff --git a/contrib/Makefile b/contrib/Makefile new file mode 100644 index 0000000..3f6d35e --- /dev/null +++ b/contrib/Makefile @@ -0,0 +1,8 @@ +SUBDIRS = $(wildcard */.) + +all: $(SUBDIRS) + +$(SUBDIRS): + $(MAKE) -C $@ + +.PHONY: all $(SUBDIRS) diff --git a/contrib/postgres/Makefile b/contrib/postgres/Makefile new file mode 100644 index 0000000..d7d33cb --- /dev/null +++ b/contrib/postgres/Makefile @@ -0,0 +1,24 @@ +CC ?= gcc +LD = $(CC) +CFLAGS += -Wall -Wextra -pedantic +CFLAGS += -std=c11 +CFLAGS += -D_POSIX_C_SOURCE=200809L +CFLAGS += -D_DEFAULT_SOURCE +CFLAGS += -fPIC +CFLAGS += -lpq -lconfig -lpthread +CFLAGS += -I../../src/ + +OBJ = postgres.o + +all: remove_obj link + +link: $(OBJ) + $(LD) $(OBJ) -shared -o postgres.so + +remove_obj: + rm -f $(OBJ) + +%.o: %.c + $(CC) $(CFLAGS) -c $< -o $@ + +.PHONY: all link remove_obj diff --git a/src/postgres.c b/contrib/postgres/postgres.c similarity index 99% rename from src/postgres.c rename to contrib/postgres/postgres.c index 498b7ff..e6fc002 100644 --- a/src/postgres.c +++ b/contrib/postgres/postgres.c @@ -356,8 +356,8 @@ postgres_validate(config_setting_t *config) return ret; } -void -register_postgres_module(void) +extern void +schaufel_module_init(void) { ModuleHandler *handler = SCALLOC(1, sizeof(ModuleHandler)); diff --git a/src/postgres.h b/contrib/postgres/postgres.h similarity index 63% rename from src/postgres.h rename to contrib/postgres/postgres.h index 7e79d7c..203cadd 100644 --- a/src/postgres.h +++ b/contrib/postgres/postgres.h @@ -2,6 +2,6 @@ #define _SCHAUFEL_POSTGRES_H_ -void register_postgres_module(void); +extern void schaufel_module_init(void); #endif diff --git a/src/modules.c b/src/modules.c index e8b87e6..28bdb52 100644 --- a/src/modules.c +++ b/src/modules.c @@ -1,6 +1,8 @@ #include +#include #include "modules.h" +#include "utils/logger.h" #include "utils/scalloc.h" /* TODO: temporary */ @@ -8,7 +10,6 @@ #include "exports.h" #include "file.h" #include "kafka.h" -#include "postgres.h" #include "redis.h" @@ -31,6 +32,7 @@ register_module(const char *name, ModuleHandler *handler) { ModuleNode *node = SCALLOC(1, sizeof(ModuleNode)); + /* TODO: check that module with the same name already exists */ node->name = name; node->handler = handler; node->next = modules_head; @@ -61,7 +63,37 @@ register_builtin_modules(void) register_file_module(); register_dummy_module(); register_kafka_module(); - register_postgres_module(); register_redis_module(); register_exports_module(); + + /* TODO: load only modules listed in config */ + load_module("./postgres.so"); +} + +bool +load_module(const char *sopath) +{ + void *handle; + void (*init_func)(void); + + handle = dlopen(sopath, RTLD_NOW); + if (!handle) + { + logger_log("failed to open object '%s': %s", sopath, dlerror()); + return false; + } + + /* find the address of module initializer function */ + init_func = (void(*)(void)) dlsym(handle, "schaufel_module_init"); + if (!init_func) + { + logger_log("could not find symbol 'schaufel_module_init' in '%s': %s", + sopath, dlerror()); + return false; + } + + /* invoke initializer */ + init_func(); + + return true; } diff --git a/src/modules.h b/src/modules.h index 95d97e3..8e610d5 100644 --- a/src/modules.h +++ b/src/modules.h @@ -27,6 +27,7 @@ typedef struct ModuleHandler extern void register_module(const char *name, ModuleHandler *handler); ModuleHandler *lookup_module(const char *name); +bool load_module(const char *sopath); /* TODO: temporary */ void register_builtin_modules(void); From 79aa71f0259199c20fade645ca1df8bde35e0819 Mon Sep 17 00:00:00 2001 From: Ildar Musin Date: Wed, 15 May 2019 15:15:40 +0200 Subject: [PATCH 04/16] Extract kafka, redis and exports to a separate contrib modules --- Makefile | 21 ++-------- Makefile.global | 19 ++++++++++ contrib/exports/Makefile | 24 ++++++++++++ {src => contrib/exports}/exports.c | 0 {src => contrib/exports}/exports.h | 0 contrib/kafka/Makefile | 24 ++++++++++++ {src => contrib/kafka}/kafka.c | 0 {src => contrib/kafka}/kafka.h | 0 contrib/postgres/Makefile | 16 ++++---- contrib/postgres/postgres.c | 4 +- contrib/redis/Makefile | 24 ++++++++++++ {src => contrib/redis}/redis.c | 0 {src => contrib/redis}/redis.h | 0 src/main.c | 6 +++ src/modules.c | 61 +++++++++++++++++++++--------- src/modules.h | 5 +-- 16 files changed, 156 insertions(+), 48 deletions(-) create mode 100644 Makefile.global create mode 100644 contrib/exports/Makefile rename {src => contrib/exports}/exports.c (100%) rename {src => contrib/exports}/exports.h (100%) create mode 100644 contrib/kafka/Makefile rename {src => contrib/kafka}/kafka.c (100%) rename {src => contrib/kafka}/kafka.h (100%) create mode 100644 contrib/redis/Makefile rename {src => contrib/redis}/redis.c (100%) rename {src => contrib/redis}/redis.h (100%) diff --git a/Makefile b/Makefile index 58cfb13..7f6bcd6 100644 --- a/Makefile +++ b/Makefile @@ -1,19 +1,6 @@ -PREFIX ?= /usr/local -BINDIR ?= $(PREFIX)/bin -MANDIR ?= $(PREFIX)/share/man -MAN1DIR = $(MANDIR)/man1 -MAN5DIR = $(MANDIR)/man5 -DOCDIR ?= $(PREFIX)/share/doc/schaufel -INSTALL ?= install -D - -CC ?= gcc -LD = $(CC) -CFLAGS += -Wall -Wextra -pedantic -CFLAGS += -std=c11 -CFLAGS += -D_POSIX_C_SOURCE=200809L -CFLAGS += -D_SCHAUFEL_VERSION='"$(SCHAUFEL_VERSION)"' -CFLAGS += -D_BSD_SOURCE -LIB = -lpthread -ldl -lhiredis -lrdkafka -lpq -lconfig -ljson-c +include Makefile.global + +LIB = -lpthread -ldl -lpq -lconfig INC = -Isrc/ LDFLAGS += -Wl,-E @@ -29,8 +16,6 @@ OBJ_BIN_TEST = $(patsubst t/%.c, $(OBJDIR)/%.o, $(TEST_SOURCES)) DOCS = $(patsubst man/%, doc/%.pdf , $(wildcard man/*)) -SCHAUFEL_VERSION ?= 0.5 - all: release contrib: diff --git a/Makefile.global b/Makefile.global new file mode 100644 index 0000000..fdb3fa4 --- /dev/null +++ b/Makefile.global @@ -0,0 +1,19 @@ +SCHAUFEL_VERSION ?= 0.5 + +PREFIX ?= /usr/local +BINDIR ?= $(PREFIX)/bin +INSTALL_LIBDIR ?= $(PREFIX)/lib/schaufel +MANDIR ?= $(PREFIX)/share/man +MAN1DIR = $(MANDIR)/man1 +MAN5DIR = $(MANDIR)/man5 +DOCDIR ?= $(PREFIX)/share/doc/schaufel +INSTALL ?= install -D + +CC ?= gcc +LD = $(CC) +CFLAGS += -Wall -Wextra -pedantic +CFLAGS += -std=c11 +CFLAGS += -D_POSIX_C_SOURCE=200809L +CFLAGS += -D_SCHAUFEL_VERSION='"$(SCHAUFEL_VERSION)"' +CFLAGS += -D_BSD_SOURCE +CFLAGS += -D_LIBDIR=\"$(INSTALL_LIBDIR)\" diff --git a/contrib/exports/Makefile b/contrib/exports/Makefile new file mode 100644 index 0000000..43aebd7 --- /dev/null +++ b/contrib/exports/Makefile @@ -0,0 +1,24 @@ +include ../../Makefile.global + +CFLAGS += -fPIC +CFLAGS += -lpq -ljson-c -lconfig -lpthread +CFLAGS += -I../../src/ + +OBJ = exports.o +LIB = exports.so + +all: remove_obj link + +link: $(OBJ) + $(LD) $(OBJ) -shared -o $(LIB) + +remove_obj: + rm -f $(OBJ) + +%.o: %.c + $(CC) $(CFLAGS) -c $< -o $@ + +install: all + $(INSTALL) $(LIB) $(DESTDIR)$(INSTALL_LIBDIR)/$(LIB) + +.PHONY: all link remove_obj install diff --git a/src/exports.c b/contrib/exports/exports.c similarity index 100% rename from src/exports.c rename to contrib/exports/exports.c diff --git a/src/exports.h b/contrib/exports/exports.h similarity index 100% rename from src/exports.h rename to contrib/exports/exports.h diff --git a/contrib/kafka/Makefile b/contrib/kafka/Makefile new file mode 100644 index 0000000..e824c46 --- /dev/null +++ b/contrib/kafka/Makefile @@ -0,0 +1,24 @@ +include ../../Makefile.global + +CFLAGS += -fPIC +CFLAGS += -lrdkafka -lconfig -lpthread +CFLAGS += -I../../src/ + +OBJ = kafka.o +LIB = kafka.so + +all: remove_obj link + +link: $(OBJ) + $(LD) $(OBJ) -shared -o $(LIB) + +remove_obj: + rm -f $(OBJ) + +%.o: %.c + $(CC) $(CFLAGS) -c $< -o $@ + +install: all + $(INSTALL) $(LIB) $(DESTDIR)$(INSTALL_LIBDIR)/$(LIB) + +.PHONY: all link remove_obj install diff --git a/src/kafka.c b/contrib/kafka/kafka.c similarity index 100% rename from src/kafka.c rename to contrib/kafka/kafka.c diff --git a/src/kafka.h b/contrib/kafka/kafka.h similarity index 100% rename from src/kafka.h rename to contrib/kafka/kafka.h diff --git a/contrib/postgres/Makefile b/contrib/postgres/Makefile index d7d33cb..11494bb 100644 --- a/contrib/postgres/Makefile +++ b/contrib/postgres/Makefile @@ -1,19 +1,16 @@ -CC ?= gcc -LD = $(CC) -CFLAGS += -Wall -Wextra -pedantic -CFLAGS += -std=c11 -CFLAGS += -D_POSIX_C_SOURCE=200809L -CFLAGS += -D_DEFAULT_SOURCE +include ../../Makefile.global + CFLAGS += -fPIC CFLAGS += -lpq -lconfig -lpthread CFLAGS += -I../../src/ OBJ = postgres.o +LIB = postgres.so all: remove_obj link link: $(OBJ) - $(LD) $(OBJ) -shared -o postgres.so + $(LD) $(OBJ) -shared -o $(LIB) remove_obj: rm -f $(OBJ) @@ -21,4 +18,7 @@ remove_obj: %.o: %.c $(CC) $(CFLAGS) -c $< -o $@ -.PHONY: all link remove_obj +install: all + $(INSTALL) $(LIB) $(DESTDIR)$(INSTALL_LIBDIR)/$(LIB) + +.PHONY: all link remove_obj install diff --git a/contrib/postgres/postgres.c b/contrib/postgres/postgres.c index e6fc002..c4aaca7 100644 --- a/contrib/postgres/postgres.c +++ b/contrib/postgres/postgres.c @@ -356,8 +356,8 @@ postgres_validate(config_setting_t *config) return ret; } -extern void -schaufel_module_init(void) +void +schaufel_init(void) { ModuleHandler *handler = SCALLOC(1, sizeof(ModuleHandler)); diff --git a/contrib/redis/Makefile b/contrib/redis/Makefile new file mode 100644 index 0000000..f812312 --- /dev/null +++ b/contrib/redis/Makefile @@ -0,0 +1,24 @@ +include ../../Makefile.global + +CFLAGS += -fPIC +CFLAGS += -lhiredis -lconfig -lpthread +CFLAGS += -I../../src/ + +OBJ = redis.o +LIB = redis.so + +all: remove_obj link + +link: $(OBJ) + $(LD) $(OBJ) -shared -o $(LIB) + +remove_obj: + rm -f $(OBJ) + +%.o: %.c + $(CC) $(CFLAGS) -c $< -o $@ + +install: all + $(INSTALL) $(LIB) $(DESTDIR)$(INSTALL_LIBDIR)/$(LIB) + +.PHONY: all link remove_obj install diff --git a/src/redis.c b/contrib/redis/redis.c similarity index 100% rename from src/redis.c rename to contrib/redis/redis.c diff --git a/src/redis.h b/contrib/redis/redis.h similarity index 100% rename from src/redis.h rename to contrib/redis/redis.h diff --git a/src/main.c b/src/main.c index cdea659..0ab0ade 100644 --- a/src/main.c +++ b/src/main.c @@ -350,6 +350,12 @@ main(int argc, char **argv) logger_init(config_lookup(&config, "logger")); + if (!load_libraries(&config)) + { + logger_log("%s %d: Failed to load libraries\n", __FILE__, __LINE__); + abort(); + } + signal(SIGINT, stop); signal(SIGTERM, stop); diff --git a/src/modules.c b/src/modules.c index 28bdb52..a55a049 100644 --- a/src/modules.c +++ b/src/modules.c @@ -1,17 +1,12 @@ #include #include +#include "dummy.h" +#include "file.h" #include "modules.h" #include "utils/logger.h" #include "utils/scalloc.h" -/* TODO: temporary */ -#include "dummy.h" -#include "exports.h" -#include "file.h" -#include "kafka.h" -#include "redis.h" - /* modules list struct */ typedef struct ModuleNode ModuleNode; @@ -56,26 +51,22 @@ lookup_module(const char *name) return NULL; } -/* TODO: temporary */ void register_builtin_modules(void) { register_file_module(); register_dummy_module(); - register_kafka_module(); - register_redis_module(); - register_exports_module(); - - /* TODO: load only modules listed in config */ - load_module("./postgres.so"); } bool -load_module(const char *sopath) +load_library(const char *name) { void *handle; + char sopath[2048]; void (*init_func)(void); + snprintf(sopath, 2048, "%s/%s.so", _LIBDIR, name); + handle = dlopen(sopath, RTLD_NOW); if (!handle) { @@ -84,10 +75,10 @@ load_module(const char *sopath) } /* find the address of module initializer function */ - init_func = (void(*)(void)) dlsym(handle, "schaufel_module_init"); + init_func = (void(*)(void)) dlsym(handle, "schaufel_init"); if (!init_func) { - logger_log("could not find symbol 'schaufel_module_init' in '%s': %s", + logger_log("could not find symbol 'schaufel_init' in '%s': %s", sopath, dlerror()); return false; } @@ -97,3 +88,39 @@ load_module(const char *sopath) return true; } + +bool +load_libraries(config_t *config) +{ + config_setting_t *root; + config_setting_t *libs; + int nlibs; + int i; + + root = config_root_setting(config); + libs = config_setting_get_member(root, "libraries"); + if (!libs) + { + /* no libraries specified */ + return true; + } + + nlibs = config_setting_length(libs); + for (i = 0; i < nlibs; ++i) + { + config_setting_t *lib = config_setting_get_elem(libs, i); + const char *libname; + + if (!lib) + return false; + + libname = config_setting_get_string(lib); + if (!libname) + return false; + + if (!load_library(libname)) + return false; + } + + return true; +} diff --git a/src/modules.h b/src/modules.h index 8e610d5..55b1d24 100644 --- a/src/modules.h +++ b/src/modules.h @@ -27,9 +27,8 @@ typedef struct ModuleHandler extern void register_module(const char *name, ModuleHandler *handler); ModuleHandler *lookup_module(const char *name); -bool load_module(const char *sopath); - -/* TODO: temporary */ void register_builtin_modules(void); +bool load_library(const char *name); +bool load_libraries(config_t *config); #endif From 017446f3bcc9d488d0c6a53dea12b112abd2852b Mon Sep 17 00:00:00 2001 From: Ildar Musin Date: Wed, 15 May 2019 15:55:36 +0200 Subject: [PATCH 05/16] Add recursive clean and install targets to contrib Makefile --- contrib/Makefile | 14 +++++++++++++- contrib/exports/Makefile | 6 +++--- contrib/kafka/Makefile | 6 +++--- contrib/postgres/Makefile | 6 +++--- contrib/redis/Makefile | 6 +++--- 5 files changed, 25 insertions(+), 13 deletions(-) diff --git a/contrib/Makefile b/contrib/Makefile index 3f6d35e..262f21f 100644 --- a/contrib/Makefile +++ b/contrib/Makefile @@ -1,8 +1,20 @@ SUBDIRS = $(wildcard */.) +INSTALLDIRS = $(patsubst %, install-%, $(SUBDIRS)) +CLEANDIRS = $(patsubst %, clean-%, $(SUBDIRS)) all: $(SUBDIRS) +install: $(INSTALLDIRS) + +clean: $(CLEANDIRS) + $(SUBDIRS): $(MAKE) -C $@ -.PHONY: all $(SUBDIRS) +$(INSTALLDIRS): + $(MAKE) -C $(patsubst install-%, %, $@) install + +$(CLEANDIRS): + $(MAKE) -C $(patsubst clean-%, %, $@) clean + +.PHONY: all $(SUBDIRS) $(INSTALLDIRS) $(CLEANDIRS) diff --git a/contrib/exports/Makefile b/contrib/exports/Makefile index 43aebd7..efe1426 100644 --- a/contrib/exports/Makefile +++ b/contrib/exports/Makefile @@ -7,12 +7,12 @@ CFLAGS += -I../../src/ OBJ = exports.o LIB = exports.so -all: remove_obj link +all: clean link link: $(OBJ) $(LD) $(OBJ) -shared -o $(LIB) -remove_obj: +clean: rm -f $(OBJ) %.o: %.c @@ -21,4 +21,4 @@ remove_obj: install: all $(INSTALL) $(LIB) $(DESTDIR)$(INSTALL_LIBDIR)/$(LIB) -.PHONY: all link remove_obj install +.PHONY: all link clean install diff --git a/contrib/kafka/Makefile b/contrib/kafka/Makefile index e824c46..42d20f0 100644 --- a/contrib/kafka/Makefile +++ b/contrib/kafka/Makefile @@ -7,12 +7,12 @@ CFLAGS += -I../../src/ OBJ = kafka.o LIB = kafka.so -all: remove_obj link +all: clean link link: $(OBJ) $(LD) $(OBJ) -shared -o $(LIB) -remove_obj: +clean: rm -f $(OBJ) %.o: %.c @@ -21,4 +21,4 @@ remove_obj: install: all $(INSTALL) $(LIB) $(DESTDIR)$(INSTALL_LIBDIR)/$(LIB) -.PHONY: all link remove_obj install +.PHONY: all link clean install diff --git a/contrib/postgres/Makefile b/contrib/postgres/Makefile index 11494bb..61e95af 100644 --- a/contrib/postgres/Makefile +++ b/contrib/postgres/Makefile @@ -7,12 +7,12 @@ CFLAGS += -I../../src/ OBJ = postgres.o LIB = postgres.so -all: remove_obj link +all: clean link link: $(OBJ) $(LD) $(OBJ) -shared -o $(LIB) -remove_obj: +clean: rm -f $(OBJ) %.o: %.c @@ -21,4 +21,4 @@ remove_obj: install: all $(INSTALL) $(LIB) $(DESTDIR)$(INSTALL_LIBDIR)/$(LIB) -.PHONY: all link remove_obj install +.PHONY: all link clean install diff --git a/contrib/redis/Makefile b/contrib/redis/Makefile index f812312..e0f10e0 100644 --- a/contrib/redis/Makefile +++ b/contrib/redis/Makefile @@ -7,12 +7,12 @@ CFLAGS += -I../../src/ OBJ = redis.o LIB = redis.so -all: remove_obj link +all: clean link link: $(OBJ) $(LD) $(OBJ) -shared -o $(LIB) -remove_obj: +clean: rm -f $(OBJ) %.o: %.c @@ -21,4 +21,4 @@ remove_obj: install: all $(INSTALL) $(LIB) $(DESTDIR)$(INSTALL_LIBDIR)/$(LIB) -.PHONY: all link remove_obj install +.PHONY: all link clean install From b19fe2e14f8ec1733cbc724b5bf92400ca30dd11 Mon Sep 17 00:00:00 2001 From: Ildar Musin Date: Wed, 15 May 2019 16:14:46 +0200 Subject: [PATCH 06/16] Load libraries before config validation; fix contrib modules' init func --- contrib/exports/exports.c | 2 +- contrib/kafka/kafka.c | 2 +- contrib/redis/redis.c | 2 +- src/main.c | 12 ++++++------ 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/contrib/exports/exports.c b/contrib/exports/exports.c index 6fb0e08..e973ca8 100644 --- a/contrib/exports/exports.c +++ b/contrib/exports/exports.c @@ -582,7 +582,7 @@ exports_validate(UNUSED config_setting_t *config) } void -register_exports_module(void) +schaufel_init(void) { ModuleHandler *handler = SCALLOC(1, sizeof(ModuleHandler)); diff --git a/contrib/kafka/kafka.c b/contrib/kafka/kafka.c index 74657fb..c127af9 100644 --- a/contrib/kafka/kafka.c +++ b/contrib/kafka/kafka.c @@ -396,7 +396,7 @@ kafka_consumer_validator(config_setting_t *config) } void -register_kafka_module(void) +schaufel_init(void) { ModuleHandler *handler = SCALLOC(1, sizeof(ModuleHandler)); diff --git a/contrib/redis/redis.c b/contrib/redis/redis.c index d202b6f..131c111 100644 --- a/contrib/redis/redis.c +++ b/contrib/redis/redis.c @@ -228,7 +228,7 @@ redis_validator(config_setting_t *config) } void -register_redis_module(void) +schaufel_init(void) { ModuleHandler *handler = SCALLOC(1, sizeof(ModuleHandler)); diff --git a/src/main.c b/src/main.c index 0ab0ade..c917524 100644 --- a/src/main.c +++ b/src/main.c @@ -341,6 +341,12 @@ main(int argc, char **argv) config_merge(&config, o); + if (!load_libraries(&config)) + { + logger_log("%s %d: Failed to load libraries\n", __FILE__, __LINE__); + abort(); + } + if(!config_validate(&config)) { if(!o.config) print_usage(); @@ -350,12 +356,6 @@ main(int argc, char **argv) logger_init(config_lookup(&config, "logger")); - if (!load_libraries(&config)) - { - logger_log("%s %d: Failed to load libraries\n", __FILE__, __LINE__); - abort(); - } - signal(SIGINT, stop); signal(SIGTERM, stop); From a68aff187011c837637c4c926dbd763983ff3ec0 Mon Sep 17 00:00:00 2001 From: Ildar Musin Date: Fri, 17 May 2019 16:58:41 +0200 Subject: [PATCH 07/16] First attempt to add autoconf script --- Makefile.global | 19 ----------------- Makefile.global.in | 10 +++++++++ Makefile => Makefile.in | 33 +++++++++++++++++++++++------ configure.ac | 47 +++++++++++++++++++++++++++++++++++++++++ src/main.c | 5 +++-- src/modules.c | 4 +++- 6 files changed, 90 insertions(+), 28 deletions(-) delete mode 100644 Makefile.global create mode 100644 Makefile.global.in rename Makefile => Makefile.in (61%) create mode 100644 configure.ac diff --git a/Makefile.global b/Makefile.global deleted file mode 100644 index fdb3fa4..0000000 --- a/Makefile.global +++ /dev/null @@ -1,19 +0,0 @@ -SCHAUFEL_VERSION ?= 0.5 - -PREFIX ?= /usr/local -BINDIR ?= $(PREFIX)/bin -INSTALL_LIBDIR ?= $(PREFIX)/lib/schaufel -MANDIR ?= $(PREFIX)/share/man -MAN1DIR = $(MANDIR)/man1 -MAN5DIR = $(MANDIR)/man5 -DOCDIR ?= $(PREFIX)/share/doc/schaufel -INSTALL ?= install -D - -CC ?= gcc -LD = $(CC) -CFLAGS += -Wall -Wextra -pedantic -CFLAGS += -std=c11 -CFLAGS += -D_POSIX_C_SOURCE=200809L -CFLAGS += -D_SCHAUFEL_VERSION='"$(SCHAUFEL_VERSION)"' -CFLAGS += -D_BSD_SOURCE -CFLAGS += -D_LIBDIR=\"$(INSTALL_LIBDIR)\" diff --git a/Makefile.global.in b/Makefile.global.in new file mode 100644 index 0000000..bcc909e --- /dev/null +++ b/Makefile.global.in @@ -0,0 +1,10 @@ +BINDIR ?= @bindir@ +CONTRIB_LIBDIR ?= @libdir@/schaufel +MANDIR ?= @mandir@ +MAN1DIR = $(MANDIR)/man1 +MAN5DIR = $(MANDIR)/man5 +DOCDIR ?= @docdir@/schaufel +INSTALL ?= install -D + +CC = @CC@ +LD = @CC@ diff --git a/Makefile b/Makefile.in similarity index 61% rename from Makefile rename to Makefile.in index 7f6bcd6..19ef42f 100644 --- a/Makefile +++ b/Makefile.in @@ -1,6 +1,17 @@ include Makefile.global -LIB = -lpthread -ldl -lpq -lconfig +CC=@CC@ +LD=@CC@ +CFLAGS=@CFLAGS@ +LIBS=@LIBS@ + +bindir := @bindir@ +includedir := @includedir@ +libdir := @libdir@ +mandir := @mandir@ +docdir := @docdir@ + +#LIB = -lpthread -ldl -lpq -lconfig INC = -Isrc/ LDFLAGS += -Wl,-E @@ -26,7 +37,7 @@ docs: $(DOCS) doc/%.pdf: man/* groff -mandoc -f H -T ps $^ | ps2pdf - $@ -release: before_release $(OBJ) out_release +release: before_release src/config_paths.h $(OBJ) out_release test: clean_release before_release $(OBJ_TEST) $(OBJ_BIN_TEST) @@ -41,15 +52,18 @@ clean_release: rm -rf $(OBJDIR) rm -rf doc/*.pdf +clean_paths: + rm -f src/config_paths.h + out_release: $(OBJ) - $(LD) $(LIBDIR) $(LDFLAGS) $(OBJ) $(LIB) -o $(OUT) + $(LD) $(LIBDIR) $(LDFLAGS) $(OBJ) $(LIBS) -o $(OUT) -$(OBJDIR)/%.o: src/%.c - $(CC) $(INC) $(CFLAGS) -c $< -o $@ +$(OBJDIR)/%.o: src/%.c + $(CC) $(INC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@ $(OBJDIR)/%.o: t/%.c $(CC) $(INC) $(CFLAGS) -c $< -o $@ - $(LD) $(LIBDIR) $(OBJ_TEST) $@ $(LIB) -o bin/$(subst .o, ,$(notdir $@)) + $(LD) $(LIBDIR) $(OBJ_TEST) $@ $(LIBS) -o bin/$(subst .o, ,$(notdir $@)) valgrind -q --leak-check=full bin/$(subst .o, ,$(notdir $@)) install: all @@ -58,4 +72,11 @@ install: all $(INSTALL) -m 0644 man/schaufel.1 $(DESTDIR)$(MAN1DIR)/schaufel.1 $(INSTALL) -m 0644 man/schaufel.conf.5 $(DESTDIR)$(MAN5DIR)/schaufel.conf.5 +src/config_paths.h: + echo "#define INCLUDEDIR \"$(includedir)\"" >>$@ + echo "#define LIBDIR \"$(libdir)\"" >>$@ + echo "#define CONTRIBDIR \"$(libdir)/@PACKAGE_NAME@\"" >>$@ + echo "#define DOCDIR \"$(docdir)\"" >>$@ + echo "#define MANDIR \"$(mandir)\"" >>$@ + .PHONY: all contrib docs release test clean diff --git a/configure.ac b/configure.ac new file mode 100644 index 0000000..e347da3 --- /dev/null +++ b/configure.ac @@ -0,0 +1,47 @@ +AC_INIT(schaufel, 0.5) +AC_LANG(C) +AC_PROG_CC + +AM_INIT_AUTOMAKE([foreign -Wall -Werror]) + +#AC_USE_SYSTEM_EXTENSIONS +#AC_CHECK_FUNCS(getopt) +#AC_CHECK_HEADERS([fcntl.h]) +#AC_CHECK_HEADER_STDBOOL + +AX_CHECK_COMPILE_FLAG([-std=c11], [ + CFLAGS+=" -std=c11" +], [ + echo "C compiler cannot compile C11 code" + exit -1 +]) + +dnl The dlopen() function is in the C library for *BSD and in +dnl libdl on GLIBC-based systems +AC_SEARCH_LIBS([dlopen], [dl dld], [], [ + AC_MSG_ERROR([unable to find the dlopen() function]) +]) + +AC_CHECK_LIB([config], [config_init], [], [ + AC_MSG_ERROR([unable to find the config_init() function]) +]) + +AC_CHECK_LIB([pthread], [pthread_create], [], [ + AC_MSG_ERROR([unable to find the pthread_create() function]) +]) + +#TODO: move to the contribs +AC_CHECK_LIB([pq], [PQputCopyData], [], [ + AC_MSG_ERROR([unable to find the PQputCopyData() function]) +]) + +AC_DEFINE_UNQUOTED([VERSION_NUM], [$VERSION], [Numeric version]) + +CFLAGS+=" -Wall -Wextra -pedantic" +CFLAGS+=" -D_POSIX_C_SOURCE=200809L" +CFLAGS+=" -D_BSD_SOURCE" + +AC_CONFIG_HEADERS([src/config.h]) + +AC_OUTPUT(Makefile.global) +AC_OUTPUT(Makefile) diff --git a/src/main.c b/src/main.c index c917524..119311c 100644 --- a/src/main.c +++ b/src/main.c @@ -8,6 +8,7 @@ #include #include +#include "config.h" #include "consumer.h" #include "modules.h" #include "producer.h" @@ -79,8 +80,8 @@ NORETURN void print_version() { printf("schaufel version: " - _SCHAUFEL_VERSION - "\n"); + VERSION + "\n"); exit(0); } diff --git a/src/modules.c b/src/modules.c index a55a049..6b5b443 100644 --- a/src/modules.c +++ b/src/modules.c @@ -1,6 +1,8 @@ #include #include +#include "config.h" +#include "config_paths.h" #include "dummy.h" #include "file.h" #include "modules.h" @@ -65,7 +67,7 @@ load_library(const char *name) char sopath[2048]; void (*init_func)(void); - snprintf(sopath, 2048, "%s/%s.so", _LIBDIR, name); + snprintf(sopath, 2048, "%s/%s.so", CONTRIBDIR, name); handle = dlopen(sopath, RTLD_NOW); if (!handle) From f7dd794b21b1314750bbd9e85dc6b36fafc2df45 Mon Sep 17 00:00:00 2001 From: Ildar Musin Date: Mon, 20 May 2019 16:54:41 +0200 Subject: [PATCH 08/16] Move postgres utility functions to contribs --- Makefile.global.in | 4 +- Makefile.in | 9 +--- configure.ac | 28 ++++-------- contrib/exports/Makefile | 2 +- contrib/exports/exports.c | 87 ++++++++++++++++++++++++++++++++++--- contrib/exports/exports.h | 7 --- contrib/kafka/Makefile | 2 +- contrib/kafka/kafka.c | 1 - contrib/kafka/kafka.h | 7 --- contrib/postgres/Makefile | 2 +- contrib/postgres/postgres.c | 81 +++++++++++++++++++++++++++++++--- contrib/postgres/postgres.h | 7 --- contrib/redis/Makefile | 2 +- contrib/redis/redis.c | 1 - contrib/redis/redis.h | 7 --- src/main.c | 2 +- src/utils/postgres.c | 60 ------------------------- src/utils/postgres.h | 32 -------------- 18 files changed, 174 insertions(+), 167 deletions(-) delete mode 100644 contrib/exports/exports.h delete mode 100644 contrib/kafka/kafka.h delete mode 100644 contrib/postgres/postgres.h delete mode 100644 contrib/redis/redis.h delete mode 100644 src/utils/postgres.c delete mode 100644 src/utils/postgres.h diff --git a/Makefile.global.in b/Makefile.global.in index bcc909e..db930d2 100644 --- a/Makefile.global.in +++ b/Makefile.global.in @@ -1,10 +1,12 @@ BINDIR ?= @bindir@ -CONTRIB_LIBDIR ?= @libdir@/schaufel +CONTRIBDIR ?= @libdir@/schaufel MANDIR ?= @mandir@ MAN1DIR = $(MANDIR)/man1 MAN5DIR = $(MANDIR)/man5 DOCDIR ?= @docdir@/schaufel INSTALL ?= install -D +DATAROOTDIR := @datarootdir@ +PTHREAD_LIB = @PTHREAD_LIB@ CC = @CC@ LD = @CC@ diff --git a/Makefile.in b/Makefile.in index 19ef42f..7154520 100644 --- a/Makefile.in +++ b/Makefile.in @@ -5,13 +5,6 @@ LD=@CC@ CFLAGS=@CFLAGS@ LIBS=@LIBS@ -bindir := @bindir@ -includedir := @includedir@ -libdir := @libdir@ -mandir := @mandir@ -docdir := @docdir@ - -#LIB = -lpthread -ldl -lpq -lconfig INC = -Isrc/ LDFLAGS += -Wl,-E @@ -44,7 +37,7 @@ test: clean_release before_release $(OBJ_TEST) $(OBJ_BIN_TEST) before_release: mkdir -p obj/utils bin -clean: clean_release +clean: clean_release clean_paths clean_release: rm -f $(OBJ) $(OUT) diff --git a/configure.ac b/configure.ac index e347da3..d382dbb 100644 --- a/configure.ac +++ b/configure.ac @@ -1,19 +1,14 @@ +AC_CONFIG_AUX_DIR([build-aux]) + AC_INIT(schaufel, 0.5) + AC_LANG(C) AC_PROG_CC -AM_INIT_AUTOMAKE([foreign -Wall -Werror]) - -#AC_USE_SYSTEM_EXTENSIONS -#AC_CHECK_FUNCS(getopt) -#AC_CHECK_HEADERS([fcntl.h]) -#AC_CHECK_HEADER_STDBOOL - AX_CHECK_COMPILE_FLAG([-std=c11], [ CFLAGS+=" -std=c11" ], [ - echo "C compiler cannot compile C11 code" - exit -1 + AC_MSG_ERROR([C compiler cannot compile C11 code]) ]) dnl The dlopen() function is in the C library for *BSD and in @@ -26,22 +21,17 @@ AC_CHECK_LIB([config], [config_init], [], [ AC_MSG_ERROR([unable to find the config_init() function]) ]) -AC_CHECK_LIB([pthread], [pthread_create], [], [ +AC_SEARCH_LIBS([pthread_create], [pthread], [ + PTHREAD_LIB=$ac_cv_search_pthread_create + AC_SUBST([PTHREAD_LIB]) + ], [ AC_MSG_ERROR([unable to find the pthread_create() function]) ]) -#TODO: move to the contribs -AC_CHECK_LIB([pq], [PQputCopyData], [], [ - AC_MSG_ERROR([unable to find the PQputCopyData() function]) -]) - -AC_DEFINE_UNQUOTED([VERSION_NUM], [$VERSION], [Numeric version]) - CFLAGS+=" -Wall -Wextra -pedantic" CFLAGS+=" -D_POSIX_C_SOURCE=200809L" CFLAGS+=" -D_BSD_SOURCE" AC_CONFIG_HEADERS([src/config.h]) -AC_OUTPUT(Makefile.global) -AC_OUTPUT(Makefile) +AC_OUTPUT([Makefile Makefile.global]) diff --git a/contrib/exports/Makefile b/contrib/exports/Makefile index efe1426..918f797 100644 --- a/contrib/exports/Makefile +++ b/contrib/exports/Makefile @@ -19,6 +19,6 @@ clean: $(CC) $(CFLAGS) -c $< -o $@ install: all - $(INSTALL) $(LIB) $(DESTDIR)$(INSTALL_LIBDIR)/$(LIB) + $(INSTALL) $(LIB) $(CONTRIBDIR)/$(LIB) .PHONY: all link clean install diff --git a/contrib/exports/exports.c b/contrib/exports/exports.c index e973ca8..947d8a2 100644 --- a/contrib/exports/exports.c +++ b/contrib/exports/exports.c @@ -1,20 +1,23 @@ +#include #include +#include #include #include #include #include -#include -#include +#include -#include "exports.h" #include "modules.h" #include "utils/config.h" #include "utils/helper.h" #include "utils/logger.h" -#include "utils/postgres.h" #include "utils/scalloc.h" +#define PQ_COPY_TEXT 0 +#define PQ_COPY_CSV 1 +#define PQ_COPY_BINARY 2 + typedef struct Needles *Needles; typedef struct Needles { char *jpointer; @@ -31,6 +34,22 @@ typedef struct Internal { uint16_t ncount; } *Internal; +typedef struct Meta { + PGconn *conn_master; + PGconn *conn_replica; + PGresult *res; + char *conninfo; + char *conninfo_replica; + char *cpycmd; + int cpyfmt; + int count; + int copy; + int commit_iter; + pthread_mutex_t commit_mutex; + pthread_t commit_worker; + Internal internal; +} *Meta; + static bool _json_to_pqtext (json_object *needle, Needles current); static bool _json_to_pqtimestamp (json_object *needle, Needles current); static void _obj_noop(UNUSED void **obj); @@ -77,6 +96,60 @@ _connectinfo(const char *host) return conninfo; } +static void +_commit(Meta *m) +{ + if((*m)->cpyfmt == PQ_COPY_BINARY) + PQputCopyData((*m)->conn_master, "\377\377", 2); + PQputCopyEnd((*m)->conn_master, NULL); + if ((*m)->conninfo_replica) + PQputCopyEnd((*m)->conn_replica, NULL); + + (*m)->count = 0; + (*m)->copy = 0; + (*m)->commit_iter = 0; +} + +static void +_commit_worker_cleanup(void *mutex) +{ + pthread_mutex_unlock((pthread_mutex_t*) mutex); + return; +} + +static void * +_commit_worker(void *meta) +{ + Meta *m = (Meta *) meta; + + #ifdef PR_SET_NAME + prctl(PR_SET_NAME, "commit_worker"); + #endif + + while(42) + { + sleep(1); + + pthread_mutex_lock(&((*m)->commit_mutex)); + pthread_cleanup_push(_commit_worker_cleanup, &(*m)->commit_mutex); + + (*m)->commit_iter++; + (*m)->commit_iter &= 0xF; + + /* if count > 0 it implies that copy == 1, + * therefore it is safe to commit data */ + if((!((*m)->commit_iter)) && ((*m)->count > 0)) { + logger_log("%s %d: Autocommiting %d entries", + __FILE__, __LINE__, (*m)->count); + _commit(m); + } + + pthread_cleanup_pop(0); + pthread_mutex_unlock(&((*m)->commit_mutex)); + pthread_testcancel(); + } +} + static PqTypes _pqtype_enum(const char *pqtype) { @@ -370,7 +443,7 @@ exports_producer_init(config_setting_t *config) if (pthread_create(&((Meta)(exports->meta))->commit_worker, NULL, - commit_worker, + _commit_worker, (void *)&(exports->meta))) { logger_log("%s %d: Failed to create commit worker!", __FILE__, __LINE__); abort(); @@ -472,7 +545,7 @@ exports_producer_produce(Producer p, Message msg) m->count = m->count + 1; if (m->count == 2000) { - commit(&m); + _commit(&m); } error: @@ -491,7 +564,7 @@ exports_producer_free(Producer *p) if (m->copy != 0) { - commit(&m); + _commit(&m); } exports_meta_free(&m); diff --git a/contrib/exports/exports.h b/contrib/exports/exports.h deleted file mode 100644 index ba472bb..0000000 --- a/contrib/exports/exports.h +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef _SCHAUFEL_EXPORTS_H_ -#define _SCHAUFEL_EXPORTS_H_ - - -void register_exports_module(void); - -#endif diff --git a/contrib/kafka/Makefile b/contrib/kafka/Makefile index 42d20f0..e466db0 100644 --- a/contrib/kafka/Makefile +++ b/contrib/kafka/Makefile @@ -19,6 +19,6 @@ clean: $(CC) $(CFLAGS) -c $< -o $@ install: all - $(INSTALL) $(LIB) $(DESTDIR)$(INSTALL_LIBDIR)/$(LIB) + $(INSTALL) $(LIB) $(CONTRIBDIR)/$(LIB) .PHONY: all link clean install diff --git a/contrib/kafka/kafka.c b/contrib/kafka/kafka.c index c127af9..62b753e 100644 --- a/contrib/kafka/kafka.c +++ b/contrib/kafka/kafka.c @@ -4,7 +4,6 @@ #include #include -#include "kafka.h" #include "modules.h" #include "utils/config.h" #include "utils/helper.h" diff --git a/contrib/kafka/kafka.h b/contrib/kafka/kafka.h deleted file mode 100644 index 00542fe..0000000 --- a/contrib/kafka/kafka.h +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef _SCHAUFEL_KAFKA_H_ -#define _SCHAUFEL_KAFKA_H_ - - -void register_kafka_module(void); - -#endif diff --git a/contrib/postgres/Makefile b/contrib/postgres/Makefile index 61e95af..eee2660 100644 --- a/contrib/postgres/Makefile +++ b/contrib/postgres/Makefile @@ -19,6 +19,6 @@ clean: $(CC) $(CFLAGS) -c $< -o $@ install: all - $(INSTALL) $(LIB) $(DESTDIR)$(INSTALL_LIBDIR)/$(LIB) + $(INSTALL) $(LIB) $(CONTRIBDIR)/$(LIB) .PHONY: all link clean install diff --git a/contrib/postgres/postgres.c b/contrib/postgres/postgres.c index c4aaca7..74e2c7d 100644 --- a/contrib/postgres/postgres.c +++ b/contrib/postgres/postgres.c @@ -2,17 +2,35 @@ #include #include #include +#include #include "modules.h" -#include "postgres.h" #include "utils/array.h" #include "utils/config.h" #include "utils/helper.h" #include "utils/logger.h" -#include "utils/postgres.h" #include "utils/scalloc.h" +#define PQ_COPY_TEXT 0 +#define PQ_COPY_CSV 1 +#define PQ_COPY_BINARY 2 + +typedef struct Meta { + PGconn *conn_master; + PGconn *conn_replica; + PGresult *res; + char *conninfo; + char *conninfo_replica; + char *cpycmd; + int cpyfmt; + int count; + int copy; + int commit_iter; + pthread_mutex_t commit_mutex; + pthread_t commit_worker; +} *Meta; + char * _connectinfo(const char *host) { @@ -70,6 +88,59 @@ _cpycmd(const char *host, const char *generation) return cpycmd; } +static void +_commit(Meta *m) +{ + if((*m)->cpyfmt == PQ_COPY_BINARY) + PQputCopyData((*m)->conn_master, "\377\377", 2); + PQputCopyEnd((*m)->conn_master, NULL); + if ((*m)->conninfo_replica) + PQputCopyEnd((*m)->conn_replica, NULL); + + (*m)->count = 0; + (*m)->copy = 0; + (*m)->commit_iter = 0; +} + +static void +_commit_worker_cleanup(void *mutex) +{ + pthread_mutex_unlock((pthread_mutex_t*) mutex); + return; +} + +static void * +_commit_worker(void *meta) +{ + Meta *m = (Meta *) meta; + + #ifdef PR_SET_NAME + prctl(PR_SET_NAME, "commit_worker"); + #endif + + while(42) + { + sleep(1); + + pthread_mutex_lock(&((*m)->commit_mutex)); + pthread_cleanup_push(_commit_worker_cleanup, &(*m)->commit_mutex); + + (*m)->commit_iter++; + (*m)->commit_iter &= 0xF; + + /* if count > 0 it implies that copy == 1, + * therefore it is safe to commit data */ + if((!((*m)->commit_iter)) && ((*m)->count > 0)) { + logger_log("%s %d: Autocommiting %d entries", + __FILE__, __LINE__, (*m)->count); + _commit(m); + } + + pthread_cleanup_pop(0); + pthread_mutex_unlock(&((*m)->commit_mutex)); + pthread_testcancel(); + } +} Meta postgres_meta_init(const char *host, const char *host_replica, const char *generation) @@ -134,7 +205,7 @@ postgres_producer_init(config_setting_t *config) if (pthread_create(&((Meta)(postgres->meta))->commit_worker, NULL, - commit_worker, + _commit_worker, (void *)&(postgres->meta))) { logger_log("%s %d: Failed to create commit worker!", __FILE__, __LINE__); abort(); @@ -214,7 +285,7 @@ postgres_producer_produce(Producer p, Message msg) m->count = m->count + 1; if (m->count == 2000) { - commit(&m); + _commit(&m); } pthread_mutex_unlock(&m->commit_mutex); @@ -232,7 +303,7 @@ postgres_producer_free(Producer *p) if (m->copy != 0) { - commit(&m); + _commit(&m); } postgres_meta_free(&m); diff --git a/contrib/postgres/postgres.h b/contrib/postgres/postgres.h deleted file mode 100644 index 203cadd..0000000 --- a/contrib/postgres/postgres.h +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef _SCHAUFEL_POSTGRES_H_ -#define _SCHAUFEL_POSTGRES_H_ - - -extern void schaufel_module_init(void); - -#endif diff --git a/contrib/redis/Makefile b/contrib/redis/Makefile index e0f10e0..b4a7306 100644 --- a/contrib/redis/Makefile +++ b/contrib/redis/Makefile @@ -19,6 +19,6 @@ clean: $(CC) $(CFLAGS) -c $< -o $@ install: all - $(INSTALL) $(LIB) $(DESTDIR)$(INSTALL_LIBDIR)/$(LIB) + $(INSTALL) $(LIB) $(CONTRIBDIR)/$(LIB) .PHONY: all link clean install diff --git a/contrib/redis/redis.c b/contrib/redis/redis.c index 131c111..c5716f9 100644 --- a/contrib/redis/redis.c +++ b/contrib/redis/redis.c @@ -4,7 +4,6 @@ #include #include "modules.h" -#include "redis.h" #include "utils/config.h" #include "utils/logger.h" #include "utils/helper.h" diff --git a/contrib/redis/redis.h b/contrib/redis/redis.h deleted file mode 100644 index 7bb42bc..0000000 --- a/contrib/redis/redis.h +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef _SCHAUFEL_REDIS_H_ -#define _SCHAUFEL_REDIS_H_ - - -void register_redis_module(void); - -#endif diff --git a/src/main.c b/src/main.c index 119311c..9626490 100644 --- a/src/main.c +++ b/src/main.c @@ -80,7 +80,7 @@ NORETURN void print_version() { printf("schaufel version: " - VERSION + PACKAGE_VERSION "\n"); exit(0); } diff --git a/src/utils/postgres.c b/src/utils/postgres.c deleted file mode 100644 index 4f28dfb..0000000 --- a/src/utils/postgres.c +++ /dev/null @@ -1,60 +0,0 @@ -#include -#include - -#include "utils/logger.h" -#include "utils/postgres.h" - - -void -commit(Meta *m) -{ - if((*m)->cpyfmt == PQ_COPY_BINARY) - PQputCopyData((*m)->conn_master, "\377\377", 2); - PQputCopyEnd((*m)->conn_master, NULL); - if ((*m)->conninfo_replica) - PQputCopyEnd((*m)->conn_replica, NULL); - - (*m)->count = 0; - (*m)->copy = 0; - (*m)->commit_iter = 0; -} - -static void -_commit_worker_cleanup(void *mutex) -{ - pthread_mutex_unlock((pthread_mutex_t*) mutex); - return; -} - -void * -commit_worker(void *meta) -{ - Meta *m = (Meta *) meta; - - #ifdef PR_SET_NAME - prctl(PR_SET_NAME, "commit_worker"); - #endif - - while(42) - { - sleep(1); - - pthread_mutex_lock(&((*m)->commit_mutex)); - pthread_cleanup_push(_commit_worker_cleanup, &(*m)->commit_mutex); - - (*m)->commit_iter++; - (*m)->commit_iter &= 0xF; - - /* if count > 0 it implies that copy == 1, - * therefore it is safe to commit data */ - if((!((*m)->commit_iter)) && ((*m)->count > 0)) { - logger_log("%s %d: Autocommiting %d entries", - __FILE__, __LINE__, (*m)->count); - commit(m); - } - - pthread_cleanup_pop(0); - pthread_mutex_unlock(&((*m)->commit_mutex)); - pthread_testcancel(); - } -} diff --git a/src/utils/postgres.h b/src/utils/postgres.h deleted file mode 100644 index 99895f8..0000000 --- a/src/utils/postgres.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef _SCHAUFEL_UTILS_POSTGRES_H -#define _SCHAUFEL_UTILS_POSTGRES_H - -#include -#include - -#define PQ_COPY_TEXT 0 -#define PQ_COPY_CSV 1 -#define PQ_COPY_BINARY 2 - -typedef struct Internal *Internal; - -typedef struct Meta { - PGconn *conn_master; - PGconn *conn_replica; - PGresult *res; - char *conninfo; - char *conninfo_replica; - char *cpycmd; - int cpyfmt; - int count; - int copy; - int commit_iter; - pthread_mutex_t commit_mutex; - pthread_t commit_worker; - Internal internal; -} *Meta; - -void commit(Meta *m); - -void *commit_worker(void *meta); -#endif From ef03c0ebf0db80b973e27fcdf9cbbf126f0594c4 Mon Sep 17 00:00:00 2001 From: Ildar Musin Date: Tue, 21 May 2019 15:48:52 +0200 Subject: [PATCH 09/16] Add contrib.mk as a common Makefile for contribs and extensions --- Makefile.global.in | 24 +++++++++++++++--------- Makefile.in | 15 ++++++--------- contrib.mk | 21 +++++++++++++++++++++ contrib/exports/Makefile | 27 ++++----------------------- contrib/kafka/Makefile | 27 ++++----------------------- contrib/postgres/Makefile | 27 ++++----------------------- contrib/redis/Makefile | 27 ++++----------------------- src/modules.c | 15 +++++++++++++-- 8 files changed, 71 insertions(+), 112 deletions(-) create mode 100644 contrib.mk diff --git a/Makefile.global.in b/Makefile.global.in index db930d2..6d31f4e 100644 --- a/Makefile.global.in +++ b/Makefile.global.in @@ -1,12 +1,18 @@ -BINDIR ?= @bindir@ -CONTRIBDIR ?= @libdir@/schaufel -MANDIR ?= @mandir@ -MAN1DIR = $(MANDIR)/man1 -MAN5DIR = $(MANDIR)/man5 -DOCDIR ?= @docdir@/schaufel -INSTALL ?= install -D -DATAROOTDIR := @datarootdir@ -PTHREAD_LIB = @PTHREAD_LIB@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +datarootdir=@datarootdir@ + +bindir ?= @bindir@ +libdir ?= @libdir@ +contribdir ?= @libdir@/@PACKAGE_NAME@ +mandir ?= @mandir@ +man1dir = $(mandir)/man1 +man5dir = $(mandir)/man5 +docdir ?= @docdir@/schaufel CC = @CC@ LD = @CC@ +INSTALL ?= install -D +PTHREAD_LIB = @PTHREAD_LIB@ + +CFLAGS=@CFLAGS@ diff --git a/Makefile.in b/Makefile.in index 7154520..a3a467c 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1,8 +1,5 @@ include Makefile.global -CC=@CC@ -LD=@CC@ -CFLAGS=@CFLAGS@ LIBS=@LIBS@ INC = -Isrc/ @@ -56,19 +53,19 @@ $(OBJDIR)/%.o: src/%.c $(OBJDIR)/%.o: t/%.c $(CC) $(INC) $(CFLAGS) -c $< -o $@ - $(LD) $(LIBDIR) $(OBJ_TEST) $@ $(LIBS) -o bin/$(subst .o, ,$(notdir $@)) + $(LD) $(libdir) $(OBJ_TEST) $@ $(LIBS) -o bin/$(subst .o, ,$(notdir $@)) valgrind -q --leak-check=full bin/$(subst .o, ,$(notdir $@)) install: all - $(INSTALL) bin/schaufel $(DESTDIR)$(BINDIR)/schaufel - $(INSTALL) -m 0644 -t $(DESTDIR)$(DOCDIR) doc/* - $(INSTALL) -m 0644 man/schaufel.1 $(DESTDIR)$(MAN1DIR)/schaufel.1 - $(INSTALL) -m 0644 man/schaufel.conf.5 $(DESTDIR)$(MAN5DIR)/schaufel.conf.5 + $(INSTALL) bin/schaufel $(DESTDIR)$(bindir)/schaufel + $(INSTALL) -m 0644 -t $(DESTDIR)$(docdir) doc/* + $(INSTALL) -m 0644 man/schaufel.1 $(DESTDIR)$(man1dir)/schaufel.1 + $(INSTALL) -m 0644 man/schaufel.conf.5 $(DESTDIR)$(man5dir)/schaufel.conf.5 src/config_paths.h: echo "#define INCLUDEDIR \"$(includedir)\"" >>$@ echo "#define LIBDIR \"$(libdir)\"" >>$@ - echo "#define CONTRIBDIR \"$(libdir)/@PACKAGE_NAME@\"" >>$@ + echo "#define CONTRIBDIR \"$(contribdir)\"" >>$@ echo "#define DOCDIR \"$(docdir)\"" >>$@ echo "#define MANDIR \"$(mandir)\"" >>$@ diff --git a/contrib.mk b/contrib.mk new file mode 100644 index 0000000..276f108 --- /dev/null +++ b/contrib.mk @@ -0,0 +1,21 @@ +include ../../Makefile.global + +CFLAGS += -fPIC +CFLAGS += $(LIBS) +CFLAGS += -I../../src/ + +all: clean link + +link: $(OBJ) + $(LD) $(OBJ) -shared -o $(LIB) + +clean: + rm -f $(OBJ) + +%.o: %.c + $(CC) $(CFLAGS) -c $< -o $@ + +install: all + $(INSTALL) $(LIB) $(CONTRIBDIR)/$(LIB) + +.PHONY: all link clean install diff --git a/contrib/exports/Makefile b/contrib/exports/Makefile index 918f797..31a4064 100644 --- a/contrib/exports/Makefile +++ b/contrib/exports/Makefile @@ -1,24 +1,5 @@ -include ../../Makefile.global +LIBS := -lpq -ljson-c -lconfig -lpthread +OBJ := exports.o +LIB := exports.so -CFLAGS += -fPIC -CFLAGS += -lpq -ljson-c -lconfig -lpthread -CFLAGS += -I../../src/ - -OBJ = exports.o -LIB = exports.so - -all: clean link - -link: $(OBJ) - $(LD) $(OBJ) -shared -o $(LIB) - -clean: - rm -f $(OBJ) - -%.o: %.c - $(CC) $(CFLAGS) -c $< -o $@ - -install: all - $(INSTALL) $(LIB) $(CONTRIBDIR)/$(LIB) - -.PHONY: all link clean install +include ../../contrib.mk diff --git a/contrib/kafka/Makefile b/contrib/kafka/Makefile index e466db0..5c9a0c8 100644 --- a/contrib/kafka/Makefile +++ b/contrib/kafka/Makefile @@ -1,24 +1,5 @@ -include ../../Makefile.global +LIBS := -lrdkafka -lconfig -lpthread +OBJ := kafka.o +LIB := kafka.so -CFLAGS += -fPIC -CFLAGS += -lrdkafka -lconfig -lpthread -CFLAGS += -I../../src/ - -OBJ = kafka.o -LIB = kafka.so - -all: clean link - -link: $(OBJ) - $(LD) $(OBJ) -shared -o $(LIB) - -clean: - rm -f $(OBJ) - -%.o: %.c - $(CC) $(CFLAGS) -c $< -o $@ - -install: all - $(INSTALL) $(LIB) $(CONTRIBDIR)/$(LIB) - -.PHONY: all link clean install +include ../../contrib.mk diff --git a/contrib/postgres/Makefile b/contrib/postgres/Makefile index eee2660..d70ab74 100644 --- a/contrib/postgres/Makefile +++ b/contrib/postgres/Makefile @@ -1,24 +1,5 @@ -include ../../Makefile.global +LIBS := -lpq -lconfig -lpthread +OBJ := postgres.o +LIB := postgres.so -CFLAGS += -fPIC -CFLAGS += -lpq -lconfig -lpthread -CFLAGS += -I../../src/ - -OBJ = postgres.o -LIB = postgres.so - -all: clean link - -link: $(OBJ) - $(LD) $(OBJ) -shared -o $(LIB) - -clean: - rm -f $(OBJ) - -%.o: %.c - $(CC) $(CFLAGS) -c $< -o $@ - -install: all - $(INSTALL) $(LIB) $(CONTRIBDIR)/$(LIB) - -.PHONY: all link clean install +include ../../contrib.mk diff --git a/contrib/redis/Makefile b/contrib/redis/Makefile index b4a7306..2dbd93a 100644 --- a/contrib/redis/Makefile +++ b/contrib/redis/Makefile @@ -1,24 +1,5 @@ -include ../../Makefile.global +LIBS := -lhiredis -lconfig -lpthread +OBJ := redis.o +LIB := redis.so -CFLAGS += -fPIC -CFLAGS += -lhiredis -lconfig -lpthread -CFLAGS += -I../../src/ - -OBJ = redis.o -LIB = redis.so - -all: clean link - -link: $(OBJ) - $(LD) $(OBJ) -shared -o $(LIB) - -clean: - rm -f $(OBJ) - -%.o: %.c - $(CC) $(CFLAGS) -c $< -o $@ - -install: all - $(INSTALL) $(LIB) $(CONTRIBDIR)/$(LIB) - -.PHONY: all link clean install +include ../../contrib.mk diff --git a/src/modules.c b/src/modules.c index 6b5b443..c1c855c 100644 --- a/src/modules.c +++ b/src/modules.c @@ -76,8 +76,19 @@ load_library(const char *name) return false; } - /* find the address of module initializer function */ - init_func = (void(*)(void)) dlsym(handle, "schaufel_init"); + /* + * find the address of module initializer function + * + * XXX: ISO C standard does not allow to convert a pointer to data (void *) + * to a function pointer and vice versa (as they can belong to different + * address spaces and have different size etc, see Harvard + * architecture). For instance, gcc with -pedantic throws a warning. The + * conversion below is a workaround recommended by POSIX and its purpose is + * to suppress warning message. Strictly speaking it does not follow + * the strict aliasing rule and theoretically may cause undefined + * behaviour. + */ + *(void**)(&init_func) = dlsym(handle, "schaufel_init"); if (!init_func) { logger_log("could not find symbol 'schaufel_init' in '%s': %s", From a1fcb86538fa0f6acc43bc3664176547e6ad44fc Mon Sep 17 00:00:00 2001 From: Ildar Musin Date: Tue, 21 May 2019 16:44:27 +0200 Subject: [PATCH 10/16] Move all headers to `include` directory --- Makefile.in | 8 ++++---- configure.ac | 2 +- src/include/build.h | 32 +++++++++++++++++++++++++++++++ src/include/build.h.in | 31 ++++++++++++++++++++++++++++++ src/include/config.h | 32 +++++++++++++++++++++++++++++++ src/include/config_paths.h | 5 +++++ src/{ => include}/consumer.h | 0 src/{ => include}/dummy.h | 0 src/{ => include}/file.h | 0 src/{ => include}/modules.h | 0 src/include/paths.h | 5 +++++ src/{ => include}/producer.h | 0 src/{ => include}/queue.h | 0 src/{ => include}/utils/array.h | 0 src/{ => include}/utils/config.h | 0 src/{ => include}/utils/helper.h | 0 src/{ => include}/utils/logger.h | 0 src/{ => include}/utils/options.h | 0 src/{ => include}/utils/scalloc.h | 0 src/main.c | 2 +- src/modules.c | 4 ++-- src/version.h | 5 ----- 22 files changed, 113 insertions(+), 13 deletions(-) create mode 100644 src/include/build.h create mode 100644 src/include/build.h.in create mode 100644 src/include/config.h create mode 100644 src/include/config_paths.h rename src/{ => include}/consumer.h (100%) rename src/{ => include}/dummy.h (100%) rename src/{ => include}/file.h (100%) rename src/{ => include}/modules.h (100%) create mode 100644 src/include/paths.h rename src/{ => include}/producer.h (100%) rename src/{ => include}/queue.h (100%) rename src/{ => include}/utils/array.h (100%) rename src/{ => include}/utils/config.h (100%) rename src/{ => include}/utils/helper.h (100%) rename src/{ => include}/utils/logger.h (100%) rename src/{ => include}/utils/options.h (100%) rename src/{ => include}/utils/scalloc.h (100%) delete mode 100644 src/version.h diff --git a/Makefile.in b/Makefile.in index a3a467c..a094cdf 100644 --- a/Makefile.in +++ b/Makefile.in @@ -2,7 +2,7 @@ include Makefile.global LIBS=@LIBS@ -INC = -Isrc/ +INC = -Isrc/include LDFLAGS += -Wl,-E OBJDIR = obj @@ -27,7 +27,7 @@ docs: $(DOCS) doc/%.pdf: man/* groff -mandoc -f H -T ps $^ | ps2pdf - $@ -release: before_release src/config_paths.h $(OBJ) out_release +release: before_release src/include/paths.h $(OBJ) out_release test: clean_release before_release $(OBJ_TEST) $(OBJ_BIN_TEST) @@ -43,7 +43,7 @@ clean_release: rm -rf doc/*.pdf clean_paths: - rm -f src/config_paths.h + rm -f src/include/paths.h out_release: $(OBJ) $(LD) $(LIBDIR) $(LDFLAGS) $(OBJ) $(LIBS) -o $(OUT) @@ -62,7 +62,7 @@ install: all $(INSTALL) -m 0644 man/schaufel.1 $(DESTDIR)$(man1dir)/schaufel.1 $(INSTALL) -m 0644 man/schaufel.conf.5 $(DESTDIR)$(man5dir)/schaufel.conf.5 -src/config_paths.h: +src/include/paths.h: echo "#define INCLUDEDIR \"$(includedir)\"" >>$@ echo "#define LIBDIR \"$(libdir)\"" >>$@ echo "#define CONTRIBDIR \"$(contribdir)\"" >>$@ diff --git a/configure.ac b/configure.ac index d382dbb..d8f11c6 100644 --- a/configure.ac +++ b/configure.ac @@ -32,6 +32,6 @@ CFLAGS+=" -Wall -Wextra -pedantic" CFLAGS+=" -D_POSIX_C_SOURCE=200809L" CFLAGS+=" -D_BSD_SOURCE" -AC_CONFIG_HEADERS([src/config.h]) +AC_CONFIG_HEADERS([src/include/build.h]) AC_OUTPUT([Makefile Makefile.global]) diff --git a/src/include/build.h b/src/include/build.h new file mode 100644 index 0000000..dbfda1f --- /dev/null +++ b/src/include/build.h @@ -0,0 +1,32 @@ +/* src/include/build.h. Generated from build.h.in by configure. */ +/* src/config.h.in. Generated from configure.ac by autoheader. */ + +/* Define to 1 if you have the `config' library (-lconfig). */ +#define HAVE_LIBCONFIG 1 + +/* Define to 1 if you have the `pq' library (-lpq). */ +/* #undef HAVE_LIBPQ */ + +/* Define to 1 if you have the `pthread' library (-lpthread). */ +/* #undef HAVE_LIBPTHREAD */ + +/* Define to the address where bug reports for this package should be sent. */ +#define PACKAGE_BUGREPORT "" + +/* Define to the full name of this package. */ +#define PACKAGE_NAME "schaufel" + +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING "schaufel 0.5" + +/* Define to the one symbol short name of this package. */ +#define PACKAGE_TARNAME "schaufel" + +/* Define to the home page for this package. */ +#define PACKAGE_URL "" + +/* Define to the version of this package. */ +#define PACKAGE_VERSION "0.5" + +/* Numeric version */ +/* #undef VERSION_NUM */ diff --git a/src/include/build.h.in b/src/include/build.h.in new file mode 100644 index 0000000..8b64f0e --- /dev/null +++ b/src/include/build.h.in @@ -0,0 +1,31 @@ +/* src/config.h.in. Generated from configure.ac by autoheader. */ + +/* Define to 1 if you have the `config' library (-lconfig). */ +#undef HAVE_LIBCONFIG + +/* Define to 1 if you have the `pq' library (-lpq). */ +#undef HAVE_LIBPQ + +/* Define to 1 if you have the `pthread' library (-lpthread). */ +#undef HAVE_LIBPTHREAD + +/* Define to the address where bug reports for this package should be sent. */ +#undef PACKAGE_BUGREPORT + +/* Define to the full name of this package. */ +#undef PACKAGE_NAME + +/* Define to the full name and version of this package. */ +#undef PACKAGE_STRING + +/* Define to the one symbol short name of this package. */ +#undef PACKAGE_TARNAME + +/* Define to the home page for this package. */ +#undef PACKAGE_URL + +/* Define to the version of this package. */ +#undef PACKAGE_VERSION + +/* Numeric version */ +#undef VERSION_NUM diff --git a/src/include/config.h b/src/include/config.h new file mode 100644 index 0000000..09b592f --- /dev/null +++ b/src/include/config.h @@ -0,0 +1,32 @@ +/* src/include/config.h. Generated from config.h.in by configure. */ +/* src/config.h.in. Generated from configure.ac by autoheader. */ + +/* Define to 1 if you have the `config' library (-lconfig). */ +#define HAVE_LIBCONFIG 1 + +/* Define to 1 if you have the `pq' library (-lpq). */ +/* #undef HAVE_LIBPQ */ + +/* Define to 1 if you have the `pthread' library (-lpthread). */ +/* #undef HAVE_LIBPTHREAD */ + +/* Define to the address where bug reports for this package should be sent. */ +#define PACKAGE_BUGREPORT "" + +/* Define to the full name of this package. */ +#define PACKAGE_NAME "schaufel" + +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING "schaufel 0.5" + +/* Define to the one symbol short name of this package. */ +#define PACKAGE_TARNAME "schaufel" + +/* Define to the home page for this package. */ +#define PACKAGE_URL "" + +/* Define to the version of this package. */ +#define PACKAGE_VERSION "0.5" + +/* Numeric version */ +/* #undef VERSION_NUM */ diff --git a/src/include/config_paths.h b/src/include/config_paths.h new file mode 100644 index 0000000..1442fd1 --- /dev/null +++ b/src/include/config_paths.h @@ -0,0 +1,5 @@ +#define INCLUDEDIR "" +#define LIBDIR "/tmp/schaufel/lib" +#define CONTRIBDIR "/tmp/schaufel/lib/schaufel" +#define DOCDIR "/tmp/schaufel/share/doc//schaufel" +#define MANDIR "/tmp/schaufel/share/man" diff --git a/src/consumer.h b/src/include/consumer.h similarity index 100% rename from src/consumer.h rename to src/include/consumer.h diff --git a/src/dummy.h b/src/include/dummy.h similarity index 100% rename from src/dummy.h rename to src/include/dummy.h diff --git a/src/file.h b/src/include/file.h similarity index 100% rename from src/file.h rename to src/include/file.h diff --git a/src/modules.h b/src/include/modules.h similarity index 100% rename from src/modules.h rename to src/include/modules.h diff --git a/src/include/paths.h b/src/include/paths.h new file mode 100644 index 0000000..8f666c9 --- /dev/null +++ b/src/include/paths.h @@ -0,0 +1,5 @@ +#define INCLUDEDIR "" +#define LIBDIR "/usr/local/lib" +#define CONTRIBDIR "/usr/local/lib/schaufel" +#define DOCDIR "/usr/local/share/doc//schaufel" +#define MANDIR "/usr/local/share/man" diff --git a/src/producer.h b/src/include/producer.h similarity index 100% rename from src/producer.h rename to src/include/producer.h diff --git a/src/queue.h b/src/include/queue.h similarity index 100% rename from src/queue.h rename to src/include/queue.h diff --git a/src/utils/array.h b/src/include/utils/array.h similarity index 100% rename from src/utils/array.h rename to src/include/utils/array.h diff --git a/src/utils/config.h b/src/include/utils/config.h similarity index 100% rename from src/utils/config.h rename to src/include/utils/config.h diff --git a/src/utils/helper.h b/src/include/utils/helper.h similarity index 100% rename from src/utils/helper.h rename to src/include/utils/helper.h diff --git a/src/utils/logger.h b/src/include/utils/logger.h similarity index 100% rename from src/utils/logger.h rename to src/include/utils/logger.h diff --git a/src/utils/options.h b/src/include/utils/options.h similarity index 100% rename from src/utils/options.h rename to src/include/utils/options.h diff --git a/src/utils/scalloc.h b/src/include/utils/scalloc.h similarity index 100% rename from src/utils/scalloc.h rename to src/include/utils/scalloc.h diff --git a/src/main.c b/src/main.c index 9626490..2b69758 100644 --- a/src/main.c +++ b/src/main.c @@ -8,7 +8,7 @@ #include #include -#include "config.h" +#include "build.h" #include "consumer.h" #include "modules.h" #include "producer.h" diff --git a/src/modules.c b/src/modules.c index c1c855c..58de17a 100644 --- a/src/modules.c +++ b/src/modules.c @@ -1,11 +1,11 @@ #include #include -#include "config.h" -#include "config_paths.h" +#include "build.h" #include "dummy.h" #include "file.h" #include "modules.h" +#include "paths.h" #include "utils/logger.h" #include "utils/scalloc.h" diff --git a/src/version.h b/src/version.h deleted file mode 100644 index 124e33b..0000000 --- a/src/version.h +++ /dev/null @@ -1,5 +0,0 @@ -#ifndef _SCHAUFEL_VERSION - -#define _SCHAUFEL_VERSION "unknown unknowns" - -#endif From 12dd76bff54563b2e4fc1c243b9e9a6dafa97e59 Mon Sep 17 00:00:00 2001 From: Ildar Musin Date: Wed, 22 May 2019 17:58:56 +0200 Subject: [PATCH 11/16] Install headers and global makefiles, add options (-I -L) to schaufel that print include path and library path and make use of those to build contribs and extensions --- Makefile.global.in | 2 +- Makefile.in | 6 ++++-- contrib.mk | 13 ++++++++++--- contrib/exports/Makefile | 4 +++- contrib/kafka/Makefile | 4 +++- contrib/postgres/Makefile | 4 +++- contrib/redis/Makefile | 4 +++- src/include/paths.h | 2 +- src/{ => include}/test/test.h | 0 src/main.c | 23 ++++++++++++++++++++++- 10 files changed, 50 insertions(+), 12 deletions(-) rename src/{ => include}/test/test.h (100%) diff --git a/Makefile.global.in b/Makefile.global.in index 6d31f4e..e299cec 100644 --- a/Makefile.global.in +++ b/Makefile.global.in @@ -3,7 +3,7 @@ exec_prefix=@exec_prefix@ datarootdir=@datarootdir@ bindir ?= @bindir@ -libdir ?= @libdir@ +includedir ?= @includedir@/@PACKAGE_NAME@ contribdir ?= @libdir@/@PACKAGE_NAME@ mandir ?= @mandir@ man1dir = $(mandir)/man1 diff --git a/Makefile.in b/Makefile.in index a094cdf..a95c1cb 100644 --- a/Makefile.in +++ b/Makefile.in @@ -53,18 +53,20 @@ $(OBJDIR)/%.o: src/%.c $(OBJDIR)/%.o: t/%.c $(CC) $(INC) $(CFLAGS) -c $< -o $@ - $(LD) $(libdir) $(OBJ_TEST) $@ $(LIBS) -o bin/$(subst .o, ,$(notdir $@)) + $(LD) $(LIBDIR) $(OBJ_TEST) $@ $(LIBS) -o bin/$(subst .o, ,$(notdir $@)) valgrind -q --leak-check=full bin/$(subst .o, ,$(notdir $@)) install: all $(INSTALL) bin/schaufel $(DESTDIR)$(bindir)/schaufel + cp -a src/include $(DESTDIR)$(includedir) + $(INSTALL) -m 0644 contrib.mk $(DESTDIR)$(contribdir)/contrib.mk + $(INSTALL) -m 0644 Makefile.global $(DESTDIR)$(contribdir)/Makefile.global $(INSTALL) -m 0644 -t $(DESTDIR)$(docdir) doc/* $(INSTALL) -m 0644 man/schaufel.1 $(DESTDIR)$(man1dir)/schaufel.1 $(INSTALL) -m 0644 man/schaufel.conf.5 $(DESTDIR)$(man5dir)/schaufel.conf.5 src/include/paths.h: echo "#define INCLUDEDIR \"$(includedir)\"" >>$@ - echo "#define LIBDIR \"$(libdir)\"" >>$@ echo "#define CONTRIBDIR \"$(contribdir)\"" >>$@ echo "#define DOCDIR \"$(docdir)\"" >>$@ echo "#define MANDIR \"$(mandir)\"" >>$@ diff --git a/contrib.mk b/contrib.mk index 276f108..3818c1a 100644 --- a/contrib.mk +++ b/contrib.mk @@ -1,8 +1,15 @@ -include ../../Makefile.global +SCHAUFEL ?= schaufel + +ifdef CONTRIB + include ../../Makefile.global + CFLAGS += -I../../src/include +else + include $(shell $(SCHAUFEL) -L)/Makefile.global + CFLAGS += -I$(shell $(SCHAUFEL) -I) +endif CFLAGS += -fPIC CFLAGS += $(LIBS) -CFLAGS += -I../../src/ all: clean link @@ -16,6 +23,6 @@ clean: $(CC) $(CFLAGS) -c $< -o $@ install: all - $(INSTALL) $(LIB) $(CONTRIBDIR)/$(LIB) + $(INSTALL) $(LIB) $(contribdir)/$(LIB) .PHONY: all link clean install diff --git a/contrib/exports/Makefile b/contrib/exports/Makefile index 31a4064..c55f615 100644 --- a/contrib/exports/Makefile +++ b/contrib/exports/Makefile @@ -1,5 +1,7 @@ +CONTRIB := 1 +SCHAUFEL ?= schaufel LIBS := -lpq -ljson-c -lconfig -lpthread OBJ := exports.o LIB := exports.so -include ../../contrib.mk +include $(shell $(SCHAUFEL) -L)/contrib.mk diff --git a/contrib/kafka/Makefile b/contrib/kafka/Makefile index 5c9a0c8..b9f9e94 100644 --- a/contrib/kafka/Makefile +++ b/contrib/kafka/Makefile @@ -1,5 +1,7 @@ +CONTRIB := 1 +SCHAUFEL ?= schaufel LIBS := -lrdkafka -lconfig -lpthread OBJ := kafka.o LIB := kafka.so -include ../../contrib.mk +include $(shell $(SCHAUFEL) -L)/contrib.mk diff --git a/contrib/postgres/Makefile b/contrib/postgres/Makefile index d70ab74..824f019 100644 --- a/contrib/postgres/Makefile +++ b/contrib/postgres/Makefile @@ -1,5 +1,7 @@ +CONTRIB := 1 +SCHAUFEL ?= schaufel LIBS := -lpq -lconfig -lpthread OBJ := postgres.o LIB := postgres.so -include ../../contrib.mk +include $(shell $(SCHAUFEL) -L)/contrib.mk diff --git a/contrib/redis/Makefile b/contrib/redis/Makefile index 2dbd93a..50eded7 100644 --- a/contrib/redis/Makefile +++ b/contrib/redis/Makefile @@ -1,5 +1,7 @@ +CONTRIB := 1 +SCHAUFEL ?= schaufel LIBS := -lhiredis -lconfig -lpthread OBJ := redis.o LIB := redis.so -include ../../contrib.mk +include $(shell $(SCHAUFEL) -L)/contrib.mk diff --git a/src/include/paths.h b/src/include/paths.h index 8f666c9..e96667c 100644 --- a/src/include/paths.h +++ b/src/include/paths.h @@ -1,4 +1,4 @@ -#define INCLUDEDIR "" +#define INCLUDEDIR "/usr/local/include/schaufel" #define LIBDIR "/usr/local/lib" #define CONTRIBDIR "/usr/local/lib/schaufel" #define DOCDIR "/usr/local/share/doc//schaufel" diff --git a/src/test/test.h b/src/include/test/test.h similarity index 100% rename from src/test/test.h rename to src/include/test/test.h diff --git a/src/main.c b/src/main.c index 2b69758..d461fe4 100644 --- a/src/main.c +++ b/src/main.c @@ -11,6 +11,7 @@ #include "build.h" #include "consumer.h" #include "modules.h" +#include "paths.h" #include "producer.h" #include "utils/config.h" #include "utils/helper.h" @@ -71,6 +72,8 @@ print_usage() " : 0 disables pipelining\n" " : Redis: 10k is upstream recommended max\n" "-l : path to the log file\n" + "-I : print include directory path\n" + "-L : print library path\n" "-V : print version\n" "\n"); exit(1); @@ -85,6 +88,20 @@ print_version() exit(0); } +NORETURN static void +print_library_path(void) +{ + printf(CONTRIBDIR "\n"); + exit(0); +} + +NORETURN static void +print_include_path(void) +{ + printf(INCLUDEDIR "\n"); + exit(0); +} + void * stats(UNUSED void *arg) { @@ -270,7 +287,7 @@ main(int argc, char **argv) config_t config; config_init(&config); - while ((opt = getopt(argc, argv, "l:i:o:c:p:b:h:g:t:f:s:B:C:H:G:T:F:S:V")) != -1) + while ((opt = getopt(argc, argv, "l:i:o:c:p:b:h:g:t:f:s:B:C:H:G:T:F:S:ILV")) != -1) { switch (opt) { @@ -321,9 +338,13 @@ main(int argc, char **argv) o.out_hosts = parse_hostinfo_master(o.out_host); o.out_hosts_replica = parse_hostinfo_replica(o.out_host); break; + case 'I': + print_include_path(); case 'G': o.out_groupid = optarg; break; + case 'L': + print_library_path(); case 'T': o.out_topic = optarg; break; From 5009664eb29ad34f67fe3b1fd92914d87c7369ec Mon Sep 17 00:00:00 2001 From: Ildar Musin Date: Thu, 23 May 2019 14:01:11 +0200 Subject: [PATCH 12/16] Add configure script to the repo; small fixes to the makefiles; remove autogenerated headers and update .gitignore --- .gitignore | 9 + Makefile.global.in | 4 +- Makefile.in | 8 +- aclocal.m4 | 68 + configure | 4070 +++++++++++++++++++++++++++++++++++++ configure.ac | 4 +- contrib.mk | 15 +- contrib/exports/Makefile | 2 +- contrib/kafka/Makefile | 2 +- contrib/postgres/Makefile | 2 +- contrib/redis/Makefile | 2 +- src/include/build.h | 32 - src/include/build.h.in | 11 +- src/include/paths.h | 5 - 14 files changed, 4168 insertions(+), 66 deletions(-) create mode 100644 aclocal.m4 create mode 100755 configure delete mode 100644 src/include/build.h delete mode 100644 src/include/paths.h diff --git a/.gitignore b/.gitignore index 9066696..541a521 100644 --- a/.gitignore +++ b/.gitignore @@ -38,3 +38,12 @@ bin/ *.swp log/ + +# Files created by configure +/config.cache +/config.log +/config.status +/Makefile +/Makefile.global +/src/include/paths.h +/src/include/build.h diff --git a/Makefile.global.in b/Makefile.global.in index e299cec..365bd5d 100644 --- a/Makefile.global.in +++ b/Makefile.global.in @@ -1,14 +1,13 @@ prefix=@prefix@ exec_prefix=@exec_prefix@ datarootdir=@datarootdir@ - bindir ?= @bindir@ includedir ?= @includedir@/@PACKAGE_NAME@ contribdir ?= @libdir@/@PACKAGE_NAME@ mandir ?= @mandir@ man1dir = $(mandir)/man1 man5dir = $(mandir)/man5 -docdir ?= @docdir@/schaufel +docdir ?= @docdir@/@PACKAGE_NAME@ CC = @CC@ LD = @CC@ @@ -16,3 +15,4 @@ INSTALL ?= install -D PTHREAD_LIB = @PTHREAD_LIB@ CFLAGS=@CFLAGS@ +LDFLAGS=@LDFLAGS@ diff --git a/Makefile.in b/Makefile.in index a95c1cb..7c21656 100644 --- a/Makefile.in +++ b/Makefile.in @@ -2,7 +2,7 @@ include Makefile.global LIBS=@LIBS@ -INC = -Isrc/include +CPPFLAGS = -Isrc/include LDFLAGS += -Wl,-E OBJDIR = obj @@ -49,10 +49,10 @@ out_release: $(OBJ) $(LD) $(LIBDIR) $(LDFLAGS) $(OBJ) $(LIBS) -o $(OUT) $(OBJDIR)/%.o: src/%.c - $(CC) $(INC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@ + $(CC) $(CPPFLAGS) $(CFLAGS) $(CPPFLAGS) -c $< -o $@ $(OBJDIR)/%.o: t/%.c - $(CC) $(INC) $(CFLAGS) -c $< -o $@ + $(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@ $(LD) $(LIBDIR) $(OBJ_TEST) $@ $(LIBS) -o bin/$(subst .o, ,$(notdir $@)) valgrind -q --leak-check=full bin/$(subst .o, ,$(notdir $@)) @@ -66,7 +66,7 @@ install: all $(INSTALL) -m 0644 man/schaufel.conf.5 $(DESTDIR)$(man5dir)/schaufel.conf.5 src/include/paths.h: - echo "#define INCLUDEDIR \"$(includedir)\"" >>$@ + echo "#define INCLUDEDIR \"$(includedir)\"" >$@ echo "#define CONTRIBDIR \"$(contribdir)\"" >>$@ echo "#define DOCDIR \"$(docdir)\"" >>$@ echo "#define MANDIR \"$(mandir)\"" >>$@ diff --git a/aclocal.m4 b/aclocal.m4 new file mode 100644 index 0000000..1bd971f --- /dev/null +++ b/aclocal.m4 @@ -0,0 +1,68 @@ +# generated automatically by aclocal 1.16.1 -*- Autoconf -*- + +# Copyright (C) 1996-2018 Free Software Foundation, Inc. + +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +m4_ifndef([AC_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])]) +# =========================================================================== +# https://www.gnu.org/software/autoconf-archive/ax_check_compile_flag.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_CHECK_COMPILE_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS], [INPUT]) +# +# DESCRIPTION +# +# Check whether the given FLAG works with the current language's compiler +# or gives an error. (Warnings, however, are ignored) +# +# ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on +# success/failure. +# +# If EXTRA-FLAGS is defined, it is added to the current language's default +# flags (e.g. CFLAGS) when the check is done. The check is thus made with +# the flags: "CFLAGS EXTRA-FLAGS FLAG". This can for example be used to +# force the compiler to issue an error when a bad flag is given. +# +# INPUT gives an alternative input source to AC_COMPILE_IFELSE. +# +# NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this +# macro in sync with AX_CHECK_{PREPROC,LINK}_FLAG. +# +# LICENSE +# +# Copyright (c) 2008 Guido U. Draheim +# Copyright (c) 2011 Maarten Bosmans +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +#serial 6 + +AC_DEFUN([AX_CHECK_COMPILE_FLAG], +[AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF +AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl +AC_CACHE_CHECK([whether _AC_LANG compiler accepts $1], CACHEVAR, [ + ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS + _AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1" + AC_COMPILE_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])], + [AS_VAR_SET(CACHEVAR,[yes])], + [AS_VAR_SET(CACHEVAR,[no])]) + _AC_LANG_PREFIX[]FLAGS=$ax_check_save_flags]) +AS_VAR_IF(CACHEVAR,yes, + [m4_default([$2], :)], + [m4_default([$3], :)]) +AS_VAR_POPDEF([CACHEVAR])dnl +])dnl AX_CHECK_COMPILE_FLAGS + diff --git a/configure b/configure new file mode 100755 index 0000000..231b2a5 --- /dev/null +++ b/configure @@ -0,0 +1,4070 @@ +#! /bin/sh +# Guess values for system-dependent variables and create Makefiles. +# Generated by GNU Autoconf 2.69 for schaufel 0.5. +# +# +# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. +# +# +# This configure script is free software; the Free Software Foundation +# gives unlimited permission to copy, distribute and modify it. +## -------------------- ## +## M4sh Initialization. ## +## -------------------- ## + +# Be more Bourne compatible +DUALCASE=1; export DUALCASE # for MKS sh +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : + emulate sh + NULLCMD=: + # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in #( + *posix*) : + set -o posix ;; #( + *) : + ;; +esac +fi + + +as_nl=' +' +export as_nl +# Printing a long string crashes Solaris 7 /usr/bin/printf. +as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo +# Prefer a ksh shell builtin over an external printf program on Solaris, +# but without wasting forks for bash or zsh. +if test -z "$BASH_VERSION$ZSH_VERSION" \ + && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='print -r --' + as_echo_n='print -rn --' +elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='printf %s\n' + as_echo_n='printf %s' +else + if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then + as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' + as_echo_n='/usr/ucb/echo -n' + else + as_echo_body='eval expr "X$1" : "X\\(.*\\)"' + as_echo_n_body='eval + arg=$1; + case $arg in #( + *"$as_nl"*) + expr "X$arg" : "X\\(.*\\)$as_nl"; + arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; + esac; + expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" + ' + export as_echo_n_body + as_echo_n='sh -c $as_echo_n_body as_echo' + fi + export as_echo_body + as_echo='sh -c $as_echo_body as_echo' +fi + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + PATH_SEPARATOR=: + (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { + (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || + PATH_SEPARATOR=';' + } +fi + + +# IFS +# We need space, tab and new line, in precisely that order. Quoting is +# there to prevent editors from complaining about space-tab. +# (If _AS_PATH_WALK were called with IFS unset, it would disable word +# splitting by setting IFS to empty value.) +IFS=" "" $as_nl" + +# Find who we are. Look in the path if we contain no directory separator. +as_myself= +case $0 in #(( + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break + done +IFS=$as_save_IFS + + ;; +esac +# We did not find ourselves, most probably we were run as `sh COMMAND' +# in which case we are not to be found in the path. +if test "x$as_myself" = x; then + as_myself=$0 +fi +if test ! -f "$as_myself"; then + $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 + exit 1 +fi + +# Unset variables that we do not need and which cause bugs (e.g. in +# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" +# suppresses any "Segmentation fault" message there. '((' could +# trigger a bug in pdksh 5.2.14. +for as_var in BASH_ENV ENV MAIL MAILPATH +do eval test x\${$as_var+set} = xset \ + && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : +done +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +LC_ALL=C +export LC_ALL +LANGUAGE=C +export LANGUAGE + +# CDPATH. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + +# Use a proper internal environment variable to ensure we don't fall + # into an infinite loop, continuously re-executing ourselves. + if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then + _as_can_reexec=no; export _as_can_reexec; + # We cannot yet assume a decent shell, so we have to provide a +# neutralization value for shells without unset; and this also +# works around shells that cannot unset nonexistent variables. +# Preserve -v and -x to the replacement shell. +BASH_ENV=/dev/null +ENV=/dev/null +(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV +case $- in # (((( + *v*x* | *x*v* ) as_opts=-vx ;; + *v* ) as_opts=-v ;; + *x* ) as_opts=-x ;; + * ) as_opts= ;; +esac +exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} +# Admittedly, this is quite paranoid, since all the known shells bail +# out after a failed `exec'. +$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 +as_fn_exit 255 + fi + # We don't want this to propagate to other subprocesses. + { _as_can_reexec=; unset _as_can_reexec;} +if test "x$CONFIG_SHELL" = x; then + as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : + emulate sh + NULLCMD=: + # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which + # is contrary to our usage. Disable this feature. + alias -g '\${1+\"\$@\"}'='\"\$@\"' + setopt NO_GLOB_SUBST +else + case \`(set -o) 2>/dev/null\` in #( + *posix*) : + set -o posix ;; #( + *) : + ;; +esac +fi +" + as_required="as_fn_return () { (exit \$1); } +as_fn_success () { as_fn_return 0; } +as_fn_failure () { as_fn_return 1; } +as_fn_ret_success () { return 0; } +as_fn_ret_failure () { return 1; } + +exitcode=0 +as_fn_success || { exitcode=1; echo as_fn_success failed.; } +as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; } +as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; } +as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; } +if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then : + +else + exitcode=1; echo positional parameters were not saved. +fi +test x\$exitcode = x0 || exit 1 +test -x / || exit 1" + as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO + as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO + eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && + test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1" + if (eval "$as_required") 2>/dev/null; then : + as_have_required=yes +else + as_have_required=no +fi + if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then : + +else + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +as_found=false +for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + as_found=: + case $as_dir in #( + /*) + for as_base in sh bash ksh sh5; do + # Try only shells that exist, to save several forks. + as_shell=$as_dir/$as_base + if { test -f "$as_shell" || test -f "$as_shell.exe"; } && + { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then : + CONFIG_SHELL=$as_shell as_have_required=yes + if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then : + break 2 +fi +fi + done;; + esac + as_found=false +done +$as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } && + { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then : + CONFIG_SHELL=$SHELL as_have_required=yes +fi; } +IFS=$as_save_IFS + + + if test "x$CONFIG_SHELL" != x; then : + export CONFIG_SHELL + # We cannot yet assume a decent shell, so we have to provide a +# neutralization value for shells without unset; and this also +# works around shells that cannot unset nonexistent variables. +# Preserve -v and -x to the replacement shell. +BASH_ENV=/dev/null +ENV=/dev/null +(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV +case $- in # (((( + *v*x* | *x*v* ) as_opts=-vx ;; + *v* ) as_opts=-v ;; + *x* ) as_opts=-x ;; + * ) as_opts= ;; +esac +exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} +# Admittedly, this is quite paranoid, since all the known shells bail +# out after a failed `exec'. +$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 +exit 255 +fi + + if test x$as_have_required = xno; then : + $as_echo "$0: This script requires a shell more modern than all" + $as_echo "$0: the shells that I found on your system." + if test x${ZSH_VERSION+set} = xset ; then + $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should" + $as_echo "$0: be upgraded to zsh 4.3.4 or later." + else + $as_echo "$0: Please tell bug-autoconf@gnu.org about your system, +$0: including any error possibly output before this +$0: message. Then install a modern shell, or manually run +$0: the script under such a shell if you do have one." + fi + exit 1 +fi +fi +fi +SHELL=${CONFIG_SHELL-/bin/sh} +export SHELL +# Unset more variables known to interfere with behavior of common tools. +CLICOLOR_FORCE= GREP_OPTIONS= +unset CLICOLOR_FORCE GREP_OPTIONS + +## --------------------- ## +## M4sh Shell Functions. ## +## --------------------- ## +# as_fn_unset VAR +# --------------- +# Portably unset VAR. +as_fn_unset () +{ + { eval $1=; unset $1;} +} +as_unset=as_fn_unset + +# as_fn_set_status STATUS +# ----------------------- +# Set $? to STATUS, without forking. +as_fn_set_status () +{ + return $1 +} # as_fn_set_status + +# as_fn_exit STATUS +# ----------------- +# Exit the shell with STATUS, even in a "trap 0" or "set -e" context. +as_fn_exit () +{ + set +e + as_fn_set_status $1 + exit $1 +} # as_fn_exit + +# as_fn_mkdir_p +# ------------- +# Create "$as_dir" as a directory, including parents if necessary. +as_fn_mkdir_p () +{ + + case $as_dir in #( + -*) as_dir=./$as_dir;; + esac + test -d "$as_dir" || eval $as_mkdir_p || { + as_dirs= + while :; do + case $as_dir in #( + *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( + *) as_qdir=$as_dir;; + esac + as_dirs="'$as_qdir' $as_dirs" + as_dir=`$as_dirname -- "$as_dir" || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + test -d "$as_dir" && break + done + test -z "$as_dirs" || eval "mkdir $as_dirs" + } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" + + +} # as_fn_mkdir_p + +# as_fn_executable_p FILE +# ----------------------- +# Test if FILE is an executable regular file. +as_fn_executable_p () +{ + test -f "$1" && test -x "$1" +} # as_fn_executable_p +# as_fn_append VAR VALUE +# ---------------------- +# Append the text in VALUE to the end of the definition contained in VAR. Take +# advantage of any shell optimizations that allow amortized linear growth over +# repeated appends, instead of the typical quadratic growth present in naive +# implementations. +if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : + eval 'as_fn_append () + { + eval $1+=\$2 + }' +else + as_fn_append () + { + eval $1=\$$1\$2 + } +fi # as_fn_append + +# as_fn_arith ARG... +# ------------------ +# Perform arithmetic evaluation on the ARGs, and store the result in the +# global $as_val. Take advantage of shells that can avoid forks. The arguments +# must be portable across $(()) and expr. +if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : + eval 'as_fn_arith () + { + as_val=$(( $* )) + }' +else + as_fn_arith () + { + as_val=`expr "$@" || test $? -eq 1` + } +fi # as_fn_arith + + +# as_fn_error STATUS ERROR [LINENO LOG_FD] +# ---------------------------------------- +# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are +# provided, also output the error to LOG_FD, referencing LINENO. Then exit the +# script with STATUS, using 1 if that was 0. +as_fn_error () +{ + as_status=$1; test $as_status -eq 0 && as_status=1 + if test "$4"; then + as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 + fi + $as_echo "$as_me: error: $2" >&2 + as_fn_exit $as_status +} # as_fn_error + +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then + as_expr=expr +else + as_expr=false +fi + +if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then + as_basename=basename +else + as_basename=false +fi + +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then + as_dirname=dirname +else + as_dirname=false +fi + +as_me=`$as_basename -- "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ + s//\1/ + q + } + /^X\/\(\/\/\)$/{ + s//\1/ + q + } + /^X\/\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + + + as_lineno_1=$LINENO as_lineno_1a=$LINENO + as_lineno_2=$LINENO as_lineno_2a=$LINENO + eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" && + test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || { + # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-) + sed -n ' + p + /[$]LINENO/= + ' <$as_myself | + sed ' + s/[$]LINENO.*/&-/ + t lineno + b + :lineno + N + :loop + s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ + t loop + s/-\n.*// + ' >$as_me.lineno && + chmod +x "$as_me.lineno" || + { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } + + # If we had to re-execute with $CONFIG_SHELL, we're ensured to have + # already done that, so ensure we don't try to do so again and fall + # in an infinite loop. This has already happened in practice. + _as_can_reexec=no; export _as_can_reexec + # Don't try to exec as it changes $[0], causing all sort of problems + # (the dirname of $[0] is not the place where we might find the + # original and so on. Autoconf is especially sensitive to this). + . "./$as_me.lineno" + # Exit status is that of the last command. + exit +} + +ECHO_C= ECHO_N= ECHO_T= +case `echo -n x` in #((((( +-n*) + case `echo 'xy\c'` in + *c*) ECHO_T=' ';; # ECHO_T is single tab character. + xy) ECHO_C='\c';; + *) echo `echo ksh88 bug on AIX 6.1` > /dev/null + ECHO_T=' ';; + esac;; +*) + ECHO_N='-n';; +esac + +rm -f conf$$ conf$$.exe conf$$.file +if test -d conf$$.dir; then + rm -f conf$$.dir/conf$$.file +else + rm -f conf$$.dir + mkdir conf$$.dir 2>/dev/null +fi +if (echo >conf$$.file) 2>/dev/null; then + if ln -s conf$$.file conf$$ 2>/dev/null; then + as_ln_s='ln -s' + # ... but there are two gotchas: + # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. + # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. + # In both cases, we have to default to `cp -pR'. + ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || + as_ln_s='cp -pR' + elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln + else + as_ln_s='cp -pR' + fi +else + as_ln_s='cp -pR' +fi +rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file +rmdir conf$$.dir 2>/dev/null + +if mkdir -p . 2>/dev/null; then + as_mkdir_p='mkdir -p "$as_dir"' +else + test -d ./-p && rmdir ./-p + as_mkdir_p=false +fi + +as_test_x='test -x' +as_executable_p=as_fn_executable_p + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" + +# Sed expression to map a string onto a valid variable name. +as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" + + +test -n "$DJDIR" || exec 7<&0 &1 + +# Name of the host. +# hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status, +# so uname gets run too. +ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` + +# +# Initializations. +# +ac_default_prefix=/usr/local +ac_clean_files= +ac_config_libobj_dir=. +LIBOBJS= +cross_compiling=no +subdirs= +MFLAGS= +MAKEFLAGS= + +# Identity of this package. +PACKAGE_NAME='schaufel' +PACKAGE_TARNAME='schaufel' +PACKAGE_VERSION='0.5' +PACKAGE_STRING='schaufel 0.5' +PACKAGE_BUGREPORT='' +PACKAGE_URL='' + +ac_unique_file="src/modules.c" +ac_subst_vars='LTLIBOBJS +LIBOBJS +PTHREAD_LIB +OBJEXT +EXEEXT +ac_ct_CC +CPPFLAGS +LDFLAGS +CFLAGS +CC +target_alias +host_alias +build_alias +LIBS +ECHO_T +ECHO_N +ECHO_C +DEFS +mandir +localedir +libdir +psdir +pdfdir +dvidir +htmldir +infodir +docdir +oldincludedir +includedir +localstatedir +sharedstatedir +sysconfdir +datadir +datarootdir +libexecdir +sbindir +bindir +program_transform_name +prefix +exec_prefix +PACKAGE_URL +PACKAGE_BUGREPORT +PACKAGE_STRING +PACKAGE_VERSION +PACKAGE_TARNAME +PACKAGE_NAME +PATH_SEPARATOR +SHELL' +ac_subst_files='' +ac_user_opts=' +enable_option_checking +' + ac_precious_vars='build_alias +host_alias +target_alias +CC +CFLAGS +LDFLAGS +LIBS +CPPFLAGS' + + +# Initialize some variables set by options. +ac_init_help= +ac_init_version=false +ac_unrecognized_opts= +ac_unrecognized_sep= +# The variables have the same names as the options, with +# dashes changed to underlines. +cache_file=/dev/null +exec_prefix=NONE +no_create= +no_recursion= +prefix=NONE +program_prefix=NONE +program_suffix=NONE +program_transform_name=s,x,x, +silent= +site= +srcdir= +verbose= +x_includes=NONE +x_libraries=NONE + +# Installation directory options. +# These are left unexpanded so users can "make install exec_prefix=/foo" +# and all the variables that are supposed to be based on exec_prefix +# by default will actually change. +# Use braces instead of parens because sh, perl, etc. also accept them. +# (The list follows the same order as the GNU Coding Standards.) +bindir='${exec_prefix}/bin' +sbindir='${exec_prefix}/sbin' +libexecdir='${exec_prefix}/libexec' +datarootdir='${prefix}/share' +datadir='${datarootdir}' +sysconfdir='${prefix}/etc' +sharedstatedir='${prefix}/com' +localstatedir='${prefix}/var' +includedir='${prefix}/include' +oldincludedir='/usr/include' +docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' +infodir='${datarootdir}/info' +htmldir='${docdir}' +dvidir='${docdir}' +pdfdir='${docdir}' +psdir='${docdir}' +libdir='${exec_prefix}/lib' +localedir='${datarootdir}/locale' +mandir='${datarootdir}/man' + +ac_prev= +ac_dashdash= +for ac_option +do + # If the previous option needs an argument, assign it. + if test -n "$ac_prev"; then + eval $ac_prev=\$ac_option + ac_prev= + continue + fi + + case $ac_option in + *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; + *=) ac_optarg= ;; + *) ac_optarg=yes ;; + esac + + # Accept the important Cygnus configure options, so we can diagnose typos. + + case $ac_dashdash$ac_option in + --) + ac_dashdash=yes ;; + + -bindir | --bindir | --bindi | --bind | --bin | --bi) + ac_prev=bindir ;; + -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) + bindir=$ac_optarg ;; + + -build | --build | --buil | --bui | --bu) + ac_prev=build_alias ;; + -build=* | --build=* | --buil=* | --bui=* | --bu=*) + build_alias=$ac_optarg ;; + + -cache-file | --cache-file | --cache-fil | --cache-fi \ + | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) + ac_prev=cache_file ;; + -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ + | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) + cache_file=$ac_optarg ;; + + --config-cache | -C) + cache_file=config.cache ;; + + -datadir | --datadir | --datadi | --datad) + ac_prev=datadir ;; + -datadir=* | --datadir=* | --datadi=* | --datad=*) + datadir=$ac_optarg ;; + + -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ + | --dataroo | --dataro | --datar) + ac_prev=datarootdir ;; + -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ + | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) + datarootdir=$ac_optarg ;; + + -disable-* | --disable-*) + ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + as_fn_error $? "invalid feature name: $ac_useropt" + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"enable_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval enable_$ac_useropt=no ;; + + -docdir | --docdir | --docdi | --doc | --do) + ac_prev=docdir ;; + -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) + docdir=$ac_optarg ;; + + -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) + ac_prev=dvidir ;; + -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) + dvidir=$ac_optarg ;; + + -enable-* | --enable-*) + ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + as_fn_error $? "invalid feature name: $ac_useropt" + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"enable_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval enable_$ac_useropt=\$ac_optarg ;; + + -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ + | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ + | --exec | --exe | --ex) + ac_prev=exec_prefix ;; + -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ + | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ + | --exec=* | --exe=* | --ex=*) + exec_prefix=$ac_optarg ;; + + -gas | --gas | --ga | --g) + # Obsolete; use --with-gas. + with_gas=yes ;; + + -help | --help | --hel | --he | -h) + ac_init_help=long ;; + -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) + ac_init_help=recursive ;; + -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) + ac_init_help=short ;; + + -host | --host | --hos | --ho) + ac_prev=host_alias ;; + -host=* | --host=* | --hos=* | --ho=*) + host_alias=$ac_optarg ;; + + -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) + ac_prev=htmldir ;; + -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ + | --ht=*) + htmldir=$ac_optarg ;; + + -includedir | --includedir | --includedi | --included | --include \ + | --includ | --inclu | --incl | --inc) + ac_prev=includedir ;; + -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ + | --includ=* | --inclu=* | --incl=* | --inc=*) + includedir=$ac_optarg ;; + + -infodir | --infodir | --infodi | --infod | --info | --inf) + ac_prev=infodir ;; + -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) + infodir=$ac_optarg ;; + + -libdir | --libdir | --libdi | --libd) + ac_prev=libdir ;; + -libdir=* | --libdir=* | --libdi=* | --libd=*) + libdir=$ac_optarg ;; + + -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ + | --libexe | --libex | --libe) + ac_prev=libexecdir ;; + -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ + | --libexe=* | --libex=* | --libe=*) + libexecdir=$ac_optarg ;; + + -localedir | --localedir | --localedi | --localed | --locale) + ac_prev=localedir ;; + -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) + localedir=$ac_optarg ;; + + -localstatedir | --localstatedir | --localstatedi | --localstated \ + | --localstate | --localstat | --localsta | --localst | --locals) + ac_prev=localstatedir ;; + -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ + | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) + localstatedir=$ac_optarg ;; + + -mandir | --mandir | --mandi | --mand | --man | --ma | --m) + ac_prev=mandir ;; + -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) + mandir=$ac_optarg ;; + + -nfp | --nfp | --nf) + # Obsolete; use --without-fp. + with_fp=no ;; + + -no-create | --no-create | --no-creat | --no-crea | --no-cre \ + | --no-cr | --no-c | -n) + no_create=yes ;; + + -no-recursion | --no-recursion | --no-recursio | --no-recursi \ + | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) + no_recursion=yes ;; + + -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ + | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ + | --oldin | --oldi | --old | --ol | --o) + ac_prev=oldincludedir ;; + -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ + | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ + | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) + oldincludedir=$ac_optarg ;; + + -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) + ac_prev=prefix ;; + -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) + prefix=$ac_optarg ;; + + -program-prefix | --program-prefix | --program-prefi | --program-pref \ + | --program-pre | --program-pr | --program-p) + ac_prev=program_prefix ;; + -program-prefix=* | --program-prefix=* | --program-prefi=* \ + | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) + program_prefix=$ac_optarg ;; + + -program-suffix | --program-suffix | --program-suffi | --program-suff \ + | --program-suf | --program-su | --program-s) + ac_prev=program_suffix ;; + -program-suffix=* | --program-suffix=* | --program-suffi=* \ + | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) + program_suffix=$ac_optarg ;; + + -program-transform-name | --program-transform-name \ + | --program-transform-nam | --program-transform-na \ + | --program-transform-n | --program-transform- \ + | --program-transform | --program-transfor \ + | --program-transfo | --program-transf \ + | --program-trans | --program-tran \ + | --progr-tra | --program-tr | --program-t) + ac_prev=program_transform_name ;; + -program-transform-name=* | --program-transform-name=* \ + | --program-transform-nam=* | --program-transform-na=* \ + | --program-transform-n=* | --program-transform-=* \ + | --program-transform=* | --program-transfor=* \ + | --program-transfo=* | --program-transf=* \ + | --program-trans=* | --program-tran=* \ + | --progr-tra=* | --program-tr=* | --program-t=*) + program_transform_name=$ac_optarg ;; + + -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) + ac_prev=pdfdir ;; + -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) + pdfdir=$ac_optarg ;; + + -psdir | --psdir | --psdi | --psd | --ps) + ac_prev=psdir ;; + -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) + psdir=$ac_optarg ;; + + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + silent=yes ;; + + -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) + ac_prev=sbindir ;; + -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ + | --sbi=* | --sb=*) + sbindir=$ac_optarg ;; + + -sharedstatedir | --sharedstatedir | --sharedstatedi \ + | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ + | --sharedst | --shareds | --shared | --share | --shar \ + | --sha | --sh) + ac_prev=sharedstatedir ;; + -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ + | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ + | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ + | --sha=* | --sh=*) + sharedstatedir=$ac_optarg ;; + + -site | --site | --sit) + ac_prev=site ;; + -site=* | --site=* | --sit=*) + site=$ac_optarg ;; + + -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) + ac_prev=srcdir ;; + -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) + srcdir=$ac_optarg ;; + + -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ + | --syscon | --sysco | --sysc | --sys | --sy) + ac_prev=sysconfdir ;; + -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ + | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) + sysconfdir=$ac_optarg ;; + + -target | --target | --targe | --targ | --tar | --ta | --t) + ac_prev=target_alias ;; + -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) + target_alias=$ac_optarg ;; + + -v | -verbose | --verbose | --verbos | --verbo | --verb) + verbose=yes ;; + + -version | --version | --versio | --versi | --vers | -V) + ac_init_version=: ;; + + -with-* | --with-*) + ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + as_fn_error $? "invalid package name: $ac_useropt" + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"with_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval with_$ac_useropt=\$ac_optarg ;; + + -without-* | --without-*) + ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + as_fn_error $? "invalid package name: $ac_useropt" + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"with_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval with_$ac_useropt=no ;; + + --x) + # Obsolete; use --with-x. + with_x=yes ;; + + -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ + | --x-incl | --x-inc | --x-in | --x-i) + ac_prev=x_includes ;; + -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ + | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) + x_includes=$ac_optarg ;; + + -x-libraries | --x-libraries | --x-librarie | --x-librari \ + | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) + ac_prev=x_libraries ;; + -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ + | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) + x_libraries=$ac_optarg ;; + + -*) as_fn_error $? "unrecognized option: \`$ac_option' +Try \`$0 --help' for more information" + ;; + + *=*) + ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` + # Reject names that are not valid shell variable names. + case $ac_envvar in #( + '' | [0-9]* | *[!_$as_cr_alnum]* ) + as_fn_error $? "invalid variable name: \`$ac_envvar'" ;; + esac + eval $ac_envvar=\$ac_optarg + export $ac_envvar ;; + + *) + # FIXME: should be removed in autoconf 3.0. + $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 + expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && + $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 + : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}" + ;; + + esac +done + +if test -n "$ac_prev"; then + ac_option=--`echo $ac_prev | sed 's/_/-/g'` + as_fn_error $? "missing argument to $ac_option" +fi + +if test -n "$ac_unrecognized_opts"; then + case $enable_option_checking in + no) ;; + fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;; + *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; + esac +fi + +# Check all directory arguments for consistency. +for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ + datadir sysconfdir sharedstatedir localstatedir includedir \ + oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ + libdir localedir mandir +do + eval ac_val=\$$ac_var + # Remove trailing slashes. + case $ac_val in + */ ) + ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'` + eval $ac_var=\$ac_val;; + esac + # Be sure to have absolute directory names. + case $ac_val in + [\\/$]* | ?:[\\/]* ) continue;; + NONE | '' ) case $ac_var in *prefix ) continue;; esac;; + esac + as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val" +done + +# There might be people who depend on the old broken behavior: `$host' +# used to hold the argument of --host etc. +# FIXME: To remove some day. +build=$build_alias +host=$host_alias +target=$target_alias + +# FIXME: To remove some day. +if test "x$host_alias" != x; then + if test "x$build_alias" = x; then + cross_compiling=maybe + elif test "x$build_alias" != "x$host_alias"; then + cross_compiling=yes + fi +fi + +ac_tool_prefix= +test -n "$host_alias" && ac_tool_prefix=$host_alias- + +test "$silent" = yes && exec 6>/dev/null + + +ac_pwd=`pwd` && test -n "$ac_pwd" && +ac_ls_di=`ls -di .` && +ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || + as_fn_error $? "working directory cannot be determined" +test "X$ac_ls_di" = "X$ac_pwd_ls_di" || + as_fn_error $? "pwd does not report name of working directory" + + +# Find the source files, if location was not specified. +if test -z "$srcdir"; then + ac_srcdir_defaulted=yes + # Try the directory containing this script, then the parent directory. + ac_confdir=`$as_dirname -- "$as_myself" || +$as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_myself" : 'X\(//\)[^/]' \| \ + X"$as_myself" : 'X\(//\)$' \| \ + X"$as_myself" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$as_myself" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + srcdir=$ac_confdir + if test ! -r "$srcdir/$ac_unique_file"; then + srcdir=.. + fi +else + ac_srcdir_defaulted=no +fi +if test ! -r "$srcdir/$ac_unique_file"; then + test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." + as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir" +fi +ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" +ac_abs_confdir=`( + cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg" + pwd)` +# When building in place, set srcdir=. +if test "$ac_abs_confdir" = "$ac_pwd"; then + srcdir=. +fi +# Remove unnecessary trailing slashes from srcdir. +# Double slashes in file names in object file debugging info +# mess up M-x gdb in Emacs. +case $srcdir in +*/) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; +esac +for ac_var in $ac_precious_vars; do + eval ac_env_${ac_var}_set=\${${ac_var}+set} + eval ac_env_${ac_var}_value=\$${ac_var} + eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} + eval ac_cv_env_${ac_var}_value=\$${ac_var} +done + +# +# Report the --help message. +# +if test "$ac_init_help" = "long"; then + # Omit some internal or obsolete options to make the list less imposing. + # This message is too long to be a string in the A/UX 3.1 sh. + cat <<_ACEOF +\`configure' configures schaufel 0.5 to adapt to many kinds of systems. + +Usage: $0 [OPTION]... [VAR=VALUE]... + +To assign environment variables (e.g., CC, CFLAGS...), specify them as +VAR=VALUE. See below for descriptions of some of the useful variables. + +Defaults for the options are specified in brackets. + +Configuration: + -h, --help display this help and exit + --help=short display options specific to this package + --help=recursive display the short help of all the included packages + -V, --version display version information and exit + -q, --quiet, --silent do not print \`checking ...' messages + --cache-file=FILE cache test results in FILE [disabled] + -C, --config-cache alias for \`--cache-file=config.cache' + -n, --no-create do not create output files + --srcdir=DIR find the sources in DIR [configure dir or \`..'] + +Installation directories: + --prefix=PREFIX install architecture-independent files in PREFIX + [$ac_default_prefix] + --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX + [PREFIX] + +By default, \`make install' will install all the files in +\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify +an installation prefix other than \`$ac_default_prefix' using \`--prefix', +for instance \`--prefix=\$HOME'. + +For better control, use the options below. + +Fine tuning of the installation directories: + --bindir=DIR user executables [EPREFIX/bin] + --sbindir=DIR system admin executables [EPREFIX/sbin] + --libexecdir=DIR program executables [EPREFIX/libexec] + --sysconfdir=DIR read-only single-machine data [PREFIX/etc] + --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] + --localstatedir=DIR modifiable single-machine data [PREFIX/var] + --libdir=DIR object code libraries [EPREFIX/lib] + --includedir=DIR C header files [PREFIX/include] + --oldincludedir=DIR C header files for non-gcc [/usr/include] + --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] + --datadir=DIR read-only architecture-independent data [DATAROOTDIR] + --infodir=DIR info documentation [DATAROOTDIR/info] + --localedir=DIR locale-dependent data [DATAROOTDIR/locale] + --mandir=DIR man documentation [DATAROOTDIR/man] + --docdir=DIR documentation root [DATAROOTDIR/doc/schaufel] + --htmldir=DIR html documentation [DOCDIR] + --dvidir=DIR dvi documentation [DOCDIR] + --pdfdir=DIR pdf documentation [DOCDIR] + --psdir=DIR ps documentation [DOCDIR] +_ACEOF + + cat <<\_ACEOF +_ACEOF +fi + +if test -n "$ac_init_help"; then + case $ac_init_help in + short | recursive ) echo "Configuration of schaufel 0.5:";; + esac + cat <<\_ACEOF + +Some influential environment variables: + CC C compiler command + CFLAGS C compiler flags + LDFLAGS linker flags, e.g. -L if you have libraries in a + nonstandard directory + LIBS libraries to pass to the linker, e.g. -l + CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if + you have headers in a nonstandard directory + +Use these variables to override the choices made by `configure' or to help +it to find libraries and programs with nonstandard names/locations. + +Report bugs to the package provider. +_ACEOF +ac_status=$? +fi + +if test "$ac_init_help" = "recursive"; then + # If there are subdirs, report their specific --help. + for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue + test -d "$ac_dir" || + { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } || + continue + ac_builddir=. + +case "$ac_dir" in +.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; +*) + ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` + # A ".." for each directory in $ac_dir_suffix. + ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` + case $ac_top_builddir_sub in + "") ac_top_builddir_sub=. ac_top_build_prefix= ;; + *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; + esac ;; +esac +ac_abs_top_builddir=$ac_pwd +ac_abs_builddir=$ac_pwd$ac_dir_suffix +# for backward compatibility: +ac_top_builddir=$ac_top_build_prefix + +case $srcdir in + .) # We are building in place. + ac_srcdir=. + ac_top_srcdir=$ac_top_builddir_sub + ac_abs_top_srcdir=$ac_pwd ;; + [\\/]* | ?:[\\/]* ) # Absolute name. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir + ac_abs_top_srcdir=$srcdir ;; + *) # Relative name. + ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_build_prefix$srcdir + ac_abs_top_srcdir=$ac_pwd/$srcdir ;; +esac +ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix + + cd "$ac_dir" || { ac_status=$?; continue; } + # Check for guested configure. + if test -f "$ac_srcdir/configure.gnu"; then + echo && + $SHELL "$ac_srcdir/configure.gnu" --help=recursive + elif test -f "$ac_srcdir/configure"; then + echo && + $SHELL "$ac_srcdir/configure" --help=recursive + else + $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 + fi || ac_status=$? + cd "$ac_pwd" || { ac_status=$?; break; } + done +fi + +test -n "$ac_init_help" && exit $ac_status +if $ac_init_version; then + cat <<\_ACEOF +schaufel configure 0.5 +generated by GNU Autoconf 2.69 + +Copyright (C) 2012 Free Software Foundation, Inc. +This configure script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it. +_ACEOF + exit +fi + +## ------------------------ ## +## Autoconf initialization. ## +## ------------------------ ## + +# ac_fn_c_try_compile LINENO +# -------------------------- +# Try to compile conftest.$ac_ext, and return whether this succeeded. +ac_fn_c_try_compile () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + rm -f conftest.$ac_objext + if { { ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compile") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_c_try_compile + +# ac_fn_c_try_link LINENO +# ----------------------- +# Try to link conftest.$ac_ext, and return whether this succeeded. +ac_fn_c_try_link () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + rm -f conftest.$ac_objext conftest$ac_exeext + if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && { + test "$cross_compiling" = yes || + test -x conftest$ac_exeext + }; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information + # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would + # interfere with the next link command; also delete a directory that is + # left behind by Apple's compiler. We do this before executing the actions. + rm -rf conftest.dSYM conftest_ipa8_conftest.oo + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_c_try_link +cat >config.log <<_ACEOF +This file contains any messages produced by compilers while +running configure, to aid debugging if configure makes a mistake. + +It was created by schaufel $as_me 0.5, which was +generated by GNU Autoconf 2.69. Invocation command line was + + $ $0 $@ + +_ACEOF +exec 5>>config.log +{ +cat <<_ASUNAME +## --------- ## +## Platform. ## +## --------- ## + +hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` +uname -m = `(uname -m) 2>/dev/null || echo unknown` +uname -r = `(uname -r) 2>/dev/null || echo unknown` +uname -s = `(uname -s) 2>/dev/null || echo unknown` +uname -v = `(uname -v) 2>/dev/null || echo unknown` + +/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` +/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` + +/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` +/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` +/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` +/usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` +/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` +/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` +/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` + +_ASUNAME + +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + $as_echo "PATH: $as_dir" + done +IFS=$as_save_IFS + +} >&5 + +cat >&5 <<_ACEOF + + +## ----------- ## +## Core tests. ## +## ----------- ## + +_ACEOF + + +# Keep a trace of the command line. +# Strip out --no-create and --no-recursion so they do not pile up. +# Strip out --silent because we don't want to record it for future runs. +# Also quote any args containing shell meta-characters. +# Make two passes to allow for proper duplicate-argument suppression. +ac_configure_args= +ac_configure_args0= +ac_configure_args1= +ac_must_keep_next=false +for ac_pass in 1 2 +do + for ac_arg + do + case $ac_arg in + -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + continue ;; + *\'*) + ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; + esac + case $ac_pass in + 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;; + 2) + as_fn_append ac_configure_args1 " '$ac_arg'" + if test $ac_must_keep_next = true; then + ac_must_keep_next=false # Got value, back to normal. + else + case $ac_arg in + *=* | --config-cache | -C | -disable-* | --disable-* \ + | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ + | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ + | -with-* | --with-* | -without-* | --without-* | --x) + case "$ac_configure_args0 " in + "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; + esac + ;; + -* ) ac_must_keep_next=true ;; + esac + fi + as_fn_append ac_configure_args " '$ac_arg'" + ;; + esac + done +done +{ ac_configure_args0=; unset ac_configure_args0;} +{ ac_configure_args1=; unset ac_configure_args1;} + +# When interrupted or exit'd, cleanup temporary files, and complete +# config.log. We remove comments because anyway the quotes in there +# would cause problems or look ugly. +# WARNING: Use '\'' to represent an apostrophe within the trap. +# WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. +trap 'exit_status=$? + # Save into config.log some information that might help in debugging. + { + echo + + $as_echo "## ---------------- ## +## Cache variables. ## +## ---------------- ##" + echo + # The following way of writing the cache mishandles newlines in values, +( + for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do + eval ac_val=\$$ac_var + case $ac_val in #( + *${as_nl}*) + case $ac_var in #( + *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 +$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; + esac + case $ac_var in #( + _ | IFS | as_nl) ;; #( + BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( + *) { eval $ac_var=; unset $ac_var;} ;; + esac ;; + esac + done + (set) 2>&1 | + case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( + *${as_nl}ac_space=\ *) + sed -n \ + "s/'\''/'\''\\\\'\'''\''/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" + ;; #( + *) + sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" + ;; + esac | + sort +) + echo + + $as_echo "## ----------------- ## +## Output variables. ## +## ----------------- ##" + echo + for ac_var in $ac_subst_vars + do + eval ac_val=\$$ac_var + case $ac_val in + *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; + esac + $as_echo "$ac_var='\''$ac_val'\''" + done | sort + echo + + if test -n "$ac_subst_files"; then + $as_echo "## ------------------- ## +## File substitutions. ## +## ------------------- ##" + echo + for ac_var in $ac_subst_files + do + eval ac_val=\$$ac_var + case $ac_val in + *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; + esac + $as_echo "$ac_var='\''$ac_val'\''" + done | sort + echo + fi + + if test -s confdefs.h; then + $as_echo "## ----------- ## +## confdefs.h. ## +## ----------- ##" + echo + cat confdefs.h + echo + fi + test "$ac_signal" != 0 && + $as_echo "$as_me: caught signal $ac_signal" + $as_echo "$as_me: exit $exit_status" + } >&5 + rm -f core *.core core.conftest.* && + rm -f -r conftest* confdefs* conf$$* $ac_clean_files && + exit $exit_status +' 0 +for ac_signal in 1 2 13 15; do + trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal +done +ac_signal=0 + +# confdefs.h avoids OS command line length limits that DEFS can exceed. +rm -f -r conftest* confdefs.h + +$as_echo "/* confdefs.h */" > confdefs.h + +# Predefined preprocessor variables. + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_NAME "$PACKAGE_NAME" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_TARNAME "$PACKAGE_TARNAME" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_VERSION "$PACKAGE_VERSION" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_STRING "$PACKAGE_STRING" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_URL "$PACKAGE_URL" +_ACEOF + + +# Let the site file select an alternate cache file if it wants to. +# Prefer an explicitly selected file to automatically selected ones. +ac_site_file1=NONE +ac_site_file2=NONE +if test -n "$CONFIG_SITE"; then + # We do not want a PATH search for config.site. + case $CONFIG_SITE in #(( + -*) ac_site_file1=./$CONFIG_SITE;; + */*) ac_site_file1=$CONFIG_SITE;; + *) ac_site_file1=./$CONFIG_SITE;; + esac +elif test "x$prefix" != xNONE; then + ac_site_file1=$prefix/share/config.site + ac_site_file2=$prefix/etc/config.site +else + ac_site_file1=$ac_default_prefix/share/config.site + ac_site_file2=$ac_default_prefix/etc/config.site +fi +for ac_site_file in "$ac_site_file1" "$ac_site_file2" +do + test "x$ac_site_file" = xNONE && continue + if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 +$as_echo "$as_me: loading site script $ac_site_file" >&6;} + sed 's/^/| /' "$ac_site_file" >&5 + . "$ac_site_file" \ + || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "failed to load site script $ac_site_file +See \`config.log' for more details" "$LINENO" 5; } + fi +done + +if test -r "$cache_file"; then + # Some versions of bash will fail to source /dev/null (special files + # actually), so we avoid doing that. DJGPP emulates it as a regular file. + if test /dev/null != "$cache_file" && test -f "$cache_file"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 +$as_echo "$as_me: loading cache $cache_file" >&6;} + case $cache_file in + [\\/]* | ?:[\\/]* ) . "$cache_file";; + *) . "./$cache_file";; + esac + fi +else + { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5 +$as_echo "$as_me: creating cache $cache_file" >&6;} + >$cache_file +fi + +# Check that the precious variables saved in the cache have kept the same +# value. +ac_cache_corrupted=false +for ac_var in $ac_precious_vars; do + eval ac_old_set=\$ac_cv_env_${ac_var}_set + eval ac_new_set=\$ac_env_${ac_var}_set + eval ac_old_val=\$ac_cv_env_${ac_var}_value + eval ac_new_val=\$ac_env_${ac_var}_value + case $ac_old_set,$ac_new_set in + set,) + { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 +$as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} + ac_cache_corrupted=: ;; + ,set) + { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5 +$as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} + ac_cache_corrupted=: ;; + ,);; + *) + if test "x$ac_old_val" != "x$ac_new_val"; then + # differences in whitespace do not lead to failure. + ac_old_val_w=`echo x $ac_old_val` + ac_new_val_w=`echo x $ac_new_val` + if test "$ac_old_val_w" != "$ac_new_val_w"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5 +$as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} + ac_cache_corrupted=: + else + { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 +$as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} + eval $ac_var=\$ac_old_val + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 +$as_echo "$as_me: former value: \`$ac_old_val'" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5 +$as_echo "$as_me: current value: \`$ac_new_val'" >&2;} + fi;; + esac + # Pass precious variables to config.status. + if test "$ac_new_set" = set; then + case $ac_new_val in + *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; + *) ac_arg=$ac_var=$ac_new_val ;; + esac + case " $ac_configure_args " in + *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. + *) as_fn_append ac_configure_args " '$ac_arg'" ;; + esac + fi +done +if $ac_cache_corrupted; then + { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 +$as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} + as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 +fi +## -------------------- ## +## Main body of script. ## +## -------------------- ## + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + + +#AC_CONFIG_AUX_DIR([build-aux]) + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. +set dummy ${ac_tool_prefix}gcc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="${ac_tool_prefix}gcc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_CC"; then + ac_ct_CC=$CC + # Extract the first word of "gcc", so it can be a program name with args. +set dummy gcc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CC="gcc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 +$as_echo "$ac_ct_CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_CC" = x; then + CC="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + CC=$ac_ct_CC + fi +else + CC="$ac_cv_prog_CC" +fi + +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. +set dummy ${ac_tool_prefix}cc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="${ac_tool_prefix}cc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + fi +fi +if test -z "$CC"; then + # Extract the first word of "cc", so it can be a program name with args. +set dummy cc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + ac_prog_rejected=no +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then + ac_prog_rejected=yes + continue + fi + ac_cv_prog_CC="cc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +if test $ac_prog_rejected = yes; then + # We found a bogon in the path, so make sure we never use it. + set dummy $ac_cv_prog_CC + shift + if test $# != 0; then + # We chose a different compiler from the bogus one. + # However, it has the same basename, so the bogon will be chosen + # first if we set CC to just the basename; use the full file name. + shift + ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" + fi +fi +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + for ac_prog in cl.exe + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. +set dummy $ac_tool_prefix$ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="$ac_tool_prefix$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$CC" && break + done +fi +if test -z "$CC"; then + ac_ct_CC=$CC + for ac_prog in cl.exe +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CC="$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 +$as_echo "$ac_ct_CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$ac_ct_CC" && break +done + + if test "x$ac_ct_CC" = x; then + CC="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + CC=$ac_ct_CC + fi +fi + +fi + + +test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "no acceptable C compiler found in \$PATH +See \`config.log' for more details" "$LINENO" 5; } + +# Provide some information about the compiler. +$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 +set X $ac_compile +ac_compiler=$2 +for ac_option in --version -v -V -qversion; do + { { ac_try="$ac_compiler $ac_option >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compiler $ac_option >&5") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + sed '10a\ +... rest of stderr output deleted ... + 10q' conftest.err >conftest.er1 + cat conftest.er1 >&5 + fi + rm -f conftest.er1 conftest.err + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } +done + +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" +# Try to create an executable without -o first, disregard a.out. +# It will help us diagnose broken compilers, and finding out an intuition +# of exeext. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5 +$as_echo_n "checking whether the C compiler works... " >&6; } +ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` + +# The possible output files: +ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" + +ac_rmfiles= +for ac_file in $ac_files +do + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; + * ) ac_rmfiles="$ac_rmfiles $ac_file";; + esac +done +rm -f $ac_rmfiles + +if { { ac_try="$ac_link_default" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link_default") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then : + # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. +# So ignore a value of `no', otherwise this would lead to `EXEEXT = no' +# in a Makefile. We should not override ac_cv_exeext if it was cached, +# so that the user can short-circuit this test for compilers unknown to +# Autoconf. +for ac_file in $ac_files '' +do + test -f "$ac_file" || continue + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) + ;; + [ab].out ) + # We found the default executable, but exeext='' is most + # certainly right. + break;; + *.* ) + if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; + then :; else + ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + fi + # We set ac_cv_exeext here because the later test for it is not + # safe: cross compilers may not add the suffix if given an `-o' + # argument, so we may need to know it at that point already. + # Even if this section looks crufty: it has the advantage of + # actually working. + break;; + * ) + break;; + esac +done +test "$ac_cv_exeext" = no && ac_cv_exeext= + +else + ac_file='' +fi +if test -z "$ac_file"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +$as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error 77 "C compiler cannot create executables +See \`config.log' for more details" "$LINENO" 5; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5 +$as_echo_n "checking for C compiler default output file name... " >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 +$as_echo "$ac_file" >&6; } +ac_exeext=$ac_cv_exeext + +rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out +ac_clean_files=$ac_clean_files_save +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 +$as_echo_n "checking for suffix of executables... " >&6; } +if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then : + # If both `conftest.exe' and `conftest' are `present' (well, observable) +# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will +# work properly (i.e., refer to `conftest.exe'), while it won't with +# `rm'. +for ac_file in conftest.exe conftest conftest.*; do + test -f "$ac_file" || continue + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; + *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + break;; + * ) break;; + esac +done +else + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "cannot compute suffix of executables: cannot compile and link +See \`config.log' for more details" "$LINENO" 5; } +fi +rm -f conftest conftest$ac_cv_exeext +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 +$as_echo "$ac_cv_exeext" >&6; } + +rm -f conftest.$ac_ext +EXEEXT=$ac_cv_exeext +ac_exeext=$EXEEXT +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main () +{ +FILE *f = fopen ("conftest.out", "w"); + return ferror (f) || fclose (f) != 0; + + ; + return 0; +} +_ACEOF +ac_clean_files="$ac_clean_files conftest.out" +# Check that the compiler produces executables we can run. If not, either +# the compiler is broken, or we cross compile. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 +$as_echo_n "checking whether we are cross compiling... " >&6; } +if test "$cross_compiling" != yes; then + { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } + if { ac_try='./conftest$ac_cv_exeext' + { { case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; }; then + cross_compiling=no + else + if test "$cross_compiling" = maybe; then + cross_compiling=yes + else + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "cannot run C compiled programs. +If you meant to cross compile, use \`--host'. +See \`config.log' for more details" "$LINENO" 5; } + fi + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 +$as_echo "$cross_compiling" >&6; } + +rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out +ac_clean_files=$ac_clean_files_save +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 +$as_echo_n "checking for suffix of object files... " >&6; } +if ${ac_cv_objext+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.o conftest.obj +if { { ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compile") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then : + for ac_file in conftest.o conftest.obj conftest.*; do + test -f "$ac_file" || continue; + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;; + *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` + break;; + esac +done +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "cannot compute suffix of object files: cannot compile +See \`config.log' for more details" "$LINENO" 5; } +fi +rm -f conftest.$ac_cv_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 +$as_echo "$ac_cv_objext" >&6; } +OBJEXT=$ac_cv_objext +ac_objext=$OBJEXT +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 +$as_echo_n "checking whether we are using the GNU C compiler... " >&6; } +if ${ac_cv_c_compiler_gnu+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ +#ifndef __GNUC__ + choke me +#endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_compiler_gnu=yes +else + ac_compiler_gnu=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +ac_cv_c_compiler_gnu=$ac_compiler_gnu + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 +$as_echo "$ac_cv_c_compiler_gnu" >&6; } +if test $ac_compiler_gnu = yes; then + GCC=yes +else + GCC= +fi +ac_test_CFLAGS=${CFLAGS+set} +ac_save_CFLAGS=$CFLAGS +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 +$as_echo_n "checking whether $CC accepts -g... " >&6; } +if ${ac_cv_prog_cc_g+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_save_c_werror_flag=$ac_c_werror_flag + ac_c_werror_flag=yes + ac_cv_prog_cc_g=no + CFLAGS="-g" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_prog_cc_g=yes +else + CFLAGS="" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + +else + ac_c_werror_flag=$ac_save_c_werror_flag + CFLAGS="-g" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_prog_cc_g=yes +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_c_werror_flag=$ac_save_c_werror_flag +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 +$as_echo "$ac_cv_prog_cc_g" >&6; } +if test "$ac_test_CFLAGS" = set; then + CFLAGS=$ac_save_CFLAGS +elif test $ac_cv_prog_cc_g = yes; then + if test "$GCC" = yes; then + CFLAGS="-g -O2" + else + CFLAGS="-g" + fi +else + if test "$GCC" = yes; then + CFLAGS="-O2" + else + CFLAGS= + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 +$as_echo_n "checking for $CC option to accept ISO C89... " >&6; } +if ${ac_cv_prog_cc_c89+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_cv_prog_cc_c89=no +ac_save_CC=$CC +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +struct stat; +/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ +struct buf { int x; }; +FILE * (*rcsopen) (struct buf *, struct stat *, int); +static char *e (p, i) + char **p; + int i; +{ + return p[i]; +} +static char *f (char * (*g) (char **, int), char **p, ...) +{ + char *s; + va_list v; + va_start (v,p); + s = g (p, va_arg (v,int)); + va_end (v); + return s; +} + +/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has + function prototypes and stuff, but not '\xHH' hex character constants. + These don't provoke an error unfortunately, instead are silently treated + as 'x'. The following induces an error, until -std is added to get + proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an + array size at least. It's necessary to write '\x00'==0 to get something + that's true only with -std. */ +int osf4_cc_array ['\x00' == 0 ? 1 : -1]; + +/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters + inside strings and character constants. */ +#define FOO(x) 'x' +int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; + +int test (int i, double x); +struct s1 {int (*f) (int a);}; +struct s2 {int (*f) (double a);}; +int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); +int argc; +char **argv; +int +main () +{ +return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; + ; + return 0; +} +_ACEOF +for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ + -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" +do + CC="$ac_save_CC $ac_arg" + if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_prog_cc_c89=$ac_arg +fi +rm -f core conftest.err conftest.$ac_objext + test "x$ac_cv_prog_cc_c89" != "xno" && break +done +rm -f conftest.$ac_ext +CC=$ac_save_CC + +fi +# AC_CACHE_VAL +case "x$ac_cv_prog_cc_c89" in + x) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 +$as_echo "none needed" >&6; } ;; + xno) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 +$as_echo "unsupported" >&6; } ;; + *) + CC="$CC $ac_cv_prog_cc_c89" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 +$as_echo "$ac_cv_prog_cc_c89" >&6; } ;; +esac +if test "x$ac_cv_prog_cc_c89" != xno; then : + +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts -std=c11" >&5 +$as_echo_n "checking whether C compiler accepts -std=c11... " >&6; } +if ${ax_cv_check_cflags___std_c11+:} false; then : + $as_echo_n "(cached) " >&6 +else + + ax_check_save_flags=$CFLAGS + CFLAGS="$CFLAGS -std=c11" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv_check_cflags___std_c11=yes +else + ax_cv_check_cflags___std_c11=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + CFLAGS=$ax_check_save_flags +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_check_cflags___std_c11" >&5 +$as_echo "$ax_cv_check_cflags___std_c11" >&6; } +if test "x$ax_cv_check_cflags___std_c11" = xyes; then : + + CFLAGS+=" -std=c11" + +else + + as_fn_error $? "C compiler cannot compile C11 code" "$LINENO" 5 + +fi + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing dlopen" >&5 +$as_echo_n "checking for library containing dlopen... " >&6; } +if ${ac_cv_search_dlopen+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_func_search_save_LIBS=$LIBS +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char dlopen (); +int +main () +{ +return dlopen (); + ; + return 0; +} +_ACEOF +for ac_lib in '' dl dld; do + if test -z "$ac_lib"; then + ac_res="none required" + else + ac_res=-l$ac_lib + LIBS="-l$ac_lib $ac_func_search_save_LIBS" + fi + if ac_fn_c_try_link "$LINENO"; then : + ac_cv_search_dlopen=$ac_res +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext + if ${ac_cv_search_dlopen+:} false; then : + break +fi +done +if ${ac_cv_search_dlopen+:} false; then : + +else + ac_cv_search_dlopen=no +fi +rm conftest.$ac_ext +LIBS=$ac_func_search_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_dlopen" >&5 +$as_echo "$ac_cv_search_dlopen" >&6; } +ac_res=$ac_cv_search_dlopen +if test "$ac_res" != no; then : + test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" + +else + + as_fn_error $? "unable to find the dlopen() function" "$LINENO" 5 + +fi + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for config_init in -lconfig" >&5 +$as_echo_n "checking for config_init in -lconfig... " >&6; } +if ${ac_cv_lib_config_config_init+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lconfig $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char config_init (); +int +main () +{ +return config_init (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_config_config_init=yes +else + ac_cv_lib_config_config_init=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_config_config_init" >&5 +$as_echo "$ac_cv_lib_config_config_init" >&6; } +if test "x$ac_cv_lib_config_config_init" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBCONFIG 1 +_ACEOF + + LIBS="-lconfig $LIBS" + +else + + as_fn_error $? "unable to find the config_init() function" "$LINENO" 5 + +fi + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing pthread_create" >&5 +$as_echo_n "checking for library containing pthread_create... " >&6; } +if ${ac_cv_search_pthread_create+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_func_search_save_LIBS=$LIBS +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char pthread_create (); +int +main () +{ +return pthread_create (); + ; + return 0; +} +_ACEOF +for ac_lib in '' pthread; do + if test -z "$ac_lib"; then + ac_res="none required" + else + ac_res=-l$ac_lib + LIBS="-l$ac_lib $ac_func_search_save_LIBS" + fi + if ac_fn_c_try_link "$LINENO"; then : + ac_cv_search_pthread_create=$ac_res +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext + if ${ac_cv_search_pthread_create+:} false; then : + break +fi +done +if ${ac_cv_search_pthread_create+:} false; then : + +else + ac_cv_search_pthread_create=no +fi +rm conftest.$ac_ext +LIBS=$ac_func_search_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_pthread_create" >&5 +$as_echo "$ac_cv_search_pthread_create" >&6; } +ac_res=$ac_cv_search_pthread_create +if test "$ac_res" != no; then : + test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" + + PTHREAD_LIB=$ac_cv_search_pthread_create + + +else + + as_fn_error $? "unable to find the pthread_create() function" "$LINENO" 5 + +fi + + +CFLAGS+=" -Wall -Wextra -pedantic" +CFLAGS+=" -D_POSIX_C_SOURCE=200809L" +CFLAGS+=" -D_BSD_SOURCE" + +ac_config_headers="$ac_config_headers src/include/build.h" + + +ac_config_files="$ac_config_files Makefile Makefile.global" + +cat >confcache <<\_ACEOF +# This file is a shell script that caches the results of configure +# tests run on this system so they can be shared between configure +# scripts and configure runs, see configure's option --config-cache. +# It is not useful on other systems. If it contains results you don't +# want to keep, you may remove or edit it. +# +# config.status only pays attention to the cache file if you give it +# the --recheck option to rerun configure. +# +# `ac_cv_env_foo' variables (set or unset) will be overridden when +# loading this file, other *unset* `ac_cv_foo' will be assigned the +# following values. + +_ACEOF + +# The following way of writing the cache mishandles newlines in values, +# but we know of no workaround that is simple, portable, and efficient. +# So, we kill variables containing newlines. +# Ultrix sh set writes to stderr and can't be redirected directly, +# and sets the high bit in the cache file unless we assign to the vars. +( + for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do + eval ac_val=\$$ac_var + case $ac_val in #( + *${as_nl}*) + case $ac_var in #( + *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 +$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; + esac + case $ac_var in #( + _ | IFS | as_nl) ;; #( + BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( + *) { eval $ac_var=; unset $ac_var;} ;; + esac ;; + esac + done + + (set) 2>&1 | + case $as_nl`(ac_space=' '; set) 2>&1` in #( + *${as_nl}ac_space=\ *) + # `set' does not quote correctly, so add quotes: double-quote + # substitution turns \\\\ into \\, and sed turns \\ into \. + sed -n \ + "s/'/'\\\\''/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" + ;; #( + *) + # `set' quotes correctly as required by POSIX, so do not add quotes. + sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" + ;; + esac | + sort +) | + sed ' + /^ac_cv_env_/b end + t clear + :clear + s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ + t end + s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ + :end' >>confcache +if diff "$cache_file" confcache >/dev/null 2>&1; then :; else + if test -w "$cache_file"; then + if test "x$cache_file" != "x/dev/null"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 +$as_echo "$as_me: updating cache $cache_file" >&6;} + if test ! -f "$cache_file" || test -h "$cache_file"; then + cat confcache >"$cache_file" + else + case $cache_file in #( + */* | ?:*) + mv -f confcache "$cache_file"$$ && + mv -f "$cache_file"$$ "$cache_file" ;; #( + *) + mv -f confcache "$cache_file" ;; + esac + fi + fi + else + { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 +$as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} + fi +fi +rm -f confcache + +test "x$prefix" = xNONE && prefix=$ac_default_prefix +# Let make expand exec_prefix. +test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' + +DEFS=-DHAVE_CONFIG_H + +ac_libobjs= +ac_ltlibobjs= +U= +for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue + # 1. Remove the extension, and $U if already installed. + ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' + ac_i=`$as_echo "$ac_i" | sed "$ac_script"` + # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR + # will be set to the directory where LIBOBJS objects are built. + as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" + as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo' +done +LIBOBJS=$ac_libobjs + +LTLIBOBJS=$ac_ltlibobjs + + + +: "${CONFIG_STATUS=./config.status}" +ac_write_fail=0 +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files $CONFIG_STATUS" +{ $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 +$as_echo "$as_me: creating $CONFIG_STATUS" >&6;} +as_write_fail=0 +cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 +#! $SHELL +# Generated by $as_me. +# Run this file to recreate the current configuration. +# Compiler output produced by configure, useful for debugging +# configure, is in config.log if it exists. + +debug=false +ac_cs_recheck=false +ac_cs_silent=false + +SHELL=\${CONFIG_SHELL-$SHELL} +export SHELL +_ASEOF +cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 +## -------------------- ## +## M4sh Initialization. ## +## -------------------- ## + +# Be more Bourne compatible +DUALCASE=1; export DUALCASE # for MKS sh +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : + emulate sh + NULLCMD=: + # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in #( + *posix*) : + set -o posix ;; #( + *) : + ;; +esac +fi + + +as_nl=' +' +export as_nl +# Printing a long string crashes Solaris 7 /usr/bin/printf. +as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo +# Prefer a ksh shell builtin over an external printf program on Solaris, +# but without wasting forks for bash or zsh. +if test -z "$BASH_VERSION$ZSH_VERSION" \ + && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='print -r --' + as_echo_n='print -rn --' +elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='printf %s\n' + as_echo_n='printf %s' +else + if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then + as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' + as_echo_n='/usr/ucb/echo -n' + else + as_echo_body='eval expr "X$1" : "X\\(.*\\)"' + as_echo_n_body='eval + arg=$1; + case $arg in #( + *"$as_nl"*) + expr "X$arg" : "X\\(.*\\)$as_nl"; + arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; + esac; + expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" + ' + export as_echo_n_body + as_echo_n='sh -c $as_echo_n_body as_echo' + fi + export as_echo_body + as_echo='sh -c $as_echo_body as_echo' +fi + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + PATH_SEPARATOR=: + (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { + (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || + PATH_SEPARATOR=';' + } +fi + + +# IFS +# We need space, tab and new line, in precisely that order. Quoting is +# there to prevent editors from complaining about space-tab. +# (If _AS_PATH_WALK were called with IFS unset, it would disable word +# splitting by setting IFS to empty value.) +IFS=" "" $as_nl" + +# Find who we are. Look in the path if we contain no directory separator. +as_myself= +case $0 in #(( + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break + done +IFS=$as_save_IFS + + ;; +esac +# We did not find ourselves, most probably we were run as `sh COMMAND' +# in which case we are not to be found in the path. +if test "x$as_myself" = x; then + as_myself=$0 +fi +if test ! -f "$as_myself"; then + $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 + exit 1 +fi + +# Unset variables that we do not need and which cause bugs (e.g. in +# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" +# suppresses any "Segmentation fault" message there. '((' could +# trigger a bug in pdksh 5.2.14. +for as_var in BASH_ENV ENV MAIL MAILPATH +do eval test x\${$as_var+set} = xset \ + && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : +done +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +LC_ALL=C +export LC_ALL +LANGUAGE=C +export LANGUAGE + +# CDPATH. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + + +# as_fn_error STATUS ERROR [LINENO LOG_FD] +# ---------------------------------------- +# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are +# provided, also output the error to LOG_FD, referencing LINENO. Then exit the +# script with STATUS, using 1 if that was 0. +as_fn_error () +{ + as_status=$1; test $as_status -eq 0 && as_status=1 + if test "$4"; then + as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 + fi + $as_echo "$as_me: error: $2" >&2 + as_fn_exit $as_status +} # as_fn_error + + +# as_fn_set_status STATUS +# ----------------------- +# Set $? to STATUS, without forking. +as_fn_set_status () +{ + return $1 +} # as_fn_set_status + +# as_fn_exit STATUS +# ----------------- +# Exit the shell with STATUS, even in a "trap 0" or "set -e" context. +as_fn_exit () +{ + set +e + as_fn_set_status $1 + exit $1 +} # as_fn_exit + +# as_fn_unset VAR +# --------------- +# Portably unset VAR. +as_fn_unset () +{ + { eval $1=; unset $1;} +} +as_unset=as_fn_unset +# as_fn_append VAR VALUE +# ---------------------- +# Append the text in VALUE to the end of the definition contained in VAR. Take +# advantage of any shell optimizations that allow amortized linear growth over +# repeated appends, instead of the typical quadratic growth present in naive +# implementations. +if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : + eval 'as_fn_append () + { + eval $1+=\$2 + }' +else + as_fn_append () + { + eval $1=\$$1\$2 + } +fi # as_fn_append + +# as_fn_arith ARG... +# ------------------ +# Perform arithmetic evaluation on the ARGs, and store the result in the +# global $as_val. Take advantage of shells that can avoid forks. The arguments +# must be portable across $(()) and expr. +if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : + eval 'as_fn_arith () + { + as_val=$(( $* )) + }' +else + as_fn_arith () + { + as_val=`expr "$@" || test $? -eq 1` + } +fi # as_fn_arith + + +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then + as_expr=expr +else + as_expr=false +fi + +if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then + as_basename=basename +else + as_basename=false +fi + +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then + as_dirname=dirname +else + as_dirname=false +fi + +as_me=`$as_basename -- "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ + s//\1/ + q + } + /^X\/\(\/\/\)$/{ + s//\1/ + q + } + /^X\/\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + +ECHO_C= ECHO_N= ECHO_T= +case `echo -n x` in #((((( +-n*) + case `echo 'xy\c'` in + *c*) ECHO_T=' ';; # ECHO_T is single tab character. + xy) ECHO_C='\c';; + *) echo `echo ksh88 bug on AIX 6.1` > /dev/null + ECHO_T=' ';; + esac;; +*) + ECHO_N='-n';; +esac + +rm -f conf$$ conf$$.exe conf$$.file +if test -d conf$$.dir; then + rm -f conf$$.dir/conf$$.file +else + rm -f conf$$.dir + mkdir conf$$.dir 2>/dev/null +fi +if (echo >conf$$.file) 2>/dev/null; then + if ln -s conf$$.file conf$$ 2>/dev/null; then + as_ln_s='ln -s' + # ... but there are two gotchas: + # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. + # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. + # In both cases, we have to default to `cp -pR'. + ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || + as_ln_s='cp -pR' + elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln + else + as_ln_s='cp -pR' + fi +else + as_ln_s='cp -pR' +fi +rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file +rmdir conf$$.dir 2>/dev/null + + +# as_fn_mkdir_p +# ------------- +# Create "$as_dir" as a directory, including parents if necessary. +as_fn_mkdir_p () +{ + + case $as_dir in #( + -*) as_dir=./$as_dir;; + esac + test -d "$as_dir" || eval $as_mkdir_p || { + as_dirs= + while :; do + case $as_dir in #( + *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( + *) as_qdir=$as_dir;; + esac + as_dirs="'$as_qdir' $as_dirs" + as_dir=`$as_dirname -- "$as_dir" || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + test -d "$as_dir" && break + done + test -z "$as_dirs" || eval "mkdir $as_dirs" + } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" + + +} # as_fn_mkdir_p +if mkdir -p . 2>/dev/null; then + as_mkdir_p='mkdir -p "$as_dir"' +else + test -d ./-p && rmdir ./-p + as_mkdir_p=false +fi + + +# as_fn_executable_p FILE +# ----------------------- +# Test if FILE is an executable regular file. +as_fn_executable_p () +{ + test -f "$1" && test -x "$1" +} # as_fn_executable_p +as_test_x='test -x' +as_executable_p=as_fn_executable_p + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" + +# Sed expression to map a string onto a valid variable name. +as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" + + +exec 6>&1 +## ----------------------------------- ## +## Main body of $CONFIG_STATUS script. ## +## ----------------------------------- ## +_ASEOF +test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +# Save the log message, to keep $0 and so on meaningful, and to +# report actual input values of CONFIG_FILES etc. instead of their +# values after options handling. +ac_log=" +This file was extended by schaufel $as_me 0.5, which was +generated by GNU Autoconf 2.69. Invocation command line was + + CONFIG_FILES = $CONFIG_FILES + CONFIG_HEADERS = $CONFIG_HEADERS + CONFIG_LINKS = $CONFIG_LINKS + CONFIG_COMMANDS = $CONFIG_COMMANDS + $ $0 $@ + +on `(hostname || uname -n) 2>/dev/null | sed 1q` +" + +_ACEOF + +case $ac_config_files in *" +"*) set x $ac_config_files; shift; ac_config_files=$*;; +esac + +case $ac_config_headers in *" +"*) set x $ac_config_headers; shift; ac_config_headers=$*;; +esac + + +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +# Files that config.status was made for. +config_files="$ac_config_files" +config_headers="$ac_config_headers" + +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +ac_cs_usage="\ +\`$as_me' instantiates files and other configuration actions +from templates according to the current configuration. Unless the files +and actions are specified as TAGs, all are instantiated by default. + +Usage: $0 [OPTION]... [TAG]... + + -h, --help print this help, then exit + -V, --version print version number and configuration settings, then exit + --config print configuration, then exit + -q, --quiet, --silent + do not print progress messages + -d, --debug don't remove temporary files + --recheck update $as_me by reconfiguring in the same conditions + --file=FILE[:TEMPLATE] + instantiate the configuration file FILE + --header=FILE[:TEMPLATE] + instantiate the configuration header FILE + +Configuration files: +$config_files + +Configuration headers: +$config_headers + +Report bugs to the package provider." + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" +ac_cs_version="\\ +schaufel config.status 0.5 +configured by $0, generated by GNU Autoconf 2.69, + with options \\"\$ac_cs_config\\" + +Copyright (C) 2012 Free Software Foundation, Inc. +This config.status script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it." + +ac_pwd='$ac_pwd' +srcdir='$srcdir' +test -n "\$AWK" || AWK=awk +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +# The default lists apply if the user does not specify any file. +ac_need_defaults=: +while test $# != 0 +do + case $1 in + --*=?*) + ac_option=`expr "X$1" : 'X\([^=]*\)='` + ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` + ac_shift=: + ;; + --*=) + ac_option=`expr "X$1" : 'X\([^=]*\)='` + ac_optarg= + ac_shift=: + ;; + *) + ac_option=$1 + ac_optarg=$2 + ac_shift=shift + ;; + esac + + case $ac_option in + # Handling of the options. + -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) + ac_cs_recheck=: ;; + --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) + $as_echo "$ac_cs_version"; exit ;; + --config | --confi | --conf | --con | --co | --c ) + $as_echo "$ac_cs_config"; exit ;; + --debug | --debu | --deb | --de | --d | -d ) + debug=: ;; + --file | --fil | --fi | --f ) + $ac_shift + case $ac_optarg in + *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; + '') as_fn_error $? "missing file argument" ;; + esac + as_fn_append CONFIG_FILES " '$ac_optarg'" + ac_need_defaults=false;; + --header | --heade | --head | --hea ) + $ac_shift + case $ac_optarg in + *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; + esac + as_fn_append CONFIG_HEADERS " '$ac_optarg'" + ac_need_defaults=false;; + --he | --h) + # Conflict between --help and --header + as_fn_error $? "ambiguous option: \`$1' +Try \`$0 --help' for more information.";; + --help | --hel | -h ) + $as_echo "$ac_cs_usage"; exit ;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil | --si | --s) + ac_cs_silent=: ;; + + # This is an error. + -*) as_fn_error $? "unrecognized option: \`$1' +Try \`$0 --help' for more information." ;; + + *) as_fn_append ac_config_targets " $1" + ac_need_defaults=false ;; + + esac + shift +done + +ac_configure_extra_args= + +if $ac_cs_silent; then + exec 6>/dev/null + ac_configure_extra_args="$ac_configure_extra_args --silent" +fi + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +if \$ac_cs_recheck; then + set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion + shift + \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 + CONFIG_SHELL='$SHELL' + export CONFIG_SHELL + exec "\$@" +fi + +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +exec 5>>config.log +{ + echo + sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX +## Running $as_me. ## +_ASBOX + $as_echo "$ac_log" +} >&5 + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 + +# Handling of arguments. +for ac_config_target in $ac_config_targets +do + case $ac_config_target in + "src/include/build.h") CONFIG_HEADERS="$CONFIG_HEADERS src/include/build.h" ;; + "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; + "Makefile.global") CONFIG_FILES="$CONFIG_FILES Makefile.global" ;; + + *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; + esac +done + + +# If the user did not use the arguments to specify the items to instantiate, +# then the envvar interface is used. Set only those that are not. +# We use the long form for the default assignment because of an extremely +# bizarre bug on SunOS 4.1.3. +if $ac_need_defaults; then + test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files + test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers +fi + +# Have a temporary directory for convenience. Make it in the build tree +# simply because there is no reason against having it here, and in addition, +# creating and moving files from /tmp can sometimes cause problems. +# Hook for its removal unless debugging. +# Note that there is a small window in which the directory will not be cleaned: +# after its creation but before its name has been assigned to `$tmp'. +$debug || +{ + tmp= ac_tmp= + trap 'exit_status=$? + : "${ac_tmp:=$tmp}" + { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status +' 0 + trap 'as_fn_exit 1' 1 2 13 15 +} +# Create a (secure) tmp directory for tmp files. + +{ + tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && + test -d "$tmp" +} || +{ + tmp=./conf$$-$RANDOM + (umask 077 && mkdir "$tmp") +} || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 +ac_tmp=$tmp + +# Set up the scripts for CONFIG_FILES section. +# No need to generate them if there are no CONFIG_FILES. +# This happens for instance with `./config.status config.h'. +if test -n "$CONFIG_FILES"; then + + +ac_cr=`echo X | tr X '\015'` +# On cygwin, bash can eat \r inside `` if the user requested igncr. +# But we know of no other shell where ac_cr would be empty at this +# point, so we can use a bashism as a fallback. +if test "x$ac_cr" = x; then + eval ac_cr=\$\'\\r\' +fi +ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` +if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then + ac_cs_awk_cr='\\r' +else + ac_cs_awk_cr=$ac_cr +fi + +echo 'BEGIN {' >"$ac_tmp/subs1.awk" && +_ACEOF + + +{ + echo "cat >conf$$subs.awk <<_ACEOF" && + echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && + echo "_ACEOF" +} >conf$$subs.sh || + as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 +ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'` +ac_delim='%!_!# ' +for ac_last_try in false false false false false :; do + . ./conf$$subs.sh || + as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 + + ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` + if test $ac_delim_n = $ac_delim_num; then + break + elif $ac_last_try; then + as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 + else + ac_delim="$ac_delim!$ac_delim _$ac_delim!! " + fi +done +rm -f conf$$subs.sh + +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK && +_ACEOF +sed -n ' +h +s/^/S["/; s/!.*/"]=/ +p +g +s/^[^!]*!// +:repl +t repl +s/'"$ac_delim"'$// +t delim +:nl +h +s/\(.\{148\}\)..*/\1/ +t more1 +s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ +p +n +b repl +:more1 +s/["\\]/\\&/g; s/^/"/; s/$/"\\/ +p +g +s/.\{148\}// +t nl +:delim +h +s/\(.\{148\}\)..*/\1/ +t more2 +s/["\\]/\\&/g; s/^/"/; s/$/"/ +p +b +:more2 +s/["\\]/\\&/g; s/^/"/; s/$/"\\/ +p +g +s/.\{148\}// +t delim +' >$CONFIG_STATUS || ac_write_fail=1 +rm -f conf$$subs.awk +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +_ACAWK +cat >>"\$ac_tmp/subs1.awk" <<_ACAWK && + for (key in S) S_is_set[key] = 1 + FS = "" + +} +{ + line = $ 0 + nfields = split(line, field, "@") + substed = 0 + len = length(field[1]) + for (i = 2; i < nfields; i++) { + key = field[i] + keylen = length(key) + if (S_is_set[key]) { + value = S[key] + line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) + len += length(value) + length(field[++i]) + substed = 1 + } else + len += 1 + keylen + } + + print line +} + +_ACAWK +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then + sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" +else + cat +fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ + || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 +_ACEOF + +# VPATH may cause trouble with some makes, so we remove sole $(srcdir), +# ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and +# trailing colons and then remove the whole line if VPATH becomes empty +# (actually we leave an empty line to preserve line numbers). +if test "x$srcdir" = x.; then + ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{ +h +s/// +s/^/:/ +s/[ ]*$/:/ +s/:\$(srcdir):/:/g +s/:\${srcdir}:/:/g +s/:@srcdir@:/:/g +s/^:*// +s/:*$// +x +s/\(=[ ]*\).*/\1/ +G +s/\n// +s/^[^=]*=[ ]*$// +}' +fi + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +fi # test -n "$CONFIG_FILES" + +# Set up the scripts for CONFIG_HEADERS section. +# No need to generate them if there are no CONFIG_HEADERS. +# This happens for instance with `./config.status Makefile'. +if test -n "$CONFIG_HEADERS"; then +cat >"$ac_tmp/defines.awk" <<\_ACAWK || +BEGIN { +_ACEOF + +# Transform confdefs.h into an awk script `defines.awk', embedded as +# here-document in config.status, that substitutes the proper values into +# config.h.in to produce config.h. + +# Create a delimiter string that does not exist in confdefs.h, to ease +# handling of long lines. +ac_delim='%!_!# ' +for ac_last_try in false false :; do + ac_tt=`sed -n "/$ac_delim/p" confdefs.h` + if test -z "$ac_tt"; then + break + elif $ac_last_try; then + as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5 + else + ac_delim="$ac_delim!$ac_delim _$ac_delim!! " + fi +done + +# For the awk script, D is an array of macro values keyed by name, +# likewise P contains macro parameters if any. Preserve backslash +# newline sequences. + +ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]* +sed -n ' +s/.\{148\}/&'"$ac_delim"'/g +t rset +:rset +s/^[ ]*#[ ]*define[ ][ ]*/ / +t def +d +:def +s/\\$// +t bsnl +s/["\\]/\\&/g +s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ +D["\1"]=" \3"/p +s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p +d +:bsnl +s/["\\]/\\&/g +s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ +D["\1"]=" \3\\\\\\n"\\/p +t cont +s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p +t cont +d +:cont +n +s/.\{148\}/&'"$ac_delim"'/g +t clear +:clear +s/\\$// +t bsnlc +s/["\\]/\\&/g; s/^/"/; s/$/"/p +d +:bsnlc +s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p +b cont +' >$CONFIG_STATUS || ac_write_fail=1 + +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 + for (key in D) D_is_set[key] = 1 + FS = "" +} +/^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ { + line = \$ 0 + split(line, arg, " ") + if (arg[1] == "#") { + defundef = arg[2] + mac1 = arg[3] + } else { + defundef = substr(arg[1], 2) + mac1 = arg[2] + } + split(mac1, mac2, "(") #) + macro = mac2[1] + prefix = substr(line, 1, index(line, defundef) - 1) + if (D_is_set[macro]) { + # Preserve the white space surrounding the "#". + print prefix "define", macro P[macro] D[macro] + next + } else { + # Replace #undef with comments. This is necessary, for example, + # in the case of _POSIX_SOURCE, which is predefined and required + # on some systems where configure will not decide to define it. + if (defundef == "undef") { + print "/*", prefix defundef, macro, "*/" + next + } + } +} +{ print } +_ACAWK +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 + as_fn_error $? "could not setup config headers machinery" "$LINENO" 5 +fi # test -n "$CONFIG_HEADERS" + + +eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS " +shift +for ac_tag +do + case $ac_tag in + :[FHLC]) ac_mode=$ac_tag; continue;; + esac + case $ac_mode$ac_tag in + :[FHL]*:*);; + :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; + :[FH]-) ac_tag=-:-;; + :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; + esac + ac_save_IFS=$IFS + IFS=: + set x $ac_tag + IFS=$ac_save_IFS + shift + ac_file=$1 + shift + + case $ac_mode in + :L) ac_source=$1;; + :[FH]) + ac_file_inputs= + for ac_f + do + case $ac_f in + -) ac_f="$ac_tmp/stdin";; + *) # Look for the file first in the build tree, then in the source tree + # (if the path is not absolute). The absolute path cannot be DOS-style, + # because $ac_f cannot contain `:'. + test -f "$ac_f" || + case $ac_f in + [\\/$]*) false;; + *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; + esac || + as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; + esac + case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac + as_fn_append ac_file_inputs " '$ac_f'" + done + + # Let's still pretend it is `configure' which instantiates (i.e., don't + # use $as_me), people would be surprised to read: + # /* config.h. Generated by config.status. */ + configure_input='Generated from '` + $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' + `' by configure.' + if test x"$ac_file" != x-; then + configure_input="$ac_file. $configure_input" + { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 +$as_echo "$as_me: creating $ac_file" >&6;} + fi + # Neutralize special characters interpreted by sed in replacement strings. + case $configure_input in #( + *\&* | *\|* | *\\* ) + ac_sed_conf_input=`$as_echo "$configure_input" | + sed 's/[\\\\&|]/\\\\&/g'`;; #( + *) ac_sed_conf_input=$configure_input;; + esac + + case $ac_tag in + *:-:* | *:-) cat >"$ac_tmp/stdin" \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; + esac + ;; + esac + + ac_dir=`$as_dirname -- "$ac_file" || +$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$ac_file" : 'X\(//\)[^/]' \| \ + X"$ac_file" : 'X\(//\)$' \| \ + X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$ac_file" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + as_dir="$ac_dir"; as_fn_mkdir_p + ac_builddir=. + +case "$ac_dir" in +.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; +*) + ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` + # A ".." for each directory in $ac_dir_suffix. + ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` + case $ac_top_builddir_sub in + "") ac_top_builddir_sub=. ac_top_build_prefix= ;; + *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; + esac ;; +esac +ac_abs_top_builddir=$ac_pwd +ac_abs_builddir=$ac_pwd$ac_dir_suffix +# for backward compatibility: +ac_top_builddir=$ac_top_build_prefix + +case $srcdir in + .) # We are building in place. + ac_srcdir=. + ac_top_srcdir=$ac_top_builddir_sub + ac_abs_top_srcdir=$ac_pwd ;; + [\\/]* | ?:[\\/]* ) # Absolute name. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir + ac_abs_top_srcdir=$srcdir ;; + *) # Relative name. + ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_build_prefix$srcdir + ac_abs_top_srcdir=$ac_pwd/$srcdir ;; +esac +ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix + + + case $ac_mode in + :F) + # + # CONFIG_FILE + # + +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +# If the template does not know about datarootdir, expand it. +# FIXME: This hack should be removed a few years after 2.60. +ac_datarootdir_hack=; ac_datarootdir_seen= +ac_sed_dataroot=' +/datarootdir/ { + p + q +} +/@datadir@/p +/@docdir@/p +/@infodir@/p +/@localedir@/p +/@mandir@/p' +case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in +*datarootdir*) ac_datarootdir_seen=yes;; +*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 +$as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 + ac_datarootdir_hack=' + s&@datadir@&$datadir&g + s&@docdir@&$docdir&g + s&@infodir@&$infodir&g + s&@localedir@&$localedir&g + s&@mandir@&$mandir&g + s&\\\${datarootdir}&$datarootdir&g' ;; +esac +_ACEOF + +# Neutralize VPATH when `$srcdir' = `.'. +# Shell code in configure.ac might set extrasub. +# FIXME: do we really want to maintain this feature? +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +ac_sed_extra="$ac_vpsub +$extrasub +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +:t +/@[a-zA-Z_][a-zA-Z_0-9]*@/!b +s|@configure_input@|$ac_sed_conf_input|;t t +s&@top_builddir@&$ac_top_builddir_sub&;t t +s&@top_build_prefix@&$ac_top_build_prefix&;t t +s&@srcdir@&$ac_srcdir&;t t +s&@abs_srcdir@&$ac_abs_srcdir&;t t +s&@top_srcdir@&$ac_top_srcdir&;t t +s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t +s&@builddir@&$ac_builddir&;t t +s&@abs_builddir@&$ac_abs_builddir&;t t +s&@abs_top_builddir@&$ac_abs_top_builddir&;t t +$ac_datarootdir_hack +" +eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \ + >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + +test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && + { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && + { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ + "$ac_tmp/out"`; test -z "$ac_out"; } && + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' +which seems to be undefined. Please make sure it is defined" >&5 +$as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' +which seems to be undefined. Please make sure it is defined" >&2;} + + rm -f "$ac_tmp/stdin" + case $ac_file in + -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; + *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; + esac \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + ;; + :H) + # + # CONFIG_HEADER + # + if test x"$ac_file" != x-; then + { + $as_echo "/* $configure_input */" \ + && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" + } >"$ac_tmp/config.h" \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then + { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 +$as_echo "$as_me: $ac_file is unchanged" >&6;} + else + rm -f "$ac_file" + mv "$ac_tmp/config.h" "$ac_file" \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + fi + else + $as_echo "/* $configure_input */" \ + && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \ + || as_fn_error $? "could not create -" "$LINENO" 5 + fi + ;; + + + esac + +done # for ac_tag + + +as_fn_exit 0 +_ACEOF +ac_clean_files=$ac_clean_files_save + +test $ac_write_fail = 0 || + as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5 + + +# configure is writing to config.log, and then calls config.status. +# config.status does its own redirection, appending to config.log. +# Unfortunately, on DOS this fails, as config.log is still kept open +# by configure, so config.status won't be able to write to it; its +# output is simply discarded. So we exec the FD to /dev/null, +# effectively closing config.log, so it can be properly (re)opened and +# appended to by config.status. When coming back to configure, we +# need to make the FD available again. +if test "$no_create" != yes; then + ac_cs_success=: + ac_config_status_args= + test "$silent" = yes && + ac_config_status_args="$ac_config_status_args --quiet" + exec 5>/dev/null + $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false + exec 5>>config.log + # Use ||, not &&, to avoid exiting from the if with $? = 1, which + # would make configure fail if this is the last instruction. + $ac_cs_success || as_fn_exit 1 +fi +if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 +$as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} +fi + diff --git a/configure.ac b/configure.ac index d8f11c6..de06d7c 100644 --- a/configure.ac +++ b/configure.ac @@ -1,6 +1,6 @@ -AC_CONFIG_AUX_DIR([build-aux]) - AC_INIT(schaufel, 0.5) +AC_CONFIG_SRCDIR([src/modules.c]) +#AC_CONFIG_AUX_DIR([build-aux]) AC_LANG(C) AC_PROG_CC diff --git a/contrib.mk b/contrib.mk index 3818c1a..34b18d6 100644 --- a/contrib.mk +++ b/contrib.mk @@ -2,25 +2,26 @@ SCHAUFEL ?= schaufel ifdef CONTRIB include ../../Makefile.global - CFLAGS += -I../../src/include + CPPFLAGS += -I../../src/include else include $(shell $(SCHAUFEL) -L)/Makefile.global - CFLAGS += -I$(shell $(SCHAUFEL) -I) + CPPFLAGS += -I$(shell $(SCHAUFEL) -I) endif CFLAGS += -fPIC -CFLAGS += $(LIBS) +LDFLAGS += -shared -all: clean link +all: clean $(LIB) -link: $(OBJ) - $(LD) $(OBJ) -shared -o $(LIB) +$(LIB): $(OBJ) + $(LD) $(LDFLAGS) $(LIBS) $< -o $@ clean: rm -f $(OBJ) + rm -f $(LIB) %.o: %.c - $(CC) $(CFLAGS) -c $< -o $@ + $(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@ install: all $(INSTALL) $(LIB) $(contribdir)/$(LIB) diff --git a/contrib/exports/Makefile b/contrib/exports/Makefile index c55f615..0d5fd46 100644 --- a/contrib/exports/Makefile +++ b/contrib/exports/Makefile @@ -4,4 +4,4 @@ LIBS := -lpq -ljson-c -lconfig -lpthread OBJ := exports.o LIB := exports.so -include $(shell $(SCHAUFEL) -L)/contrib.mk +include ../../contrib.mk diff --git a/contrib/kafka/Makefile b/contrib/kafka/Makefile index b9f9e94..41e87a3 100644 --- a/contrib/kafka/Makefile +++ b/contrib/kafka/Makefile @@ -4,4 +4,4 @@ LIBS := -lrdkafka -lconfig -lpthread OBJ := kafka.o LIB := kafka.so -include $(shell $(SCHAUFEL) -L)/contrib.mk +include ../../contrib.mk diff --git a/contrib/postgres/Makefile b/contrib/postgres/Makefile index 824f019..5643bce 100644 --- a/contrib/postgres/Makefile +++ b/contrib/postgres/Makefile @@ -4,4 +4,4 @@ LIBS := -lpq -lconfig -lpthread OBJ := postgres.o LIB := postgres.so -include $(shell $(SCHAUFEL) -L)/contrib.mk +include ../../contrib.mk diff --git a/contrib/redis/Makefile b/contrib/redis/Makefile index 50eded7..0f7307d 100644 --- a/contrib/redis/Makefile +++ b/contrib/redis/Makefile @@ -4,4 +4,4 @@ LIBS := -lhiredis -lconfig -lpthread OBJ := redis.o LIB := redis.so -include $(shell $(SCHAUFEL) -L)/contrib.mk +include ../../contrib.mk diff --git a/src/include/build.h b/src/include/build.h deleted file mode 100644 index dbfda1f..0000000 --- a/src/include/build.h +++ /dev/null @@ -1,32 +0,0 @@ -/* src/include/build.h. Generated from build.h.in by configure. */ -/* src/config.h.in. Generated from configure.ac by autoheader. */ - -/* Define to 1 if you have the `config' library (-lconfig). */ -#define HAVE_LIBCONFIG 1 - -/* Define to 1 if you have the `pq' library (-lpq). */ -/* #undef HAVE_LIBPQ */ - -/* Define to 1 if you have the `pthread' library (-lpthread). */ -/* #undef HAVE_LIBPTHREAD */ - -/* Define to the address where bug reports for this package should be sent. */ -#define PACKAGE_BUGREPORT "" - -/* Define to the full name of this package. */ -#define PACKAGE_NAME "schaufel" - -/* Define to the full name and version of this package. */ -#define PACKAGE_STRING "schaufel 0.5" - -/* Define to the one symbol short name of this package. */ -#define PACKAGE_TARNAME "schaufel" - -/* Define to the home page for this package. */ -#define PACKAGE_URL "" - -/* Define to the version of this package. */ -#define PACKAGE_VERSION "0.5" - -/* Numeric version */ -/* #undef VERSION_NUM */ diff --git a/src/include/build.h.in b/src/include/build.h.in index 8b64f0e..2833bed 100644 --- a/src/include/build.h.in +++ b/src/include/build.h.in @@ -1,14 +1,8 @@ -/* src/config.h.in. Generated from configure.ac by autoheader. */ +/* src/include/build.h.in. Generated from configure.ac by autoheader. */ /* Define to 1 if you have the `config' library (-lconfig). */ #undef HAVE_LIBCONFIG -/* Define to 1 if you have the `pq' library (-lpq). */ -#undef HAVE_LIBPQ - -/* Define to 1 if you have the `pthread' library (-lpthread). */ -#undef HAVE_LIBPTHREAD - /* Define to the address where bug reports for this package should be sent. */ #undef PACKAGE_BUGREPORT @@ -26,6 +20,3 @@ /* Define to the version of this package. */ #undef PACKAGE_VERSION - -/* Numeric version */ -#undef VERSION_NUM diff --git a/src/include/paths.h b/src/include/paths.h deleted file mode 100644 index e96667c..0000000 --- a/src/include/paths.h +++ /dev/null @@ -1,5 +0,0 @@ -#define INCLUDEDIR "/usr/local/include/schaufel" -#define LIBDIR "/usr/local/lib" -#define CONTRIBDIR "/usr/local/lib/schaufel" -#define DOCDIR "/usr/local/share/doc//schaufel" -#define MANDIR "/usr/local/share/man" From b9dd19a91e45e59a69cb24c6400d0fc6471f6933 Mon Sep 17 00:00:00 2001 From: Ildar Musin Date: Fri, 24 May 2019 12:39:41 +0200 Subject: [PATCH 13/16] Add check that loaded module implements consumer and/or producer interface --- src/include/modules.h | 4 +--- src/main.c | 2 -- src/modules.c | 3 +++ src/utils/config.c | 40 ++++++++++++++++++++++++++++++++++++++-- 4 files changed, 42 insertions(+), 7 deletions(-) diff --git a/src/include/modules.h b/src/include/modules.h index 55b1d24..b83924c 100644 --- a/src/include/modules.h +++ b/src/include/modules.h @@ -14,14 +14,12 @@ typedef struct ModuleHandler Consumer (*consumer_init) (config_setting_t *config); int (*consume) (Consumer c, Message msg); void (*consumer_free) (Consumer *c); + bool (*validate_consumer) (config_setting_t* config); /* producer routines */ Producer (*producer_init) (config_setting_t *config); void (*produce) (Producer p, Message msg); void (*producer_free) (Producer *p); - - /* validator routines */ - bool (*validate_consumer) (config_setting_t* config); bool (*validate_producer) (config_setting_t* config); } ModuleHandler; diff --git a/src/main.c b/src/main.c index d461fe4..4b33c07 100644 --- a/src/main.c +++ b/src/main.c @@ -144,8 +144,6 @@ consume(void *config) return NULL; } - /* TODO: check that consumer_init routine is not NULL */ - Consumer c = handler->consumer_init((config_setting_t *) config); if (c == NULL) { diff --git a/src/modules.c b/src/modules.c index 58de17a..d8bf27e 100644 --- a/src/modules.c +++ b/src/modules.c @@ -67,6 +67,9 @@ load_library(const char *name) char sopath[2048]; void (*init_func)(void); + if (!name) + return false; + snprintf(sopath, 2048, "%s/%s.so", CONTRIBDIR, name); handle = dlopen(sopath, RTLD_NOW); diff --git a/src/utils/config.c b/src/utils/config.c index fc19c94..f72885d 100644 --- a/src/utils/config.c +++ b/src/utils/config.c @@ -87,6 +87,34 @@ module_to_string(int module) return result; } +static bool +verify_consumer_routines(ModuleHandler *handler) +{ + if (handler->consumer_init + && handler->consume + && handler->consumer_free + && handler->validate_producer) + { + return true; + } + + return false; +} + +static bool +verify_producer_routines(ModuleHandler *handler) +{ + if (handler->producer_init + && handler->produce + && handler->producer_free + && handler->validate_producer) + { + return true; + } + + return false; +} + static bool _thread_validate(config_t* config, int type) { char buf[1024]; @@ -157,9 +185,10 @@ static bool _thread_validate(config_t* config, int type) if(type == SCHAUFEL_TYPE_CONSUMER) { - if (!handler->validate_consumer) + if (!verify_consumer_routines(handler)) { - fprintf(stderr, "Type %s has no consumer validator!\n", conf_str); + fprintf(stderr, "%s %d: '%s' module doesn't implement consumer interface\n", + __FILE__, __LINE__, conf_str); ret = false; goto error; } @@ -171,6 +200,13 @@ static bool _thread_validate(config_t* config, int type) } else if(type == SCHAUFEL_TYPE_PRODUCER) { + if (!verify_producer_routines(handler)) + { + fprintf(stderr, "%s %d: '%s' module doesn't implement producer interface\n", + __FILE__, __LINE__, conf_str); + ret = false; + goto error; + } if (!handler->validate_producer) { fprintf(stderr, "Type %s has no producer validator!\n", conf_str); From 18b13fa5ef344f2792197a3a1c094b554fce9c61 Mon Sep 17 00:00:00 2001 From: Ildar Musin Date: Fri, 24 May 2019 14:50:57 +0200 Subject: [PATCH 14/16] Check modules for the names conflict --- src/main.c | 2 +- src/modules.c | 20 +++++++++++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/main.c b/src/main.c index 4b33c07..a7a2a6a 100644 --- a/src/main.c +++ b/src/main.c @@ -364,7 +364,7 @@ main(int argc, char **argv) if (!load_libraries(&config)) { logger_log("%s %d: Failed to load libraries\n", __FILE__, __LINE__); - abort(); + exit(1); } if(!config_validate(&config)) { diff --git a/src/modules.c b/src/modules.c index d8bf27e..8fd4a3e 100644 --- a/src/modules.c +++ b/src/modules.c @@ -28,8 +28,26 @@ extern void register_module(const char *name, ModuleHandler *handler) { ModuleNode *node = SCALLOC(1, sizeof(ModuleNode)); + ModuleNode *cur = modules_head; + + /* check for module names conflicts */ + while (cur) + { + if (strcmp(cur->name, name) == 0) + { + logger_log("module '%s' has already been registered", name); + /* + * XXX This function is called from extensions and we can't trust + * extensions to properly propagate the error back to schaufel. + * So we just exit here. Is there a better solution? + */ + exit(1); + } + + cur = cur->next; + } - /* TODO: check that module with the same name already exists */ + /* set up a new node and insert it to the head of the list */ node->name = name; node->handler = handler; node->next = modules_head; From 0b0f305122a58874bbe42dbde73409ae158a5092 Mon Sep 17 00:00:00 2001 From: Ildar Musin Date: Fri, 24 May 2019 17:40:55 +0200 Subject: [PATCH 15/16] Properly load contrib modules when executing schaufel with command line arguments --- Makefile.in | 2 +- src/utils/config.c | 63 +++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 61 insertions(+), 4 deletions(-) diff --git a/Makefile.in b/Makefile.in index 7c21656..76473ba 100644 --- a/Makefile.in +++ b/Makefile.in @@ -58,7 +58,7 @@ $(OBJDIR)/%.o: t/%.c install: all $(INSTALL) bin/schaufel $(DESTDIR)$(bindir)/schaufel - cp -a src/include $(DESTDIR)$(includedir) + cp -r src/include/ $(DESTDIR)$(includedir) $(INSTALL) -m 0644 contrib.mk $(DESTDIR)$(contribdir)/contrib.mk $(INSTALL) -m 0644 Makefile.global $(DESTDIR)$(contribdir)/Makefile.global $(INSTALL) -m 0644 -t $(DESTDIR)$(docdir) doc/* diff --git a/src/utils/config.c b/src/utils/config.c index f72885d..ded52ab 100644 --- a/src/utils/config.c +++ b/src/utils/config.c @@ -1,5 +1,6 @@ #include #include +#include #include "modules.h" #include "utils/config.h" @@ -60,6 +61,38 @@ _add_member(config_setting_t* config, char* name, int type) return(child); } +static void +_add_list_member_unique(config_setting_t* setting, const char *str) +{ + int i; + int len; + + /* TODO: check once */ + if (!config_setting_is_list(setting)) + exit(1); + + len = config_setting_length(setting); + for (i = 0; i < len; ++i) + { + config_setting_t *elem; + + elem = config_setting_get_elem(setting, i); + if (config_setting_type(elem) == CONFIG_TYPE_STRING) + { + const char *val = config_setting_get_string(elem); + + if (strcmp(val, str) == 0) + { + /* the list already contains str, skipping */ + return; + } + + elem = _add_member(setting, NULL, CONFIG_TYPE_STRING); + config_setting_set_string(elem, str); + } + } +} + char * module_to_string(int module) { @@ -263,7 +296,11 @@ config_merge(config_t* config, Options o) /* Commandline options take precedence over * config file parameters. */ - config_setting_t *croot = NULL, *parent = NULL, *setting = NULL; + config_setting_t *croot = NULL, + *parent = NULL, + *setting = NULL, + *libs = NULL; + croot = config_root_setting(config); setting = config_lookup(config, "logger"); @@ -276,12 +313,27 @@ config_merge(config_t* config, Options o) config_setting_set_string(setting, "file"); } // TODO : default to stderr + // libraries + if ((libs = config_setting_get_member(croot, "libraries")) != NULL) { + if (!config_setting_is_list(libs)) { + fprintf(stderr, "'libraries' setting must be a list"); + exit(1); + } + } else { + libs = _add_node(croot, "libraries", CONFIG_TYPE_LIST); + } + //consumers if (o.input) { + const char *module = module_to_string(o.input); + parent = _add_node(croot, "consumers", CONFIG_TYPE_LIST); parent = _add_node(parent, NULL, CONFIG_TYPE_GROUP); setting = _add_member(parent, "type", CONFIG_TYPE_STRING); - config_setting_set_string(setting, module_to_string(o.input)); + config_setting_set_string(setting, module); + + // add library + _add_list_member_unique(libs, module); // threads are initialized to 0, therefore they are safe to add setting = _add_member(parent, "threads", CONFIG_TYPE_INT); @@ -314,10 +366,15 @@ config_merge(config_t* config, Options o) //producers if (o.output) { + const char *module = module_to_string(o.output); + parent = _add_node(croot, "producers", CONFIG_TYPE_LIST); parent = _add_node(parent, NULL, CONFIG_TYPE_GROUP); setting = _add_member(parent, "type", CONFIG_TYPE_STRING); - config_setting_set_string(setting, module_to_string(o.output)); + config_setting_set_string(setting, module); + + // add library + _add_list_member_unique(libs, module); // threads are initialized to 0, therefore they are safe to add setting = _add_member(parent, "threads", CONFIG_TYPE_INT); From c55492a71cf7fd601287a83225d60002d10ff66d Mon Sep 17 00:00:00 2001 From: Ildar Musin Date: Mon, 27 May 2019 15:46:20 +0200 Subject: [PATCH 16/16] Remove garbage files --- Makefile.in | 2 -- aclocal.m4 | 68 -------------------------------------- configure.ac | 4 +-- src/include/config_paths.h | 5 --- src/include/modules.h | 2 +- 5 files changed, 2 insertions(+), 79 deletions(-) delete mode 100644 aclocal.m4 delete mode 100644 src/include/config_paths.h diff --git a/Makefile.in b/Makefile.in index 76473ba..8e10b1d 100644 --- a/Makefile.in +++ b/Makefile.in @@ -68,7 +68,5 @@ install: all src/include/paths.h: echo "#define INCLUDEDIR \"$(includedir)\"" >$@ echo "#define CONTRIBDIR \"$(contribdir)\"" >>$@ - echo "#define DOCDIR \"$(docdir)\"" >>$@ - echo "#define MANDIR \"$(mandir)\"" >>$@ .PHONY: all contrib docs release test clean diff --git a/aclocal.m4 b/aclocal.m4 deleted file mode 100644 index 1bd971f..0000000 --- a/aclocal.m4 +++ /dev/null @@ -1,68 +0,0 @@ -# generated automatically by aclocal 1.16.1 -*- Autoconf -*- - -# Copyright (C) 1996-2018 Free Software Foundation, Inc. - -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -m4_ifndef([AC_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])]) -# =========================================================================== -# https://www.gnu.org/software/autoconf-archive/ax_check_compile_flag.html -# =========================================================================== -# -# SYNOPSIS -# -# AX_CHECK_COMPILE_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS], [INPUT]) -# -# DESCRIPTION -# -# Check whether the given FLAG works with the current language's compiler -# or gives an error. (Warnings, however, are ignored) -# -# ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on -# success/failure. -# -# If EXTRA-FLAGS is defined, it is added to the current language's default -# flags (e.g. CFLAGS) when the check is done. The check is thus made with -# the flags: "CFLAGS EXTRA-FLAGS FLAG". This can for example be used to -# force the compiler to issue an error when a bad flag is given. -# -# INPUT gives an alternative input source to AC_COMPILE_IFELSE. -# -# NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this -# macro in sync with AX_CHECK_{PREPROC,LINK}_FLAG. -# -# LICENSE -# -# Copyright (c) 2008 Guido U. Draheim -# Copyright (c) 2011 Maarten Bosmans -# -# Copying and distribution of this file, with or without modification, are -# permitted in any medium without royalty provided the copyright notice -# and this notice are preserved. This file is offered as-is, without any -# warranty. - -#serial 6 - -AC_DEFUN([AX_CHECK_COMPILE_FLAG], -[AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF -AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl -AC_CACHE_CHECK([whether _AC_LANG compiler accepts $1], CACHEVAR, [ - ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS - _AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1" - AC_COMPILE_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])], - [AS_VAR_SET(CACHEVAR,[yes])], - [AS_VAR_SET(CACHEVAR,[no])]) - _AC_LANG_PREFIX[]FLAGS=$ax_check_save_flags]) -AS_VAR_IF(CACHEVAR,yes, - [m4_default([$2], :)], - [m4_default([$3], :)]) -AS_VAR_POPDEF([CACHEVAR])dnl -])dnl AX_CHECK_COMPILE_FLAGS - diff --git a/configure.ac b/configure.ac index de06d7c..4525142 100644 --- a/configure.ac +++ b/configure.ac @@ -1,6 +1,5 @@ -AC_INIT(schaufel, 0.5) +AC_INIT([schaufel], [0.5]) AC_CONFIG_SRCDIR([src/modules.c]) -#AC_CONFIG_AUX_DIR([build-aux]) AC_LANG(C) AC_PROG_CC @@ -33,5 +32,4 @@ CFLAGS+=" -D_POSIX_C_SOURCE=200809L" CFLAGS+=" -D_BSD_SOURCE" AC_CONFIG_HEADERS([src/include/build.h]) - AC_OUTPUT([Makefile Makefile.global]) diff --git a/src/include/config_paths.h b/src/include/config_paths.h deleted file mode 100644 index 1442fd1..0000000 --- a/src/include/config_paths.h +++ /dev/null @@ -1,5 +0,0 @@ -#define INCLUDEDIR "" -#define LIBDIR "/tmp/schaufel/lib" -#define CONTRIBDIR "/tmp/schaufel/lib/schaufel" -#define DOCDIR "/tmp/schaufel/share/doc//schaufel" -#define MANDIR "/tmp/schaufel/share/man" diff --git a/src/include/modules.h b/src/include/modules.h index b83924c..55023f3 100644 --- a/src/include/modules.h +++ b/src/include/modules.h @@ -15,7 +15,7 @@ typedef struct ModuleHandler int (*consume) (Consumer c, Message msg); void (*consumer_free) (Consumer *c); bool (*validate_consumer) (config_setting_t* config); - + /* producer routines */ Producer (*producer_init) (config_setting_t *config); void (*produce) (Producer p, Message msg);