new makefiles
Costa Tsaousis (ktsaou) committed
Mar 16, 2015 at 22:12 UTC
4ccc4aa01d5b21e326008c8b526b2da3c6a78862
4 files changed
+126
-38
Makefile
new
+34
@@ -0,0 +1,34 @@
1
+ifndef BIN_DIR
2
+BIN_DIR = "$(PWD)"
3
+endif
4
+
5
+ifndef CONFIG_DIR
6
+CONFIG_DIR = "$(PWD)/conf.d"
7
+endif
8
+
9
+ifndef LOG_DIR
10
+LOG_DIR = "$(PWD)/log"
11
+endif
12
+
13
+ifndef PLUGINS_DIR
14
+PLUGINS_DIR = "$(PWD)/plugins.d"
15
+endif
16
+
17
+COMMON_FLAGS = BIN_DIR='$(BIN_DIR)' CONFIG_DIR='$(CONFIG_DIR)' LOG_DIR='$(LOG_DIR)' PLUGINS_DIR='$(PLUGINS_DIR)'
18
+
19
+ifdef debug
20
+COMMON_FLAGS += debug=1
21
+endif
22
+
23
+.PHONY: all
24
+all:
25
+ $(MAKE) -C src $(COMMON_FLAGS) all
26
+
27
+.PHONY: clean
28
+clean:
29
+ $(MAKE) -C src clean
30
+
31
+.PHONY: install
32
+install:
33
+ $(MAKE) -C src $(COMMON_FLAGS) install
34
+
netdata.start
+3
-12
@@ -19,7 +19,7 @@ NETDATA_CONFIG_INTERNAL_HISTORY_LINES=3600
19
NETDATA_CONFIG_USER=nobody
20
21
# set to 1, to enable debugging
22
-NETDATA_CONFIG_DEBUG=1
22
+NETDATA_CONFIG_DEBUG=0
23
24
# our port
25
NETDATA_CONFIG_PORT=19999
@@ -60,21 +60,12 @@ echo "Compiling netdata (debug=$NETDATA_CONFIG_DEBUG)"
60
if [ $NETDATA_CONFIG_DEBUG -eq 1 ]
61
then
62
ulimit -c unlimited
63
- cd src || exit 1
64
- make || exit 1
65
- cd plugins.d || exit 1
66
- make || exit 1
63
+ make install debug=1 # this installs in the current directory
64
debug_opts="-df 0xfffffadf"
65
else
69
- cd src || exit 1
70
- make final=1 || exit 1
71
- cd plugins.d || exit 1
72
- make final=1 || exit 1
66
+ make install # this installs in the current directory
67
debug_opts="-df 0x00000000"
68
fi
75
-cd ../../ || exit 1
76
-mv src/netdata ./ || exit 1
77
-mv src/plugins.d/apps.plugin plugins.d/ || exit 1
69
70
echo "Stopping a (possibly) running netdata..."
71
ret=0
src/Makefile
+44
-10
@@ -1,31 +1,65 @@
1
-# COMMON_FLAGS =
1
+ifndef BIN_DIR
2
+BIN_DIR = "$(PWD)"
3
+endif
4
5
+ifndef CONFIG_DIR
6
CONFIG_DIR = "conf.d"
7
+endif
8
+
9
+ifndef LOG_DIR
10
LOG_DIR = "log"
11
+endif
12
+
13
+ifndef PLUGINS_DIR
14
PLUGINS_DIR = "plugins.d"
15
+endif
16
7
-COMMON_FLAGS = -DCONFIG_DIR='$(CONFIG_DIR)' -DLOG_DIR='$(LOG_DIR)' -DPLUGINS_DIR='$(PLUGINS_DIR)'
17
+COMMON_FLAGS = BIN_DIR='$(BIN_DIR)' CONFIG_DIR='$(CONFIG_DIR)' LOG_DIR='$(LOG_DIR)' PLUGINS_DIR='$(PLUGINS_DIR)'
18
9
-ifdef final
10
-CFLAGS = -Wall -Wextra -O3 $(COMMON_FLAGS)
19
+ifdef debug
20
+COMMON_FLAGS += debug=1
21
+CFLAGS = -Wall -Wextra -ggdb -DBIN_DIR='$(BIN_DIR)' -DCONFIG_DIR='$(CONFIG_DIR)' -DLOG_DIR='$(LOG_DIR)' -DPLUGINS_DIR='$(PLUGINS_DIR)'
22
else
12
-CFLAGS = -Wall -Wextra -ggdb $(COMMON_FLAGS)
23
+CFLAGS = -Wall -Wextra -O3 -DBIN_DIR='$(BIN_DIR)' -DCONFIG_DIR='$(CONFIG_DIR)' -DLOG_DIR='$(LOG_DIR)' -DPLUGINS_DIR='$(PLUGINS_DIR)'
24
endif
25
15
-CC = gcc $(CFLAGS)
26
+CC = gcc
27
28
proc_sources = proc_net_dev.c proc_net_ip_vs_stats.c proc_diskstats.c proc_meminfo.c proc_net_netstat.c proc_net_snmp.c proc_net_stat_conntrack.c proc_stat.c proc_vmstat.c
29
sources = procfile.c common.c log.c popen.c url.c config.c web_buffer.c storage_number.c web_client.c global_statistics.c rrd.c rrd2json.c web_server.c plugins_d.c daemon.c plugin_tc.c plugin_checks.c plugin_idlejitter.c plugin_proc.c unit_test.c main.c
30
headers = $(patsubst %.c,%.h,$(sources))
31
objects = $(patsubst %.c,%.o,$(sources) $(proc_sources))
32
22
-all: netdata
33
+.PHONY: options
34
+options:
35
+ @echo " COMPILING WITH OPTIONS: $(CFLAGS)"
36
+
37
+all: options netdata plugins
38
39
netdata: $(objects)
25
- $(CC) -o netdata $(objects) -pthread -lz
40
+ @echo " $(CC) netdata"
41
+ @$(CC) -o netdata $(objects) -pthread -lz
42
+
43
+.PHONY: plugins
44
+plugins:
45
+ $(MAKE) -C plugins.d $(COMMON_FLAGS) all
46
47
%.o: %.c ${headers}
28
- $(CC) -c $< -o $@
48
+ @echo " $(CC) $<"
49
+ @$(CC) $(CFLAGS) -c $< -o $@
50
51
+.PHONY: clean
52
clean:
31
- rm -rfv *.o netdata core
53
+ $(MAKE) -C plugins.d clean
54
+ rm -f *.o netdata core
55
+
56
+install: all
57
+ $(MAKE) -C plugins.d $(COMMON_FLAGS) install
58
+ @echo; \
59
+ echo " INSTALLING netdata to $(BIN_DIR)"; \
60
+ if [ -f $(BIN_DIR)/netdata ]; \
61
+ then \
62
+ mv -f $(BIN_DIR)/netdata $(BIN_DIR)/netdata.old; \
63
+ fi; \
64
+ cp -f netdata $(BIN_DIR)/; \
65
+ echo
src/plugins.d/Makefile
+45
-16
@@ -1,37 +1,66 @@
1
+ifndef BIN_DIR
2
+BIN_DIR = "$(PWD)"
3
+endif
4
5
+ifndef CONFIG_DIR
6
CONFIG_DIR = "conf.d"
7
+endif
8
+
9
+ifndef LOG_DIR
10
LOG_DIR = "log"
11
+endif
12
+
13
+ifndef PLUGINS_DIR
14
PLUGINS_DIR = "plugins.d"
15
+endif
16
6
-COMMON_FLAGS = -DCONFIG_DIR='$(CONFIG_DIR)' -DLOG_DIR='$(LOG_DIR)' -DPLUGINS_DIR='$(PLUGINS_DIR)'
17
+COMMON_FLAGS = BIN_DIR='$(BIN_DIR)' CONFIG_DIR='$(CONFIG_DIR)' LOG_DIR='$(LOG_DIR)' PLUGINS_DIR='$(PLUGINS_DIR)'
18
+
19
+CC = gcc
20
21
ifdef debug
9
-CFLAGS = $(COMMON_FLAGS) -Wall -Wextra -ggdb
22
+COMMON_FLAGS += debug=1
23
+CFLAGS = -Wall -Wextra -ggdb -DBIN_DIR='$(BIN_DIR)' -DCONFIG_DIR='$(CONFIG_DIR)' -DLOG_DIR='$(LOG_DIR)' -DPLUGINS_DIR='$(PLUGINS_DIR)'
24
else
11
-CFLAGS = $(COMMON_FLAGS) -Wall -Wextra -O3
25
+CFLAGS = -Wall -Wextra -O3 -DBIN_DIR='$(BIN_DIR)' -DCONFIG_DIR='$(CONFIG_DIR)' -DLOG_DIR='$(LOG_DIR)' -DPLUGINS_DIR='$(PLUGINS_DIR)'
26
endif
27
14
-all: plugins
28
+.PHONY: options
29
+options:
30
+ @echo " COMPILING WITH OPTIONS: $(CFLAGS)"
31
+
32
+.PHONY: all
33
+all: options plugins
34
35
+.PHONY: plugins
36
plugins: apps.plugin
37
38
apps.plugin: apps_plugin.c
19
- @echo
20
- @echo "Compiling apps.plugin..."
21
- $(CC) $(CFLAGS) -o apps.plugin apps_plugin.c
22
- @-if [ ! "$$USER" = "root" ]; \
39
+ @echo " $(CC) $@"
40
+ @$(CC) $(CFLAGS) -o $@ apps_plugin.c
41
+
42
+clean:
43
+ -rm -f *.o apps.plugin core
44
+
45
+install: all
46
+ @echo; \
47
+ echo " INSTALLING apps.plugin to $(PLUGINS_DIR)"; \
48
+ if [ -f $(PLUGINS_DIR)/apps.plugin ]; \
49
+ then \
50
+ mv -f $(PLUGINS_DIR)/apps.plugin $(PLUGINS_DIR)/apps.plugin.old; \
51
+ fi; \
52
+ cp apps.plugin $(PLUGINS_DIR)/; \
53
+ if [ ! "$$USER" = "root" ]; \
54
then \
55
echo; \
56
echo " >>> apps.plugin requires root access to access files in /proc"; \
57
echo " >>> Please authorize it!"; \
58
echo; \
28
- sudo chown root apps.plugin; \
29
- sudo chmod 4775 apps.plugin; \
59
+ sudo chown root $(PLUGINS_DIR)/apps.plugin; \
60
+ sudo chmod 4775 $(PLUGINS_DIR)/apps.plugin; \
61
else \
31
- chown root apps.plugin; \
32
- chmod 4775 apps.plugin; \
33
- fi
34
-
62
+ chown root $(PLUGINS_DIR)/apps.plugin; \
63
+ chmod 4775 $(PLUGINS_DIR)/apps.plugin; \
64
+ fi; \
65
+ echo;
66
36
-clean:
37
- -rm -f *.o apps.plugin core