cpprules.in revision b4ee4795
1#							-*- Makefile -*-
2# Rules for generating files using the C pre-processor
3# (Replaces CppFileTarget from Imake)
4
5SED = sed
6
7SUFFIXES = .pre
8
9WCHAR32_FLAGS = -DWCHAR32=@WCHAR32@
10
11CPP_FILES_FLAGS = $(WCHAR32_FLAGS)
12
13# Translate XCOMM into pound sign with sed, rather than passing -DXCOMM=XCOMM
14# to cpp, because that trick does not work on all ANSI C preprocessors.
15# Delete line numbers from the cpp output (-P is not portable, I guess).
16# Allow XCOMM to be preceded by whitespace and provide a means of generating
17# output lines with trailing backslashes.
18# Allow XHASH to always be substituted, even in cases where XCOMM isn't.
19
20CPP_SED_MAGIC = $(SED) -e '/^\#  *[0-9][0-9]*  *.*$$/d' \
21                       -e '/^\#line  *[0-9][0-9]*  *.*$$/d' \
22                       -e '/^[         ]*XCOMM$$/s/XCOMM/\#/' \
23                       -e '/^[         ]*XCOMM[^a-zA-Z0-9_]/s/XCOMM/\#/' \
24                       -e '/^[         ]*XHASH/s/XHASH/\#/' \
25                       -e 's,X11_LOCALEDATADIR,$(X11_LOCALEDATADIR),g' \
26                       -e '/\@\@$$/s/\@\@$$/\\/'
27
28.pre:
29	$(AM_V_GEN)$(RAWCPP) $(RAWCPPFLAGS) $(CPP_FILES_FLAGS) < $< | $(CPP_SED_MAGIC) > $@
30