AUTOGENERATED:=src/cfgparse.tab.c src/cfgparse.yy.c
FILES:=$(filter-out $(AUTOGENERATED),$(wildcard src/*.c))
FILES:=$(FILES:.c=.o)
-HEADERS=$(wildcard include/*.h)
+HEADERS:=$(filter-out include/loglevels.h,$(wildcard include/*.h))
# Depend on the specific file (.c for each .o) and on all headers
src/%.o: src/%.c ${HEADERS}
echo "CC $<"
- $(CC) $(CFLAGS) -c -o $@ $<
+ $(CC) $(CFLAGS) -DLOGLEVEL="(1 << $(shell awk '/$(shell basename $< .c)/ { print NR }' loglevels.tmp))" -c -o $@ $<
-all: src/cfgparse.y.o src/cfgparse.yy.o ${FILES}
+all: loglevels.h src/cfgparse.y.o src/cfgparse.yy.o ${FILES}
echo "LINK i3"
$(CC) -o i3 ${FILES} src/cfgparse.y.o src/cfgparse.yy.o $(LDFLAGS)
echo ""
echo "SUBDIR i3-input"
$(MAKE) TOPDIR=$(TOPDIR) -C i3-input
+rm_loglevels:
+ rm -f loglevels.h
+
+loglevels.h: rm_loglevels
+ echo "LOGLEVELS"
+ for file in $$(ls src/*.c src/*.y src/*.l | grep -v 'cfgparse.\(tab\|yy\).c'); \
+ do \
+ echo $$(basename $$file .c); \
+ done > loglevels.tmp
+ (echo "char *loglevels[] = {"; for file in $$(cat loglevels.tmp); \
+ do \
+ echo -e "\t\"$$file\", "; \
+ done; \
+ echo "};") > include/loglevels.h
+
src/cfgparse.yy.o: src/cfgparse.l
echo "LEX $<"
flex -i -o$(@:.o=.c) $<
- $(CC) $(CFLAGS) -c -o $@ $(@:.o=.c)
+ $(CC) $(CFLAGS) -DLOGLEVEL="(1 << $(shell awk '/cfgparse.l/ { print NR }' loglevels.tmp))" -c -o $@ $(@:.o=.c)
src/cfgparse.y.o: src/cfgparse.y
echo "YACC $<"
bison --debug --verbose -b $(basename $< .y) -d $<
- $(CC) $(CFLAGS) -c -o $@ $(<:.y=.tab.c)
+ $(CC) $(CFLAGS) -DLOGLEVEL="(1 << $(shell awk '/cfgparse.y/ { print NR }' loglevels.tmp))" -c -o $@ $(<:.y=.tab.c)
install: all
echo "INSTALL"