diff options
-rw-r--r-- | .gitignore | 4 | ||||
-rw-r--r-- | Makefile | 49 |
2 files changed, 53 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6b8407e --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +/.clang_complete +/.d +/prometheus-nano-exporter +/*.o diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..906031a --- /dev/null +++ b/Makefile @@ -0,0 +1,49 @@ +# enabled collectors + +COLLECTORS = +COLLECTORS += cpu +COLLECTORS += filesystem +COLLECTORS += hwmon +COLLECTORS += meminfo +COLLECTORS += network +COLLECTORS += textfile +COLLECTORS += uname + +# compile settings + +CFLAGS = -std=c11 -Os +LDFLAGS = -Os -s + +# build rules + +PROG = prometheus-nano-exporter +SRCS = main.c scrape.c util.c $(foreach c,$(COLLECTORS),$(c).c) +OBJS = $(patsubst %.c,%.o,$(SRCS)) + +DEPDIR := .d +$(shell mkdir -p $(DEPDIR) >/dev/null) +DEPFLAGS = -MT $@ -MMD -MP -MF $(DEPDIR)/$*.Td + +all: $(PROG) + +$(PROG): $(OBJS) + $(CC) -o $@ $^ $(LDFLAGS) $(LDLIBS) + +%.o : %.c +%.o : %.c $(DEPDIR)/%.d + $(CC) $(DEPFLAGS) $(CFLAGS) $(CPPFLAGS) -c -o $@ $< + @mv -f $(DEPDIR)/$*.Td $(DEPDIR)/$*.d && touch $@ + +# make clean + +.PHONY: clean +clean: + $(RM) $(PROG) $(OBJS) + $(RM) -r $(DEPDIR) + +# dependencies + +$(DEPDIR)/%.d: ; +.PRECIOUS: $(DEPDIR)/%.d + +include $(wildcard $(patsubst %,$(DEPDIR)/%.d,$(basename $(SRCS)))) |