cpprules.in revision 1ab64890
11ab64890Smrg#							-*- Makefile -*-
21ab64890Smrg# Rules for generating files using the C pre-processor
31ab64890Smrg# (Replaces CppFileTarget from Imake)
41ab64890Smrg
51ab64890SmrgSED = sed
61ab64890Smrg
71ab64890SmrgSUFFIXES = .pre
81ab64890Smrg
91ab64890SmrgWCHAR32_FLAGS = -DWCHAR32=@WCHAR32@
101ab64890Smrg
111ab64890SmrgCPP_FILES_FLAGS = $(WCHAR32_FLAGS)
121ab64890Smrg
131ab64890Smrg# Translate XCOMM into pound sign with sed, rather than passing -DXCOMM=XCOMM
141ab64890Smrg# to cpp, because that trick does not work on all ANSI C preprocessors.
151ab64890Smrg# Delete line numbers from the cpp output (-P is not portable, I guess).
161ab64890Smrg# Allow XCOMM to be preceded by whitespace and provide a means of generating
171ab64890Smrg# output lines with trailing backslashes.
181ab64890Smrg# Allow XHASH to always be substituted, even in cases where XCOMM isn't.
191ab64890Smrg
201ab64890SmrgCPP_SED_MAGIC = $(SED) -e '/^\#  *[0-9][0-9]*  *.*$$/d' \
211ab64890Smrg                       -e '/^\#line  *[0-9][0-9]*  *.*$$/d' \
221ab64890Smrg                       -e '/^[         ]*XCOMM$$/s/XCOMM/\#/' \
231ab64890Smrg                       -e '/^[         ]*XCOMM[^a-zA-Z0-9_]/s/XCOMM/\#/' \
241ab64890Smrg                       -e '/^[         ]*XHASH/s/XHASH/\#/' \
251ab64890Smrg                       -e '/\@\@$$/s/\@\@$$/\\/'
261ab64890Smrg
271ab64890Smrg# Allow people to comment out lines by starting them with '##'
281ab64890Smrg.pre:
291ab64890Smrg	$(SED) -e '/^\#\#/d' $< | $(RAWCPP) $(RAWCPPFLAGS) $(CPP_FILES_FLAGS) | $(CPP_SED_MAGIC) > $@
30