OSDN Git Service

Correct DLSYM attribute handling in msvcrt-xref.pdf
[mingw/mingw-org-wsl.git] / mingwrt / msvcrt-xref / Makefile.in
1 # @configure_input@
2 #
3 # $Id$
4 #
5 # Makefile to compile cross-reference documentation for the symbols
6 # exported by various versions of MSVCRT.DLL and MSVCRxx.DLL
7 #
8 # Written by Keith Marshall <keithmarshall@users.sourceforge.net>
9 # Copyright (C) 2014, 2015, 2016, 2020, MinGW.org Project.
10 #
11 #
12 # This is free software.  Permission is granted to copy, modify and
13 # redistribute this software, under the provisions of the GNU General
14 # Public License, Version 3, (or, at your option, any later version),
15 # as published by the Free Software Foundation; see the file COPYING.
16 # (If you have not received the file COPYING with this software, see
17 # <http://www.gnu.org/licenses/>).
18 #
19 # Note, in particular, that this software is provided "as is", in the
20 # hope that it may prove useful, but WITHOUT WARRANTY OF ANY KIND; not
21 # even an implied WARRANTY OF MERCHANTABILITY, nor of FITNESS FOR ANY
22 # PARTICULAR PURPOSE.  Under no circumstances will the author, or the
23 # MinGW.org Project, accept liability for any damages, however caused,
24 # arising from the use of this software.
25 #
26 #
27 # The default goal is "all"; declare it early, to ensure that it will not
28 # be inadvertently overridden, but defer assignment of its actual payload
29 # until until the mechanisms for generating it have been identified.
30 #
31 all:
32 srcdir = @srcdir@
33 VPATH = @srcdir@
34
35 MSG_NEED_GNU_TROFF = Please install the GNU Troff package
36 MSG_NEED_GHOSTSCRIPT = Please install GhostScript to produce PDF output
37
38 # MS-Windows OS platform specific versions of MSVCRT.DLL are identified
39 # by the following set of hexadecimal codes:--
40 #
41 #   NT4                         0x400UL
42 #   Win98                       0x410UL
43 #   Win98-SE                    0x412UL
44 #   Win2K                       0x500UL
45 #   WinXP                       0x501UL
46 #   Vista                       0x600UL
47 #   Win7                        0x601UL
48 #
49 msvcrt_platform_versions := 400 410 412 500 501 600 601
50
51 # The non-free MSVCRxx.DLL versions, as shipped with various versions of
52 # Visual-Studio/MSVC, are identified by the following hexadecimal codes:--
53 #
54 #   MSVCR70.DLL                 0x07000000UL
55 #   MSVCR71.DLL                 0x07100000UL
56 #   MSVCR80.DLL                 0x08000000UL
57 #   MSVCR90.DLL                 0x09000000UL
58 #   MSVCR100.DLL                0x10000000UL
59 #   MSVCR110.DLL                0x11000000UL
60 #   MSVCR120.DLL                0x12000000UL
61 #
62 msvcrt_nonfree_version_tags_1 := 70 71 80 90
63 msvcrt_nonfree_version_tags_2 := 100 110 120
64 msvcrt_nonfree_versions_1 := $(addsuffix 00000,$(msvcrt_nonfree_version_tags_1))
65 msvcrt_nonfree_versions_2 := $(addsuffix 00000,$(msvcrt_nonfree_version_tags_2))
66 msvcrt_nonfree_versions := $(foreach grp,1 2,$(msvcrt_nonfree_versions_$(grp)))
67
68 # We provide a README file, which we generate from the README.in template;
69 # it is formatted for online display by processing it with nroff.
70 #
71 NROFF = $(if @NROFF@,@NROFF@,$(error $(MSG_NEED_GNU_TROFF)))
72
73 all: README
74 README: README.in
75         printf '.pl 1\n.ll 72\n.hy 0\n' | $(NROFF) - $^ > $@
76
77 # The principal payload component is a printable cross-reference document,
78 # in either PDF (preferred when an appropriate generator is detected by the
79 # configure script) or Postscript format otherwise.  This lists all symbols
80 # which are exported by each of the MSVCRT.DLL and MSVCRxx.DLL variants of
81 # the C runtime libraries, and identifies the particular DLL versions in
82 # which each is present.
83 #
84 OUTPUT_FORMAT = @OUTPUT_FORMAT@
85
86 all: msvcrt-xref.$(OUTPUT_FORMAT)
87 platform_dlls := platform nonfree-1 nonfree-2
88 msvcrt-xref.$(OUTPUT_FORMAT): $(foreach p,$(platform_dlls),msvcrt-xref.$p.tbl)
89
90 # The first step, in generation of the cross-reference document, is to
91 # extract an unqualified list of all the symbols, regardless of whichever
92 # DLL versions provide them; this list is derived from a single composite
93 # template file, (filtered without regard to library version, and noting
94 # the special handling required for those symbols which are qualified
95 # by assignment of the __MINGW_DLSYM attribute).
96 #
97 SYMBOLS_AGGREGATOR := sed -n \
98   -e '1,/^EXPORTS/d' -e 's/^__MINGW_DLSYM(\([^)]*\)).*/\1/' \
99   -e '/^[A-Z_a-z]/p'
100
101 msvcrt.def.tbl: %.tbl: %.in
102         $(SYMBOLS_AGGREGATOR) $< > $@
103
104 # The full gamut of supported DLL versions is the aggregate of the platform
105 # specific MSVCRT.DLLs, and the non-free MSVCRxx.DLLs.
106 #
107 msvcrt_versions := $(msvcrt_platform_versions) $(msvcrt_nonfree_versions)
108
109 # For each of these MSVCRT.DLL and MSVCRxx.DLL versions, we use the
110 # C pre-processor to generate a version specific filtered symbols list,
111 # derived from the same composite template file from which the previous
112 # list, (non-specific to DLL version), was generated.
113 #
114 CC = @CC@
115 msvcrt.%.def: msvcrt.def.in
116         $(CC) -xc-header -E -P -D__MSVCRT_VERSION__=0x$*UL $< > $@
117
118 classify_symbols = while read symbol; \
119   do echo $$symbol%`grep -q "^$$symbol\\$$" $1 && echo Y || echo N`; \
120   done
121
122 msvcrt.%.tbl: msvcrt.%.def msvcrt.def.tbl
123         $(call classify_symbols,$<) < msvcrt.def.tbl > $@
124
125 # Having collected the symbols into individual per-library classification
126 # tables, we fold those together into documentation group tables.
127 #
128 msvcrt_xref_prerequisite = $(foreach p,$(msvcrt_$1_versions$2),msvcrt.$p.tbl)
129 msvcrt-xref.platform.tbl: $(call msvcrt_xref_prerequisite,platform)
130 msvcrt-xref.nonfree-1.tbl: $(call msvcrt_xref_prerequisite,nonfree,_1)
131 msvcrt-xref.nonfree-2.tbl: $(call msvcrt_xref_prerequisite,nonfree,_2)
132 msvcrt-xref.nonfree.tbl: $(call msvcrt_xref_prerequisite,nonfree)
133 msvcrt-xref.%.tbl:
134         cp msvcrt.def.tbl $@
135         for s in $^; do mv -f $@ $@.tmp && join -t% $@.tmp $$s > $@; done
136         $(if $(COMPACT_TABLES),mv -f $@ $@.tmp; sed -n '/%Y/p' $@.tmp > $@)
137         $(RM) $@.tmp
138
139 # Regardless of the chosen output format, the document source template
140 # must be processed using the pdfroff tool, from GNU troff...
141 #
142 GROFF = $(if @PDFROFF@,@PDFROFF@,$(error $(MSG_NEED_GNU_TROFF)))
143 GROFF_FORMAT_FLAGS = --no-toc-relocation -mpdfmark @GROFF_FORMAT@
144 #
145 # ...with the appropriate option to curtail post-processing of intermediate
146 # groff postscript output, when that is the chosen final output format.
147 #
148 %.ps: %.ms
149         $(GROFF) -st -I ${srcdir} -ms $(GROFF_FORMAT_FLAGS) --emit-ps $< > $@
150
151 # When postscript output already exists, then we may simply post-process
152 # it with GhostScript, to subsequently produce PDF output...
153 #
154 GS = $(if @GS@,@GS@,$(error $(MSG_NEED_GHOSTSCRIPT)))
155 GSFLAGS = @GSFLAGS@
156
157 %.pdf: %.ps
158         $(GS) $(GSFLAGS) -sDEVICE=pdfwrite -sOutputFile="$@" $<
159
160 # ...but, in the normal case, we may simply use pdfroff to produce PDF
161 # output directly, without capturing intermediate postscript.
162 #
163 POST_PDFROFF = $(if @GS@,@PDFROFF@,$(error $(MSG_NEED_GHOSTSCRIPT)))
164 PDFROFF = $(if @PDFROFF@,$(POST_PDFROFF),$(error $(MSG_NEED_GNU_TROFF)))
165
166 %.pdf: %.ms
167         $(PDFROFF) -st -I ${srcdir} -ms $(GROFF_FORMAT_FLAGS) $< > $@
168
169 # Rules to force a rebuild of the PDF or postscript output, in either
170 # simplex or duplex printer ready layout format.
171 #
172 .PHONY: publication-clean
173 publication-clean:
174         $(RM) msvcrt-xref*.ps msvcrt-xref*.pdf
175
176 simplex: publication-clean
177         $(MAKE) --no-print-directory $(MAKEFLAGS) all
178
179 duplex: publication-clean
180         $(MAKE) --no-print-directory $(MAKEFLAGS) $(GROFF_DUPLEX_FLAGS) all
181
182 GROFF_DUPLEX_FLAGS = GROFF_FORMAT_FLAGS='$(GROFF_FORMAT_FLAGS) -$@=on'
183
184 # Clean-up rules: discard generated files.
185 #
186 clean mostlyclean:
187         $(RM) *.def *.tbl msvcrt-xref*.ps msvcrt-xref*.pdf
188
189 distclean: clean
190         $(RM) -r autom4te.cache build dist
191         $(RM) config.*
192
193 # $RCSfile$: end of file