makefile cleanups; math is enabled by default - added make flags nomath=1 to disable math
Costa Tsaousis (ktsaou) committed
Mar 19, 2015 at 22:38 UTC
e5683d1b701edb7dbdbcd0130501663947d0ecda
4 files changed
+24
-24
Makefile
+2
-4
@@ -20,20 +20,16 @@ ifdef debug
20
COMMON_FLAGS += debug=1
21
endif
22
23
-.PHONY: all
23
all:
24
$(MAKE) -C src $(COMMON_FLAGS) all
25
27
-.PHONY: clean
26
clean:
27
$(MAKE) -C src clean
28
-rm -f netdata netdata.old plugins.d/apps.plugin plugins.d/apps.plugin.old
29
32
-.PHONY: install
30
install:
31
$(MAKE) -C src $(COMMON_FLAGS) install
32
36
-.PHONY: getconf
33
getconf:
34
@wget -O conf.d/netdata.conf.new "http://localhost:19999/netdata.conf"; \
35
if [ $$? -eq 0 -a -s conf.d/netdata.conf.new ]; \
@@ -41,3 +37,5 @@ getconf:
37
mv conf.d/netdata.conf conf.d/netdata.conf.old; \
38
mv conf.d/netdata.conf.new conf.d/netdata.conf; \
39
fi
40
+
41
+.PHONY: all clean install getconf
src/Makefile
+14
-10
@@ -14,6 +14,10 @@ ifndef PLUGINS_DIR
14
PLUGINS_DIR = "plugins.d"
15
endif
16
17
+ifndef nomath
18
+STORAGE_WITH_MATH = 1
19
+endif
20
+
21
COMMON_FLAGS = BIN_DIR='$(BIN_DIR)' CONFIG_DIR='$(CONFIG_DIR)' LOG_DIR='$(LOG_DIR)' PLUGINS_DIR='$(PLUGINS_DIR)'
22
23
ifdef debug
@@ -30,6 +34,7 @@ sources = procfile.c common.c log.c popen.c url.c config.c web_buffer.c storage_
34
libs = -pthread -lz
35
36
ifdef STORAGE_WITH_MATH
37
+CFLAGS += -DSTORAGE_WITH_MATH=1
38
libs += -lm
39
endif
40
@@ -43,25 +48,22 @@ endif
48
headers = $(patsubst %.c,%.h,$(sources))
49
objects = $(patsubst %.c,%.o,$(sources) $(proc_sources))
50
46
-.PHONY: options
47
-options:
48
- @echo " COMPILING WITH OPTIONS: $(CFLAGS)"
51
+all: show_options netdata plugins
52
50
-all: options netdata plugins
53
+%.o: %.c ${headers}
54
+ @echo " $(CC) $<"
55
+ @$(CC) $(CFLAGS) -c $< -o $@
56
57
netdata: $(objects)
58
@echo " $(CC) netdata"
59
@$(CC) -o netdata $(objects) $(libs)
60
56
-.PHONY: plugins
61
+show_options:
62
+ @echo " COMPILING WITH OPTIONS: $(CFLAGS)"
63
+
64
plugins:
65
$(MAKE) -C plugins.d $(COMMON_FLAGS) all
66
60
-%.o: %.c ${headers}
61
- @echo " $(CC) $<"
62
- @$(CC) $(CFLAGS) -c $< -o $@
63
-
64
-.PHONY: clean
67
clean:
68
$(MAKE) -C plugins.d clean
69
rm -f *.o netdata core
@@ -76,3 +78,5 @@ install: all
78
fi; \
79
cp -f netdata $(BIN_DIR)/; \
80
echo
81
+
82
+.PHONY: all show_options plugins clean install
src/plugins.d/Makefile
+3
-5
@@ -25,14 +25,11 @@ else
25
CFLAGS = -Wall -Wextra -O3 -DBIN_DIR='$(BIN_DIR)' -DCONFIG_DIR='$(CONFIG_DIR)' -DLOG_DIR='$(LOG_DIR)' -DPLUGINS_DIR='$(PLUGINS_DIR)'
26
endif
27
28
-.PHONY: options
28
+all: options plugins
29
+
30
options:
31
@echo " COMPILING WITH OPTIONS: $(CFLAGS)"
32
32
-.PHONY: all
33
-all: options plugins
34
-
35
-.PHONY: plugins
33
plugins: apps.plugin
34
35
apps.plugin: apps_plugin.c
@@ -64,3 +61,4 @@ install: all
61
fi; \
62
echo;
63
64
+.PHONY: options all plugins clean install
src/unit_test.c
+5
-5
@@ -8,7 +8,7 @@
8
#include "log.h"
9
#include "web_buffer.h"
10
11
-#define ACCURACY_LOSS 100.0000001
11
+#define ACCURACY_LOSS 0.0000001
12
13
int check_storage_number(calculated_number n, int debug) {
14
char buffer[100];
@@ -31,14 +31,14 @@ int check_storage_number(calculated_number n, int debug) {
31
fprintf(stderr,
32
CALCULATED_NUMBER_FORMAT " original\n"
33
CALCULATED_NUMBER_FORMAT " packed and unpacked, (stored as 0x%08X, diff " CALCULATED_NUMBER_FORMAT ", " CALCULATED_NUMBER_FORMAT "%%)\n"
34
- "%s printed after unpacked (%lu bytes)\n"
34
+ "%s printed after unpacked (%zu bytes)\n"
35
CALCULATED_NUMBER_FORMAT " re-parsed from printed (diff " CALCULATED_NUMBER_FORMAT ", " CALCULATED_NUMBER_FORMAT "%%)\n\n",
36
n,
37
d, s, ddiff, dcdiff,
38
buffer,
39
len, p, pdiff, pcdiff
40
);
41
- if(len != strlen(buffer)) fprintf(stderr, "ERROR: printed number %s is reported to have length %lu but it has %lu\n", buffer, len, strlen(buffer));
41
+ if(len != strlen(buffer)) fprintf(stderr, "ERROR: printed number %s is reported to have length %zu but it has %zu\n", buffer, len, strlen(buffer));
42
if(dcdiff > ACCURACY_LOSS) fprintf(stderr, "WARNING: packing number " CALCULATED_NUMBER_FORMAT " has accuracy loss %0.7Lf %%\n", n, dcdiff);
43
if(pcdiff > ACCURACY_LOSS) fprintf(stderr, "WARNING: re-parsing the packed, unpacked and printed number " CALCULATED_NUMBER_FORMAT " has accuracy loss %0.7Lf %%\n", n, pcdiff);
44
}
@@ -63,8 +63,8 @@ void benchmark_storage_number(int loop, int multiplier) {
63
64
// ------------------------------------------------------------------------
65
66
- fprintf(stderr, "SYSTEM LONG DOUBLE SIZE: %lu bytes\n", sizeof(calculated_number));
67
- fprintf(stderr, "NETDATA FLOATING POINT SIZE: %lu bytes\n", sizeof(storage_number));
66
+ fprintf(stderr, "SYSTEM LONG DOUBLE SIZE: %zu bytes\n", sizeof(calculated_number));
67
+ fprintf(stderr, "NETDATA FLOATING POINT SIZE: %zu bytes\n", sizeof(storage_number));
68
69
mine = (calculated_number)sizeof(storage_number) * (calculated_number)loop;
70
their = (calculated_number)sizeof(calculated_number) * (calculated_number)loop;