]> git.draconx.ca Git - cdecl99.git/blob - glconfig.mk
Add note about old-style function declarations to the manual.
[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 AUTOMAKE_OPTIONS = nostdinc to Makefile.am (or equivalent).
9 #   * Ensure that -I$(top_builddir)/@GLSRC@ and -I$(top_builddir) are
10 #     listed in AM_CPPFLAGS (in that order).
11 #   * Pass the desired symbol prefix to DX_FIX_GNULIB in configure.ac.
12 #
13 # License WTFPL2: Do What The Fuck You Want To Public License, version 2.
14 # This is free software: you are free to do what the fuck you want to.
15 # There is NO WARRANTY, to the extent permitted by law.
16
17 GLCONFIG = @GLSRC@/config.h
18 GLCAT    = cat /dev/null
19
20 GLSYM_V   = $(GLSYM_V_$(V))
21 GLSYM_V_  = $(GLSYM_V_$(AM_DEFAULT_VERBOSITY))
22 GLSYM_V_0 = @echo "  GLSYM " $<;
23
24 gnulib_symfiles = $(gnulib_lt_objects:.lo=.glsym)
25 gnulib_src_headers += $(GLCONFIG)
26
27 # This suffix rule triggers symbol generation only on demand.  Dependencies are
28 # not tracked directly, so it must remain phony and thus not create the target.
29 .c.glsym:
30         $(GLSYM_V) $(MKDIR_P) $(@D)/.syms
31         $(AM_V_at) depfile=$(@D)/.syms/$(*F).deps \
32                 source=$< object=$(GLCONFIG) $(CCDEPMODE) \
33                 $(depcomp) $(COMPILE) -c -o $(@D)/.syms/$(*F).o $<
34         $(AM_V_at) $(SHELL) $(top_builddir)/exported.sh \
35                 $(@D)/.syms/$(*F).o > $(@D)/.syms/$(*F).sym
36 $(gnulib_symfiles): $(gnulib_core_headers)
37
38 clean-local: clean-glconfig
39 clean-glconfig:
40         @for sym in $(libgnu_la_SOURCES) $(EXTRA_libgnu_la_SOURCES); do \
41                 symdir=`expr "$$sym" : '\(.*/\)'`.syms; \
42                 if test -d "$$symdir"; then \
43                         echo "rm -rf $$symdir"; rm -rf "$$symdir"; \
44                 fi; \
45         done
46 .PHONY: clean-glconfig
47
48 # The config header requires compilation of all gnulib object files via the
49 # .glsym rule above.  However, it cannot depend on those build products
50 # directly because those compilations will include this header if it exists,
51 # which is (by definition) out of date when this rule gets triggered.
52 #
53 # Thus, we delete the header, then perform a recursive make call to regenerate
54 # the header, which can in turn parallelize the required compilation.
55 #
56 # Also delete the phony symbol files so the build doesn't fail badly if they
57 # got created somehow (for instance by make -t).
58 $(GLCONFIG): $(top_builddir)/config.h $(gnulib_core_headers)
59         -$(AM_V_at) rm -f $(gnulib_symfiles) $@.tmp $@
60         $(AM_V_at) $(MAKE) $(AM_MAKEFLAGS) glconfig-gen
61         $(AM_V_GEN) cat $(top_builddir)/config.h >> $@.tmp
62         $(AM_V_at) mv -f $@.tmp $@
63 CLEANFILES += $(GLCONFIG)
64
65 # The glconfig-gen target is intended only for use in recursive make
66 # invocations.
67 glconfig-gen: $(gnulib_symfiles)
68         $(AM_V_at) depfiles=; symfiles=; \
69         for sym in $(gnulib_symfiles); do \
70                 symdir=`expr "$$sym" : '\(.*/\)'`; \
71                 symfile=`expr "$$sym" : '.*/\(.*\)' || printf '%s\n' "$$sym"`; \
72                 symbase=$$symdir.syms/`expr "$$symfile" : '\(.*\)\..*'`; \
73                 test -f "$$symbase.deps" && \
74                         depfiles="$$depfiles $$symbase.deps"; \
75                 symfiles="$$symfiles $$symbase.sym"; \
76         done; \
77                 $(GLCAT) $$depfiles > @GLSRC@/$(DEPDIR)/glconfig.Ph && \
78                 $(GLCAT) $$symfiles | sed 's/.*/#define & $(GLSYM_PREFIX)&/' \
79                         > $(GLCONFIG).tmp
80 .PHONY: glconfig-gen
81
82 @AMDEP_TRUE@@am__include@ @am__quote@@GLSRC@/$(DEPDIR)/glconfig.Ph@am__quote@