Permalink
Browse files

Separately include proper CPPFLAGS for every binary

Now that CORE_*FLAGS are not used anymore, I tried to explicitly include
only the needed CPPFLAGS for each binary. Unfortunately, because
cf3.defs.h is inluded almost everywhere, and it includes headers from
libutils, which needs OpenSSL includes, I had to carry the
OPENSSL_CPPFLAGS almost everywhere, and in fewer cases PCRE_CPPFLAGS as
well.

I didn't manage to completely remove those dependencies (OpenSSL, PCRE),
but at least now they are not included from within platform.h, but only
from the respective headers that need them.

To sum up, the dependency mess is less but still exists, but at least it
is visible in each makefile and we can untangle it little by little. And
every new dependency added by mistake will trigger a failure, where
previously it succeeded because CORE_CPPFLAGS included everything plus
the kitchen sink.
  • Loading branch information...
1 parent 618771b commit f08073835f7e08084288e381d93a111e4d9904ff @jimis jimis committed Jul 8, 2014
View
@@ -3,6 +3,8 @@ noinst_LTLIBRARIES = libcf-agent.la
AM_CPPFLAGS = -I$(srcdir)/../libpromises -I$(srcdir)/../libutils \
-I$(srcdir)/../libcfnet \
$(ENTERPRISE_CPPFLAGS) \
+ $(OPENSSL_CPPFLAGS) \
+ $(PCRE_CPPFLAGS) \
$(LIBVIRT_CPPFLAGS) \
$(POSTGRESQL_CPPFLAGS) \
$(MYSQL_CPPFLAGS) \
@@ -11,20 +13,26 @@ AM_CPPFLAGS = -I$(srcdir)/../libpromises -I$(srcdir)/../libutils \
AM_CFLAGS = \
$(ENTERPRISE_CFLAGS) \
+ $(OPENSSL_CFLAGS) \
+ $(PCRE_CFLAGS) \
$(LIBVIRT_CFLAGS) \
$(POSTGRESQL_CFLAGS) \
$(MYSQL_CFLAGS) \
$(LIBXML2_CFLAGS) \
$(PAM_CFLAGS)
AM_LDFLAGS = \
+ $(OPENSSL_LDFLAGS) \
+ $(PCRE_LDFLAGS) \
$(LIBVIRT_LDFLAGS) \
$(POSTGRESQL_LDFLAGS) \
$(MYSQL_LDFLAGS) \
$(LIBXML2_LDFLAGS) \
$(PAM_LDFLAGS)
libcf_agent_la_LIBADD = ../libutils/libutils.la ../libpromises/libpromises.la \
+ $(OPENSSL_LIBS) \
+ $(PCRE_LIBS) \
$(LIBVIRT_LIBS) \
$(POSTGRESQL_LIBS) \
$(MYSQL_LIBS) \
View
@@ -24,6 +24,7 @@
#include <cf3.defs.h>
+#include <pcre_include.h>
#include <actuator.h>
#include <eval_context.h>
#include <promises.h>
View
@@ -1,16 +1,18 @@
noinst_LTLIBRARIES = libcf-execd.la
-AM_CPPFLAGS = @CPPFLAGS@ \
+AM_CPPFLAGS = \
+ $(OPENSSL_CPPFLAGS) \
-I$(srcdir)/../libpromises \
-I$(srcdir)/../libutils \
-I$(srcdir)/../libcfnet \
-I$(srcdir)/../libenv \
$(ENTERPRISE_CPPFLAGS)
-AM_CFLAGS = @CFLAGS@ \
+AM_CFLAGS = \
+ $(OPENSSL_CFLAGS) \
$(ENTERPRISE_CFLAGS)
-libcf_execd_la_LIBADD = ../libpromises/libpromises.la
+libcf_execd_la_LIBADD = ../libutils/libutils.la ../libpromises/libpromises.la
libcf_execd_la_SOURCES = \
cf-execd.c cf-execd.h \
View
@@ -1,12 +1,14 @@
noinst_LTLIBRARIES = libcf-key.la
-AM_CPPFLAGS = @CPPFLAGS@ \
+AM_CPPFLAGS = \
+ $(OPENSSL_CPPFLAGS) \
-I$(srcdir)/../libutils \
-I$(srcdir)/../libcfnet \
-I$(srcdir)/../libpromises \
$(ENTERPRISE_CPPFLAGS)
-AM_CFLAGS = @CFLAGS@ \
+AM_CFLAGS = \
+ $(OPENSSL_CFLAGS) \
$(ENTERPRISE_CFLAGS)
libcf_key_la_SOURCES = \
@@ -22,7 +22,11 @@
included file COSL.txt.
*/
-#include <generic_agent.h>
+#include <platform.h>
+#include <cf-key-functions.h>
+
+#include <openssl/bn.h> /* BN_*, BIGNUM */
+#include <openssl/rand.h> /* RAND_* */
#include <lastseen.h>
#include <dir.h>
@@ -36,7 +40,6 @@
#include <crypto.h>
#include <file_lib.h>
-#include <cf-key-functions.h>
static const char *const passphrase = "Cfengine passphrase";
@@ -27,6 +27,8 @@
#include <generic_agent.h>
+#include <openssl/rsa.h>
+
#include <lastseen.h>
#include <dir.h>
#include <scope.h>
View
@@ -1,13 +1,15 @@
noinst_LTLIBRARIES = libcf-monitord.la
-AM_CPPFLAGS = @CPPFLAGS@ \
+AM_CPPFLAGS = \
+ $(OPENSSL_CPPFLAGS) \
-I$(srcdir)/../libutils \
-I$(srcdir)/../libcfnet \
-I$(srcdir)/../libenv \
-I$(srcdir)/../libpromises \
$(ENTERPRISE_CPPFLAGS)
AM_CFLAGS = @CFLAGS@ \
+ $(OPENSSL_CFLAGS) \
$(ENTERPRISE_CFLAGS)
libcf_monitord_la_LIBADD = ../libpromises/libpromises.la
View
@@ -1,9 +1,11 @@
noinst_LTLIBRARIES = libcf-promises.la
AM_CPPFLAGS = @CPPFLAGS@ -I$(srcdir)/../libpromises -I$(srcdir)/../libutils -I$(srcdir)/../libcfnet \
+ $(OPENSSL_CPPFLAGS) \
$(ENTERPRISE_CPPFLAGS)
AM_CFLAGS = @CFLAGS@ -I$(srcdir) \
+ $(OPENSSL_CFLAGS) \
$(ENTERPRISE_CFLAGS)
libcf_promises_la_LIBADD = ../libpromises/libpromises.la
View
@@ -1,10 +1,12 @@
noinst_LTLIBRARIES = libcf-runagent.la
-AM_CPPFLAGS = @CPPFLAGS@ -I$(srcdir)/../libpromises -I$(srcdir)/../libutils \
+AM_CPPFLAGS = -I$(srcdir)/../libpromises -I$(srcdir)/../libutils \
-I$(srcdir)/../libcfnet \
+ $(OPENSSL_CPPFLAGS) \
$(ENTERPRISE_CPPFLAGS)
AM_CFLAGS = @CFLAGS@ \
+ $(OPENSSL_CFLAGS) \
$(ENTERPRISE_CFLAGS)
libcf_runagent_la_LIBADD = ../libpromises/libpromises.la
View
@@ -1,11 +1,13 @@
noinst_LTLIBRARIES = libcf-serverd.la
-AM_CPPFLAGS = @CPPFLAGS@ -I$(srcdir)/../libpromises -I$(srcdir)/../libutils \
+AM_CPPFLAGS = -I$(srcdir)/../libpromises -I$(srcdir)/../libutils \
-I$(srcdir)/../libcfnet \
-I$(srcdir)/../libenv \
+ $(OPENSSL_CPPFLAGS) \
$(ENTERPRISE_CPPFLAGS)
-AM_CFLAGS = @CFLAGS@ \
+AM_CFLAGS = \
+ $(OPENSSL_CFLAGS) \
$(ENTERPRISE_CFLAGS)
libcf_serverd_la_LIBADD = ../libpromises/libpromises.la
@@ -1,5 +1,7 @@
#include <platform.h>
+#include <openssl/bn.h> /* BN_* */
+
#include <cf3.defs.h>
#include <item_lib.h> /* IsMatchItemIn */
#include <matching.h> /* IsRegexItemIn */
View
@@ -26,6 +26,8 @@
#include <server_tls.h>
#include <server_common.h>
+#include <openssl/err.h> /* ERR_get_error */
+
#include <crypto.h> /* DecryptString */
#include <conversion.h>
#include <signals.h>
View
@@ -1,7 +1,8 @@
noinst_LTLIBRARIES = libcfnet.la
-AM_CPPFLAGS = -I$(top_srcdir)/libutils # platform.h
-AM_CPPFLAGS += -I$(top_srcdir)/libpromises # cf3.defs.h
+AM_CPPFLAGS = $(OPENSSL_CPPFLAGS)
+AM_CPPFLAGS += -I$(top_srcdir)/libutils # platform.h
+AM_CPPFLAGS += -I$(top_srcdir)/libpromises # cf3.defs.h
libcfnet_la_SOURCES = \
misc.c \
@@ -24,6 +24,8 @@
#include <client_protocol.h>
+#include <openssl/bn.h> /* BN_* */
+
#include <communication.h>
#include <net.h>
View
@@ -25,15 +25,21 @@
#include <cfnet.h>
+#include <openssl/err.h>
+#include <openssl/crypto.h>
+#include <openssl/ssl.h>
+
#include <logging.h>
#include <misc_lib.h>
#include <tls_client.h>
#include <tls_generic.h>
#include <net.h> /* SendTransaction, ReceiveTransaction */
/* TODO move crypto.h to libutils */
-#include <crypto.h> /* PRIVKEY,PUBKEY,LoadSecretKeys */
-#include <bootstrap.h> /* ReadPolicyServerFile */
+#include <crypto.h> /* LoadSecretKeys */
+
+
+extern RSA *PRIVKEY, *PUBKEY;
extern char CFWORKDIR[];
View
@@ -25,6 +25,10 @@
#include <cfnet.h>
+#include <openssl/err.h>
+#include <openssl/crypto.h>
+#include <openssl/ssl.h>
+
#include <logging.h> /* LogLevel */
#include <misc_lib.h>
View
@@ -29,6 +29,8 @@
#include <cfnet.h>
+#include <openssl/ssl.h>
+
#include <logging.h> /* LogLevel */
View
@@ -1,9 +1,6 @@
noinst_LTLIBRARIES = libcompat.la
-# platform.h is in libutils/
-# and unfortunately platform.h #inludes stuff from both openssl and pcre
-AM_CPPFLAGS = -I$(top_srcdir)/libutils \
- $(OPENSSL_CPPFLAGS) $(PCRE_CPPFLAGS)
+AM_CPPFLAGS = -I$(top_srcdir)/libutils # platform.h
libcompat_la_LIBADD = $(LTLIBOBJS)
View
@@ -11,7 +11,8 @@ if SOLARIS
libenv_la_LIBADD = -lkstat
endif
-AM_CPPFLAGS = -I$(top_srcdir)/libutils
+AM_CPPFLAGS = -I$(top_srcdir)/libutils
+AM_CPPFLAGS += $(OPENSSL_CPPFLAGS) # because libutils needs it
# Those dependencies are ought to go away ASAP
AM_CPPFLAGS += -I$(top_srcdir)/libcfnet
View
@@ -25,7 +25,12 @@
#ifndef CFENGINE_CONSTANTS_H
#define CFENGINE_CONSTANTS_H
-#include <cf3.defs.h>
+
+#include <platform.h>
+
+/* TODO libpromises depends on libenv, the opposite should not happen! */
+#include <eval_context.h>
+
void LoadSystemConstants(EvalContext *ctx);
View
@@ -26,7 +26,12 @@
#ifndef CFENGINE_UNIX_IFACE_H
#define CFENGINE_UNIX_IFACE_H
-#include <cf3.defs.h>
+
+#include <platform.h>
+
+/* TODO libpromises depends on libenv, the opposite should not happen! */
+#include <eval_context.h>
+
void GetInterfacesInfo(EvalContext *ctx);
View
@@ -33,7 +33,7 @@
#include <libxml/xpathInternals.h>
#endif
-#include <hash.h> /* Required for HashMethod */
+#include <hash_method.h> /* HashMethod */
#include <sequence.h>
#include <logging.h>
View
@@ -24,6 +24,10 @@
#include <crypto.h>
+#include <openssl/err.h> /* ERR_* */
+#include <openssl/rand.h> /* RAND_* */
+#include <openssl/bn.h> /* BN_* */
+
#include <cf3.defs.h>
#include <lastseen.h>
#include <files_interfaces.h>
View
@@ -26,6 +26,9 @@
#define CFENGINE_CRYPTO_H
#include <platform.h>
+
+#include <openssl/rsa.h>
+
#include <logging.h>
@@ -25,7 +25,7 @@
#ifndef CFENGINE_EVAL_CONTEXT_H
#define CFENGINE_EVAL_CONTEXT_H
-#include <cf3.defs.h>
+#include <platform.h>
#include <writer.h>
#include <set.h>
@@ -24,6 +24,9 @@
#include <files_hashes.h>
+#include <openssl/bn.h> /* BN_* */
+#include <openssl/evp.h> /* EVP_* */
+
#include <dbm_api.h>
#include <files_interfaces.h>
#include <client_code.h>
@@ -25,9 +25,9 @@
#ifndef CFENGINE_VAR_EXPRESSIONS_H
#define CFENGINE_VAR_EXPRESSIONS_H
-#include <string_expressions.h>
-
#include <platform.h>
+
+#include <string_expressions.h>
#include <policy.h>
typedef struct
View
@@ -13,7 +13,7 @@ libutils_la_SOURCES = \
atexit.c atexit.h \
compiler.h \
dir.h dir_priv.h \
- hashes.c hashes.h \
+ hashes.c hashes.h hash_method.h \
sequence.c sequence.h \
set.c set.h \
statistics.c statistics.h \
@@ -24,7 +24,7 @@ libutils_la_SOURCES = \
json.c json.h \
refcount.c refcount.h \
list.c list.h \
- logging.c logging.h logging_priv.h\
+ logging.c logging.h logging_priv.h \
buffer.c buffer.h \
ip_address.c ip_address.h \
map.c map.h map_common.h \
View
@@ -22,6 +22,11 @@
included file COSL.txt.
*/
+#include <platform.h>
+
+#include <openssl/evp.h> /* EVP_* */
+#include <openssl/bn.h> /* BN_bn2bin */
+
#include <alloc.h>
#include <logging.h>
#include <hash.h>
Oops, something went wrong.

0 comments on commit f080738

Please sign in to comment.