blob: 638f43c64c6138b18da2334826e7e0afa5eb7981 [file] [log] [blame]
default: all
SHELL=/bin/bash
# cc -E tries to guess by extension what to do with the file.
# And it does other weird things. cpp seems to Just Work(tm), so use that for
# our C# (.cs) files
CSCPP=cpp
# Rules for generating autodependencies on header files
$(patsubst %.cs.E,%.d,$(filter %.cs.E,$(FILES))): %.d: %.cs
@echo Generating dependency file $@ for $<
@set -e; set -o pipefail; rm -f $@; (\
($(CSCPP) -M -MM -MQ '$@' $(CPPFLAGS) $< && echo Makefile) \
| paste -s -d ' ' - && \
$(CSCPP) -M -MM -MQ '$<'.E $(CPPFLAGS) $< \
) > $@ \
|| (rm -f $@ && echo "Error generating dependency file." && exit 1)
include $(patsubst %.cs.E,%.d,$(filter %.cs.E,$(FILES)))
# Rule for actually preprocessing source files with headers
%.cs.E: %.cs
@rm -f $@
set -o pipefail; $(CSCPP) $(CPPFLAGS) -C -dI $< \
| expand -8 \
| sed -e 's,^#include,//#include,' \
| grep -v '^# [0-9]' \
>$@ || (rm -f $@ && exit 1)