summaryrefslogtreecommitdiff
path: root/tools/d2c/d2c.mk
blob: 07313291ab770028f96a490f4a442387fe6f5088 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50

.NOTPARALLEL:

d2c_verbose = $(d2c_verbose_@AM_V@)
d2c_verbose_ = $(d2c_verbose_@AM_DEFAULT_V@)
d2c_verbose_0 = @echo "  D2C     " $<;

fix_verbose = $(fix_verbose_@AM_V@)
fix_verbose_ = $(fix_verbose_@AM_DEFAULT_V@)
fix_verbose_0 = echo "  FIX     " `basename $$f`;


# D2C_BIN =
# D2C_TYPE =
# D2C_OUTDIR =
# D2C_ARCH =
# D2C_HEADER =
# D2C_ENCODINGS =
# D2C_MACROS =
# D2C_PREFIX =

# FIXED_C_INCLUDES =
# FIXED_H_INCLUDES =


SUFFIXES = .g

.d.g:
	$(d2c_verbose)$(D2C_BIN) -i $< -t $(D2C_TYPE) -d $(D2C_OUTDIR) -a $(D2C_ARCH) -H $(D2C_HEADER) $(D2C_ENCODINGS) $(D2C_MACROS) -p $(D2C_PREFIX)
	@touch $@

d2c_final_rules: fix_includes_in_c_templates fix_includes_in_h_templates untabify_disass

fix_includes_in_c_templates:
	@for f in `find .gen/ -name '*tmpl.c'`; do			\
		if grep -q '##INCLUDES##' $$f; then				\
			$(fix_verbose)sed -i 's/##INCLUDES##/$(FIXED_C_INCLUDES)/' $$f;	\
		fi;												\
	done

fix_includes_in_h_templates:
	@for f in `find .gen/ -name '*tmpl.h'`; do			\
		if grep -q '##INCLUDES##' $$f; then				\
			$(fix_verbose)sed -i 's/##INCLUDES##/$(FIXED_H_INCLUDES)/' $$f ;	\
		fi;												\
	done

# Merci http://www.commandlinefu.com/commands/view/10276/grep-tab-t
untabify_disass:
	@find .gen/ -name '*[ch]' -exec grep -q $$'\t' {} \; -exec sed -i 's/\t/    /g' {} \;