]> git.draconx.ca Git - cdecl99.git/blob - glconfig.mk
Batch up crossparse tests to improve performance.
[cdecl99.git] / glconfig.mk
1 # Copyright © 2011 Nick Bowler
2 #
3 # Automake fragment to generate a Gnulib config header to rewrite exported
4 # symbols.  This fragment relies on the Gnulib makefile enhancements done by
5 # fix-gnulib.pl.  Furthermore, the following additional changes may be
6 # required:
7 #
8 #   * Add AM_PROC_CC_C_O to configure.ac
9 #   * Pass the desired symbol prefix to DX_FIX_GNULIB in configure.ac.
10 #
11 # License WTFPL2: Do What The Fuck You Want To Public License, version 2.
12 # This is free software: you are free to do what the fuck you want to.
13 # There is NO WARRANTY, to the extent permitted by law.
14
15 GLCONFIG = @GLSRC@/glconfig.h
16 GLCAT    = cat /dev/null
17
18 GLSYM_V   = $(GLSYM_V_$(V))
19 GLSYM_V_  = $(GLSYM_V_$(AM_DEFAULT_VERBOSITY))
20 GLSYM_V_0 = @echo "  GLSYM " $<;
21
22 gnulib_symfiles = $(gnulib_lt_objects:.lo=.glsym)
23 gnulib_src_headers += $(GLCONFIG)
24
25 # This suffix rule triggers symbol generation only on demand.  Dependencies are
26 # not tracked directly, so it must remain phony and thus not create the target.
27 .c.glsym:
28         $(GLSYM_V) $(MKDIR_P) $(@D)/.syms
29         $(AM_V_at) depfile=$(@D)/.syms/$(*F).deps \
30                 source=$< object=$(GLCONFIG) $(CCDEPMODE) \
31                 $(depcomp) $(COMPILE) -DNO_GLCONFIG \
32                 -c -o $(@D)/.syms/$(*F).o $<
33         $(AM_V_at) $(SHELL) $(top_builddir)/exported.sh \
34                 $(@D)/.syms/$(*F).o > $(@D)/.syms/$(*F).sym
35 $(gnulib_symfiles): $(gnulib_core_headers)
36
37 clean-local: clean-glconfig
38 clean-glconfig:
39         @for sym in $(libgnu_la_SOURCES) $(EXTRA_libgnu_la_SOURCES); do \
40                 symdir=`expr "$$sym" : '\(.*/\)'`.syms; \
41                 if test -d "$$symdir"; then \
42                         echo "rm -rf $$symdir"; rm -rf "$$symdir"; \
43                 fi; \
44         done
45 .PHONY: clean-glconfig
46
47 # The config header requires compilation of all gnulib object files via the
48 # .glsym rule above.  However, it cannot depend on those build products
49 # directly because they are phony, and would make this header never up-to-date.
50 #
51 # Thus, we use a recursive make call to regenerate the header, which avoids
52 # the need to list prerequisites.
53 #
54 # Since GNU make does not appear to allow the target of a suffix rule to be
55 # marked .PHONY, we also delete the .glsym files here just in case they were
56 # created for some reason (e.g., make -t).
57 $(GLCONFIG): $(gnulib_core_headers)
58         -$(AM_V_at) rm -f $(gnulib_symfiles)
59         $(AM_V_at) $(MAKE) $(AM_MAKEFLAGS) glconfig-gen
60         $(AM_V_GEN) mv -f $@.tmp $@
61 CLEANFILES += $(GLCONFIG)
62
63 # The glconfig-gen target is intended only for use in recursive make
64 # invocations.
65 glconfig-gen: $(gnulib_symfiles)
66         $(AM_V_at) depfiles=; symfiles=; \
67         for sym in $(gnulib_symfiles); do \
68                 symdir=`expr "$$sym" : '\(.*/\)'`; \
69                 symfile=`expr "$$sym" : '.*/\(.*\)' || printf '%s\n' "$$sym"`; \
70                 symbase=$$symdir.syms/`expr "$$symfile" : '\(.*\)\..*'`; \
71                 test -f "$$symbase.deps" && \
72                         depfiles="$$depfiles $$symbase.deps"; \
73                 symfiles="$$symfiles $$symbase.sym"; \
74         done; \
75                 $(GLCAT) $$depfiles > @GLSRC@/$(DEPDIR)/glconfig.Ph && \
76                 $(GLCAT) $$symfiles | sed 's/.*/#define & $(GLSYM_PREFIX)&/' \
77                         > $(GLCONFIG).tmp
78 .PHONY: glconfig-gen
79
80 @AMDEP_TRUE@@am__include@ @am__quote@@GLSRC@/$(DEPDIR)/glconfig.Ph@am__quote@