+ifndef BIN_DIR\r
+BIN_DIR = "$(PWD)"\r
+endif\r
\r
-CONFIG_DIR = "conf.d"\r
-LOG_DIR = "log"\r
-PLUGINS_DIR = "plugins.d"\r
-\r
-COMMON_FLAGS = -DCONFIG_DIR='$(CONFIG_DIR)' -DLOG_DIR='$(LOG_DIR)' -DPLUGINS_DIR='$(PLUGINS_DIR)'\r
-\r
-ifdef debug\r
-CFLAGS = $(COMMON_FLAGS) -Wall -Wextra -ggdb\r
-else\r
-CFLAGS = $(COMMON_FLAGS) -Wall -Wextra -O3\r
+ifndef CONFIG_DIR\r
+CONFIG_DIR = "$(PWD)/conf.d"\r
endif\r
\r
-all: setuid\r
+ifndef LOG_DIR\r
+LOG_DIR = "$(PWD)/log"\r
+endif\r
\r
-bin: netdata plugins\r
+ifndef PLUGINS_DIR\r
+PLUGINS_DIR = "$(PWD)/plugins.d"\r
+endif\r
\r
-setuid: bin\r
- @echo\r
- @echo " >>> apps.plugin requires root access to access files in /proc"\r
- @echo " >>> Please authorize it!"\r
- @echo\r
- sudo chown root plugins.d/apps.plugin\r
- sudo chmod 4775 plugins.d/apps.plugin\r
+COMMON_FLAGS = BIN_DIR='$(BIN_DIR)' CONFIG_DIR='$(CONFIG_DIR)' LOG_DIR='$(LOG_DIR)' PLUGINS_DIR='$(PLUGINS_DIR)'\r
\r
-netdata: netdata.c\r
- $(CC) $(CFLAGS) -o netdata netdata.c -lpthread -lz\r
+ifdef debug\r
+COMMON_FLAGS += debug=1\r
+endif\r
\r
-plugins: plugins.d/apps.plugin\r
+ifdef nozlib\r
+COMMON_FLAGS += nozlib=1\r
+endif\r
\r
-plugins.d/apps.plugin: apps_plugin.c\r
- $(CC) $(CFLAGS) -o plugins.d/apps.plugin apps_plugin.c\r
+all:\r
+ $(MAKE) -C src $(COMMON_FLAGS) all\r
\r
clean:\r
- rm -f *.o netdata plugins.d/apps.plugin core\r
+ $(MAKE) -C src clean\r
+ -rm -f netdata netdata.old plugins.d/apps.plugin plugins.d/apps.plugin.old\r
+\r
+install:\r
+ $(MAKE) -C src $(COMMON_FLAGS) install\r
\r
getconf:\r
- wget -O conf.d/netdata.conf.new "http://localhost:19999/netdata.conf"\r
- mv conf.d/netdata.conf conf.d/netdata.conf.old\r
- mv conf.d/netdata.conf.new conf.d/netdata.conf\r
+ @wget -O conf.d/netdata.conf.new "http://localhost:19999/netdata.conf"; \\r
+ if [ $$? -eq 0 -a -s conf.d/netdata.conf.new ]; \\r
+ then \\r
+ mv conf.d/netdata.conf conf.d/netdata.conf.old; \\r
+ mv conf.d/netdata.conf.new conf.d/netdata.conf; \\r
+ fi\r
+\r
+.PHONY: all clean install getconf\r