Commit 66cc9b66 authored by Cyrill Gorcunov's avatar Cyrill Gorcunov Committed by Pavel Emelyanov

make: Introduce compile time include/config.h generation

It's being reported that some systems (as Ubuntu 13.04) already
have struct tcp_repair_opt definition in their system headers.

| sk-tcp.c:25:8: error: redefinition of struct tcp_repair_opt
| sk-tcp.c:31:2: error: redeclaration of enumerator TCP_NO_QUEUE

So add a facility for compile time testing for reported entities
to be present on a system. For this we generate include/config.h
where all tested entries will lay and source code need to include
it only in places where really needed.
Reported-by: 's avatarVasily Averin <vvs@parallels.com>
Acked-by: 's avatarKir Kolyshkin <kir@openvz.org>
Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 234dce78
......@@ -17,6 +17,7 @@ export VERSION_MAJOR VERSION_MINOR VERSION_SUBLEVEL VERSION_EXTRA VERSION_NAME
#MAKEFLAGS := -r -R
include Makefile.inc
include Makefile.config
#
# Common definitions
......@@ -118,7 +119,7 @@ ifeq ($(GCOV),1)
%.o $(PROGRAM): override CFLAGS += --coverage
endif
all: pie $(VERSION_HEADER)
all: config pie $(VERSION_HEADER)
$(Q) $(MAKE) $(PROGRAM)
protobuf/%::
......@@ -158,6 +159,7 @@ clean-built:
$(Q) $(MAKE) $(build)=pie clean
$(Q) $(MAKE) $(build-crtools)=. clean
$(Q) $(MAKE) -C Documentation clean
$(Q) $(RM) ./include/config.h
$(Q) $(RM) ./$(PROGRAM)
rebuild: clean-built
......
include scripts/utilities.mak
include scripts/feature-tests.mak
CONFIG := include/config.h
$(CONFIG): scripts/utilities.mak scripts/feature-tests.mak
$(E) " GEN " $@
$(Q) @echo '#ifndef __CR_CONFIG_H__' > $@
$(Q) @echo '#define __CR_CONFIG_H__' >> $@
ifeq ($(call try-cc,$(TCP_REPAIR_TEST),,),y)
$(Q) @echo '#define CONFIG_HAS_TCP_REPAIR' >> $@
endif
$(Q) @echo '#endif /* __CR_CONFIG_H__ */' >> $@
config: $(CONFIG)
.PHONY: config
define TCP_REPAIR_TEST
#include <netinet/tcp.h>
int main(void)
{
struct tcp_repair_opt opts;
opts.opt_code = TCP_NO_QUEUE;
opts.opt_val = 0;
return opts.opt_val;
}
endef
......@@ -18,10 +18,19 @@
#include "netfilter.h"
#include "image.h"
#include "namespaces.h"
#include "config.h"
#include "protobuf.h"
#include "protobuf/tcp-stream.pb-c.h"
#ifndef CONFIG_HAS_TCP_REPAIR
/*
* It's been reported that both tcp_repair_opt
* and TCP_ enum already shipped in netinet/tcp.h
* system header by some distros thus we need a
* test if we can use predefined ones or provide
* our own.
*/
struct tcp_repair_opt {
u32 opt_code;
u32 opt_val;
......@@ -33,6 +42,7 @@ enum {
TCP_SEND_QUEUE,
TCP_QUEUES_NR,
};
#endif
#ifndef TCP_TIMESTAMP
#define TCP_TIMESTAMP 24
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment