diff --git a/Makefile b/Makefile index 597924451..42da15288 100644 --- a/Makefile +++ b/Makefile @@ -45,7 +45,6 @@ V ?= 2 # Common flags LDLIBS = CFLAGS += -I. -Iinclude -Iinclude/villas -CFLAGS += @$(BUILDDIR)/defines CFLAGS += -std=c11 -MMD -mcx16 CFLAGS += -Wall -Werror -fdiagnostics-color=auto LDFLAGS += -L$(BUILDDIR) @@ -124,29 +123,17 @@ everything: %/: mkdir -p $@ -define DEFINES --DV=$(V) +escape = $(shell echo $1 | tr a-z- A-Z_ | tr -dc ' A-Z0-9_') --DPLUGIN_PATH=\"$(PREFIX)/share/villas/node/plugins\" --DWEB_PATH=\"$(PREFIX)/share/villas/node/web\" --DSYSFS_PATH=\"/sys\" --DPROCFS_PATH=\"/proc\" --DBUILDID=\"$(VERSION)-$(GIT_REV)-$(VARIANT)\" - --D_POSIX_C_SOURCE=200809L --D_GNU_SOURCE=1 -endef -export DEFINES - -$(BUILDDIR)/defines: | $$(dir $$@) - echo "$${DEFINES}" > $@ - echo -e "$(addprefix \n-DWITH_, $(shell echo ${PKGS} | tr a-z- A-Z_ | tr -dc ' A-Z0-9_' ))" >> $@ - echo -e "$(addprefix \n-DWITH_, $(shell echo ${LIB_PKGS} | tr a-z- A-Z_ | tr -dc ' A-Z0-9_' ))" >> $@ +CFLAGS += -DV=$(V) -DPREFIX=\"$(PREFIX)\" +CFLAGS += -DBUILDID=\"$(VERSION)-$(GIT_REV)-$(VARIANT)\" +CFLAGS += -D_POSIX_C_SOURCE=200809L -D_GNU_SOURCE=1 +CFLAGS += $(addprefix -DWITH_, $(call escape,$(PKGS))) install: $(addprefix install-,$(filter-out thirdparty doc clients,$(MODULES))) -clean: $(addprefix clean-,$(filter-out thirdparty doc clients,$(MODULES))) +clean: $(addprefix clean-, $(filter-out thirdparty doc clients,$(MODULES))) -.PHONY: all everything clean install +.PHONY: all everything clean install FORCE -include $(wildcard $(BUILDDIR)/**/*.d) -include $(addsuffix /Makefile.inc,$(MODULES)) diff --git a/config.h b/config.h index 9ee2d128e..4a30d2ef1 100644 --- a/config.h +++ b/config.h @@ -26,6 +26,12 @@ #pragma once +/* Paths */ +#define PLUGIN_PATH PREFIX "/share/villas/node/plugins" +#define WEB_PATH PREFIX "/share/villas/node/web" +#define SYSFS_PATH "/sys" +#define PROCFS_PATH "/proc" + /** Default number of values in a sample */ #define DEFAULT_SAMPLELEN 64 #define DEFAULT_QUEUELEN 1024 diff --git a/lib/Makefile.inc b/lib/Makefile.inc index 8287b49ac..7b6fb91c2 100644 --- a/lib/Makefile.inc +++ b/lib/Makefile.inc @@ -32,8 +32,10 @@ LIB_CFLAGS = $(CFLAGS) -fPIC -include $(patsubst %, lib/Makefile.%.inc, $(SONAMES)) +LIB_CFLAGS += $(addprefix -DWITH_, $(call escape,$(LIB_PKGS))) + # Compile -$(BUILDDIR)/lib/%.o: lib/%.c $(BUILDDIR)/defines | $$(dir $$@) +$(BUILDDIR)/lib/%.o: lib/%.c | $$(dir $$@) $(CC) $(LIB_CFLAGS) -c $< -o $@ lib: $(patsubst %, lib%, $(SONAMES))