-
Notifications
You must be signed in to change notification settings - Fork 54
/
Mmake.common.in
551 lines (460 loc) · 20 KB
/
Mmake.common.in
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
#-----------------------------------------------------------------------------#
# vim: ts=8 sw=8 noexpandtab ft=make
#-----------------------------------------------------------------------------#
# Copyright (C) 1995-2006, 2009-2012 The University of Melbourne.
# Copyright (C) 2013-2014, 2016-2017, 2019-2020, 2022-2024 The Mercury team.
# This file may only be copied under the terms of the GNU General
# Public Licence - see the file COPYING in the Mercury distribution.
#-----------------------------------------------------------------------------#
# Mmake.common - this is the part of the makefiles for building the Mercury
# implementation that is shared between all the subdirectories. It also
# contains all the parameters that might need to be modified when installing
# Mercury on a new machine.
# These parameters should all be determined automatically by `configure'.
# Any definitions in the Mmake.params file take precedence over the
# definitions here, so if you want to change one of the values here
# it is best to just add a definition to Mmake.params.
#-----------------------------------------------------------------------------#
include $(MERCURY_DIR)/VERSION
# The rpath for the libraries needs to be set to the final installation
# directory, not $(MERCURY_DIR)/runtime etc.
SET_RPATH=no
# This affects the tools set in Mmake.workspace so must be set first.
CROSS_COMPILING=@CROSS_COMPILING@
WORKSPACE=$(MERCURY_DIR)
include $(MERCURY_DIR)/Mmake.workspace
#-----------------------------------------------------------------------------#
# The host triplet is used to configure libatomic_ops.
FULLARCH=@FULLARCH@
# Specify a C compiler to build executables that can be executed on the build
# system itself, as part of the Boehm GC build process. The name is confusing
# because it conflicts with the autoconf meaning of "host", but it comes from
# upstream.
HOSTCC=@BUILD_C_PROGS_FOR_BUILD_SYSTEM@
#-----------------------------------------------------------------------------#
# Specify the Mercury compiler to use for bootstrapping.
MC = @BOOTSTRAP_MC_COMPILER@
# Specify the compilation model to use for compiling the compiler.
GRADE = @GRADE@
# Specify EXT_FOR_EXE is `.exe' on MS-Windows and empty elsewhere.
EXT_FOR_EXE = @EXT_FOR_EXE@
# Specify EXT_FOR_SHARED_LIB as `so' if the operating system
# supports `.so' shared libraries,
# `.dll' if it supports DLLs,
# or as `a' if it doesn't.
EXT_FOR_SHARED_LIB = @EXT_FOR_SHARED_LIB@
# Specify USE_DLLs as `yes' if the OS supports Windows-style DLLs.
USE_DLLS = @USE_DLLS@
# Specify any special flags to pass to the C compiler when creating objects
# for a shared library (e.g. -fpic or -fPIC for gcc).
CFLAGS_FOR_PIC = @CFLAGS_FOR_PIC@
# Specify EXT_FOR_PIC_OBJECTS as `pic_o' if any special $(PIC) flags are
# required (see above), and as `o' otherwise. This is used to ensure that
# we don't bother to build the .pic_o files if $(PIC) is null, since we can
# just reuse the .o files.
EXT_FOR_PIC_OBJECTS = @EXT_FOR_PIC_OBJECTS@
# Specify the Mmake command to link a shared library.
# This is only used if EXT_FOR_SHARED_LIB was defined as `so' above.
# This command may reference $(SO_LOCATIONS_DIR).
#
# LINK_SHARED_OBJ = gcc -shared # for Solaris etc.
LINK_SHARED_OBJ = @LINK_SHARED_OBJ@
# This is the same as LINK_SHARED_OBJ except that it
# specifies a Bourne shell command rather than an Mmake command,
# so if it references the SO_LOCATIONS_DIR variable it must use
# ${SO_LOCATIONS_DIR} rather than $(SO_LOCATIONS_DIR).
LINK_SHARED_OBJ_SH = @LINK_SHARED_OBJ_SH@
# The following variables specify options to $LINK_SHARED_OBJ to
# allow/disallow unresolved symbols when building shared libraries.
ALLOW_UNDEFINED = @ALLOW_UNDEFINED@
ERROR_UNDEFINED = @ERROR_UNDEFINED@
# The thread-safe version of the Boehm GC library links in lots
# of system-specific libraries that we don't want to have to
# explicitly link in when building the Mercury shared libraries,
# so override ERROR_UNDEFINED in that case.
ifeq "$(findstring .par,$(GRADE))$(findstring .gc,$(GRADE))" ".par.gc"
ERROR_UNDEFINED = $(ALLOW_UNDEFINED)
endif
# Specify any options required when linking if AddressSanitizer and other
# sanitizers are enabled.
LDFLAGS_FOR_SANITIZERS = @LDFLAGS_FOR_SANITIZERS@
# The following variables specify how to pass options to the $(CC) or
# $(LINK_SHARED_OBJ) command to specify directories to be searched at
# runtime for shared libraries.
# Normally RPATH_OPT is either "-R" or "-rpath ", but you may need to
# do something special to get the C compiler to pass this option on
# to the linker (e.g. with gcc you can use "-Wl,-rpath,").
# RPATH_SEP is a path separator; normally either ":"
# or just RPATH_OPT with a space in front of it.
# The SHLIB_ versions are used when linking shared libraries
# (perhaps invoking ld directly, rather than via the C compiler).
# The EXE_ versions are used when linking executables.
# The empty single quote pairs below are there to ensure that `make'
# does not throw away any important trailing or leading whitespace.
SHLIB_RPATH_OPT = @SHLIB_RPATH_OPT@''
SHLIB_RPATH_SEP = ''@SHLIB_RPATH_SEP@''
EXE_RPATH_OPT = @EXE_RPATH_OPT@''
EXE_RPATH_SEP = ''@EXE_RPATH_SEP@''
# These variables can be used to set the install-name for the mercury
# shared libraries on systems that use the install-name option (such as
# Darwin).
SHLIB_USE_INSTALL_NAME = @SHLIB_USE_INSTALL_NAME@
SHLIB_INSTALL_NAME_FLAG = @SHLIB_INSTALL_NAME_FLAG@''
# Specify any extra libraries that must be linked in when linking shared
# objects.
SHARED_LIBS = @SHARED_LIBS@
# Set the installation prefix. This is done here as well as
# in scripts/Mmake.vars to avoid accidentally overwriting an
# existing installation when using an installed mmake.
ifeq ($(DESTDIR),)
# DESTDIR is the empty string, DESTDIR_AND_SLASH must therefore
# be empty. Otherwise, the slash can change a relative path
# into an absolute one; or on Windows, it can create an invalid
# path name.
DESTDIR_AND_SLASH=
else
# We cannot append paths like this in Windows, but we don't think
# anyone will use DESTDIR on Windows.
DESTDIR_AND_SLASH=$(DESTDIR)/
endif
INSTALL_PREFIX = $(DESTDIR_AND_SLASH)@prefix@
FINAL_INSTALL_PREFIX = @prefix@
INSTALLABLE_PREFIX = @INSTALLABLE_PREFIX@
#-----------------------------------------------------------------------------#
INSTALL_MERC_GC_LIB_DIR = $(INSTALL_MERC_GRADELESS_LIB_DIR)
FINAL_INSTALL_MERC_GC_LIB_DIR = $(FINAL_INSTALL_MERC_GRADELESS_LIB_DIR)
# By default, GRADESTRING is defined as the result of invoking
# `mmc --output-grade-string' with $(GRADE) and $(GRADEFLAGS).
# But when installing the standard library, the compiler will not yet
# have been installed. So we need to define GRADESTRING here, in a way
# that doesn't require invoking mmc.
#
# Note that the definition below does _not_ include GRADEFLAGS.
# So any changes to the grade flags for the standard library or
# compiler itself should be done by setting GRADE, not GRADEFLAGS.
GRADESTRING = $(shell $(SCRIPTS_DIR)/canonical_grade $(ALL_GRADEFLAGS))
# Options to pass to the Mercury compiler
# now included in FLAGS files
# MCFLAGS += --no-infer-all --halt-at-warn --no-warn-inferred-erroneous
# Options to pass to the C compiler when building Boehm-GC.
BOEHM_CFLAGS = @ENABLE_BOEHM_LARGE_CONFIG@ \
@ENABLE_BOEHM_USE_MMAP@ \
@ENABLE_BOEHM_USE_MUNMAP@ \
@ENABLE_BOEHM_XOPEN_SOURCE@ \
@BOEHM_NO_GETCONTEXT@ \
@BOEHM_HAVE_DL_ITERATE_PTR@
# Additional options to pass to the C compiler when building Boehm-GC for
# threads.
#
BOEHM_CFLAGS_FOR_THREADS = @BOEHM_CFLAGS_FOR_THREADS@ \
@ENABLE_BOEHM_THREAD_LOCAL_ALLOC@ \
@ENABLE_BOEHM_PARALLEL_MARK@
# The CPU type to pass via the "cpu" argument of boehm_gc/NT_MAKEFILE.
# (This is only relevant when using MSVC.)
BOEHM_WINDOWS_CPU_TYPE = @BOEHM_WINDOWS_CPU_TYPE@
# Do we want to deal with intermodule information when building the library?
# By default yes, since this way we note immediately when intermodule
# optimization breaks, and always at installation time, since we must install
# the library's .opt and .trans_opt files as well. However, during development
# some problems are easier to track down without intermodule optimization
# complicating things.
# Some test cases assume that the library is compiled intermodule optimization,
# so it is not a good idea to disable it in a bootcheck.
LIBRARY_INTERMODULE = yes
# Do we want to compile the library with --trace minimum?
# By default yes, since the library is pretty well debugged. However,
# when it is being modified, it may have bugs we may want to chase down,
# so we allow the user to override this by setting LIBRARY_TRACE_MINIMUM to no.
# However, the test cases assume that the library is compiled with --trace
# minimum, so if you do that, expect test case failures in the debugger
# directory.
LIBRARY_TRACE_MINIMUM = yes
# Enable building of the deep profiler?
# The value of ENABLE_DEEP_PROFILER is either yes or no.
ENABLE_DEEP_PROFILER=@ENABLE_DEEP_PROFILER@
# Making the tags file for a directory containing Mercury source files
# requires giving mmake access to the list of source files in the directory.
# We normally do this by having the programs' and/or libraries .dv files
# define make variables such as "mer_std.ms".
#
# Mmc --make does not create .dv files, so these make variable don't get
# defined. The resulting invocation of mtags with an empty argument list
# (the default value of an undefined make variable) would yield an error.
ifeq ($(MMAKE_USE_MMC_MAKE),yes)
TAGS_FILE_EXISTS =
else
ifdef ALWAYS_MMAKE_TAGS_FILE
TAGS_FILE_EXISTS = tags_file_exists
else
TAGS_FILE_EXISTS =
endif
endif
#-----------------------------------------------------------------------------#
INSTALL_INFO=@INSTALL_INFO@
INFO=@INFO@
TEXI2DVI=@TEXI2DVI@
DVIPS=@DVIPS@
PDFTEX=@PDFTEX@
MAKEINFO=@MAKEINFO@
LYNX=@LYNX@
PERL=@PERL@
NM=@NM@
#-----------------------------------------------------------------------------#
# Should we install batch files (and other Windows specific files)?
INSTALL_WINDOWS_SCRIPTS=@INSTALL_WINDOWS_SCRIPTS@
#-----------------------------------------------------------------------------#
# The linker option to use to link in the math library, if any.
# Typically `-lm'.
MATH_LIB=@MATH_LIB@
# More libraries to link
THREAD_LIBS=@THREAD_LIBS@
SOCKET_LIBRARY=@SOCKET_LIBRARY@
NSL_LIBRARY=@NSL_LIBRARY@
DL_LIBRARY=@DL_LIBRARY@
READLINE_LIBRARIES=@READLINE_LIBRARIES@
TERMCAP_LIBRARY=@TERMCAP_LIBRARY@
HWLOC_CFLAGS=@HWLOC_CFLAGS@
HWLOC_LIBS=@HWLOC_LIBS@
# Extensions to use
O=@OBJ_SUFFIX@
A=@LIB_SUFFIX@
# The option needed to name object files.
# We need to use $(empty_string) here to prevent Make from truncating
# any trailing spaces in -o
empty_string=
OBJFILE_OPT=@OBJFILE_OPT@$(empty_string)
# Are we compiling using the MS C compiler?
USING_MICROSOFT_CL_COMPILER=@USING_MICROSOFT_CL_COMPILER@
# Is getopt() available?
HAVE_GETOPT=@HAVE_GETOPT@
#-----------------------------------------------------------------------------#
# Module-specific options should go in Mercury.options so they
# can be found by `mmc --make'.
include $(MERCURY_DIR)/Mercury.options
$(MERCURY_DIR)/Mercury.options:
@if test ! -f $(MERCURY_DIR)/Mercury.options ; then \
touch $(MERCURY_DIR)/Mercury.options; \
fi
# The Mmake.params file can be used to override definitions in this file
-include $(MERCURY_DIR)/Mmake.params
# Avoid trying to make this file with `mmc --make' if it doesn't exist.
$(MERCURY_DIR)/Mmake.params: ;
#-----------------------------------------------------------------------------#
#
# `mmake check_namespace' performs various checks on the header files
# and object files to make sure that they conform with our coding standards.
#
ifdef CHECK_OBJS
HDR_CHECK_CS = $(CHECK_HDRS:.h=.check_hdr.c)
HDR_CHECK_POBJS = $(CHECK_HDRS:.h=.check_hdr.pseudo_o)
HDR_CHECK_MACROS = $(CHECK_HDRS:.h=.check.macros)
MHDR_CHECK_CS = $(CHECK_MHDRS:.mh=.check_mhdr.c)
MHDR_CHECK_POBJS = $(CHECK_MHDRS:.mh=.check_mhdr.pseudo_o)
MHDR_CHECK_MACROS = $(CHECK_MHDRS:.mh=.check.mmacros)
OBJ_CHECKS = $(CHECK_OBJS:%=%.obj_check)
# Macro names must normally start with one of the prefixes associated
# with the different components of our system:
# `MR_' or `MERCURY_' for stuff in the Mercury runtime implementation
# (the `runtime' and `trace' directories)
# `ML_' for stuff in the Mercury standard library
# (the `library' directory)
# `MDB_' stuff in the browser
# (the `browser' directory)
# `MDBCOMP_'for stuff in the mdbcomp library
# (the `mdbcomp' directory)
# `GC_' for stuff in the Boehm et al conservative garbage collector
# (the `boehm_gc' directory)
# Exceptions to this policy must be listed in the RESERVED_MACRO_NAMES file
# in the top directory (if applicable to all C source directories) or in
# the relevant directory (if applicable only to some C source directories).
#
# XXX The base_typeclass_info prefix is allowed only temporarily; it should
# be fixed by adding a prefix giving the name of the module defining the
# typeclass.
GEN_MACRO_PREFIX_EXPRS = \
-e '^MR_' -e '^MERCURY_' -e '^GC_'
GEN_OBJ_PREFIX_EXPRS = \
-e '^@SYMPREFIX@MR_' -e '^_entry' -e '^@SYMPREFIX@mercury_' \
-e '^@SYMPREFIX@base_typeclass_info_'
ifeq ("$(ALLOW_LIB_PREFIX)","yes")
LIB_MACRO_PREFIX_EXPRS = \
-e '^ML_'
LIB_OBJ_PREFIX_EXPRS = \
-e '^@SYMPREFIX@ML_'
else
LIB_MACRO_PREFIX_EXPRS =
LIB_OBJ_PREFIX_EXPRS =
endif
ifeq ("$(ALLOW_BROWSER_PREFIX)","yes")
BROWSER_MACRO_PREFIX_EXPRS = \
-e '^MDB_'
BROWSER_OBJ_PREFIX_EXPRS = \
-e '^@SYMPREFIX@MDB_' -e '^@SYMPREFIX@mdb_'
else
BROWSER_MACRO_PREFIX_EXPRS =
BROWSER_OBJ_PREFIX_EXPRS =
endif
ifeq ("$(ALLOW_MDBCOMP_PREFIX)","yes")
MDBCOMP_MACRO_PREFIX_EXPRS = \
-e '^MDBCOMP_'
MDBCOMP_OBJ_PREFIX_EXPRS = \
-e '^@SYMPREFIX@MDBCOMP_' -e '^@SYMPREFIX@mdbcomp_'
else
MDBCOMP_MACRO_PREFIX_EXPRS =
MDBCOMP_OBJ_PREFIX_EXPRS =
endif
ifeq ("$(ALLOW_SSDB_PREFIX)","yes")
SSDB_MACRO_PREFIX_EXPRS = \
-e '^SSDB_'
SSDB_OBJ_PREFIX_EXPRS = \
-e '^@SYMPREFIX@SSDB_' -e '^@SYMPREFIX@ssdb_'
else
SSDB_MACRO_PREFIX_EXPRS =
SSDB_OBJ_PREFIX_EXPRS =
endif
# The external symbols in object files generated by MSVC will include a
# symbol for each string in the global string pool. Such symbols have
# names that begin with "??_C@".
ifeq ("$(USING_MICROSOFT_CL_COMPILER)","yes")
MSVC_OBJ_PREFIX_EXPRS = \
-e '^??_C@'
else
MSVC_OBJ_PREFIX_EXPRS =
endif
MACRO_PREFIX_EXPRS = \
$(GEN_MACRO_PREFIX_EXPRS) \
$(LIB_MACRO_PREFIX_EXPRS) \
$(BROWSER_MACRO_PREFIX_EXPRS) \
$(MDBCOMP_MACRO_PREFIX_EXPRS) \
$(SSDB_MACRO_PREFIX_EXPRS)
OBJ_PREFIX_EXPRS = \
$(GEN_OBJ_PREFIX_EXPRS) \
$(LIB_OBJ_PREFIX_EXPRS) \
$(BROWSER_OBJ_PREFIX_EXPRS) \
$(MDBCOMP_OBJ_PREFIX_EXPRS) \
$(SSDB_OBJ_PREFIX_EXPRS) \
$(MSVC_OBJ_PREFIX_EXPRS)
HEADER_CLEAN_FILTER = \
grep -v $(MACRO_PREFIX_EXPRS) | \
fgrep -v -x -f ../RESERVED_MACRO_NAMES | \
fgrep -v -x -f RESERVED_MACRO_NAMES
# This rule checks that object files are properly namespace-clean,
# with regard to the global symbols that they define.
# For an object file foo.o, it produces a file foo.o.obj_check that contains
# a list of all the globals defined by that object that do not start with
# `MR_', `mercury_', or `entry_'.
%.obj_check: %
@$(NM) -P -g $< | awk '$$2 != "U" { print $$1; }' | \
grep -v $(OBJ_PREFIX_EXPRS) | sort -u > $@
@if cmp -s /dev/null $@; then \
true; \
else \
echo "** Global symbols in user namespace: $*:"; \
cat $@; \
echo "(You may need to add a distinguishing prefix to these names.)"; \
exit 1; \
fi
# These rules help to check that each header file is self-contained,
# i.e. that each header file foo.h includes any other header files
# that define types used by foo.h. It creates a foo.check_hdr.c file
# that contains only a single `#include' statement that includes foo.h;
# compiling foo.check_hdr.c will fail if foo.h is not self-contained.
# Similarly for .mh files.
%.check_hdr.c: %.h
@echo "#include \"$*.h\"" > $*.check_hdr.c
%.check_mhdr.c: %.mh
@echo "#include \"$*.mh\"" > $*.check_mhdr.c
# This rule is a version of the rule for "%.$O: %c" in scripts/Mmake.rules,
# but to avoid clutter in the usual case that the object file *can* be made,
# it does not print the action.
%.pseudo_o: %.c
@$(MGNUC) $(ALL_GRADEFLAGS) $(ALL_MGNUCFLAGS) -c $< $(OBJFILE_OPT)$@
# Mark these files as intermediate files that make should NOT delete
# automatically. The reason for this is that there is no way to tell make
# to delete these files *without* printing the rm command used to delete them.
# Instead, tools/bootcheck uses "mmake clean_check" to delete them silently.
# Users whose run "mmake check_namespace" manually can do so as well.
.SECONDARY: $(HDR_CHECK_CS) $(HDR_CHECK_POBJS) $(HDR_CHECK_MACROS)
.SECONDARY: $(MHDR_CHECK_CS) $(MHDR_CHECK_POBJS) $(MHDR_CHECK_MACROS)
.SECONDARY: $(OBJ_CHECKS)
# These rules check whether a header file defines any macros it shouldn't.
# They generates the list of macros defined in the header file, and filter this
# list through a command that is intended to filter out all references to macro
# names that are all right. Each directory that uses this rule must set arrange
# for the precursors of the HEADER_CLEAN_FILTER make variable to contain this
# command.
#
# The two rules should differ only in the filenames they use and in the fact
# that the automatically created header file for module x is allowed to have
# three macros, X_H, X_MH and X_DECL_GUARD over and above what
# HEADER_CLEAN_FILTER allows.
#
# XXX We should consider deleting the special handling of these macros, and
# requiring instead that the compiler put MERCURY_ prefixes in front of them,
# considering them to be honorary submodules of the "mercury" module.
AWK = awk
%.check.macros: %.h %.check_hdr.c
@> $*.empty.c
-@ @CC@ -E $*.empty.c -nostdinc -dN 2> /dev/null | \
$(AWK) '/[ \t]*#define/ { print $$2; }' | sort -u > $*.base
-@$(MGNUC) $(ALL_GRADEFLAGS) $(ALL_MGNUCFLAGS) \
-DMERCURY_BOOTSTRAP_H -DMR_NO_CONF_BACKWARDS_COMPAT \
-E $*.check_hdr.c -nostdinc -dN \
2> /dev/null | $(AWK) '/[ \t]*#define/ { print $$2; }' | \
$(HEADER_CLEAN_FILTER) | sort -u > $*.actual
@comm -1 -3 $*.base $*.actual > $@
@rm $*.base $*.actual $*.empty.c
@if cmp -s /dev/null $@; then \
true; \
else \
echo "** Macro name(s) in user namespace: $*:"; \
cat $@; \
echo "(You may need to add a distinguishing prefix to these names.)"; \
exit 1; \
fi
%.check.mmacros: %.mh %.check_mhdr.c
@> $*.mempty.c
-@ @CC@ -E $*.mempty.c -nostdinc -dN 2> /dev/null | \
$(AWK) '/[ \t]*#define/ { print $$2; }' | sort -u > $*.mbase
-@$(MGNUC) $(ALL_GRADEFLAGS) $(ALL_MGNUCFLAGS) \
-DMERCURY_BOOTSTRAP_H -DMR_NO_CONF_BACKWARDS_COMPAT \
-E $*.check_mhdr.c -nostdinc -dN \
2> /dev/null | $(AWK) '/[ \t]*#define/ { print $$2; }' | \
grep -v -e `echo $(subst .check.mmacros,,$@) | tr '[a-z]' '[A-Z]' | sed -e s/\\\\./__/`_H | \
grep -v -e `echo $(subst .check.mmacros,,$@) | tr '[a-z]' '[A-Z]' | sed -e s/\\\\./__/`_MH | \
grep -v -e `echo $(subst .check.mmacros,,$@) | tr '[a-z]' '[A-Z]' | sed -e s/\\\\./__/`_DECL_GUARD | \
$(HEADER_CLEAN_FILTER) | sort -u > $*.mactual
@comm -1 -3 $*.mbase $*.mactual > $@
@rm $*.mbase $*.mactual $*.mempty.c
@if cmp -s /dev/null $@; then \
true; \
else \
echo "** Macro name(s) in user namespace: $*:"; \
cat $@; \
echo "(You may need to add a distinguishing prefix to these names.)"; \
exit 1; \
fi
#---------------------#
.PHONY: check_headers_self_contained
check_headers_self_contained: $(HDR_CHECK_POBJS) $(MHDR_CHECK_POBJS)
.PHONY: check_headers_macros
check_headers_macros: $(HDR_CHECK_MACROS) $(MHDR_CHECK_MACROS)
.PHONY: check_headers
check_headers: check_headers_self_contained check_headers_macros
.PHONY: check_objs
check_objs: $(OBJ_CHECKS)
.PHONY: check_namespace
check_namespace: check_headers check_objs
.PHONY: clean_check
clean_check:
-@rm -f $(HDR_CHECK_POBJS) $(HDR_CHECK_CS) $(HDR_CHECK_MACROS)
-@rm -f $(MHDR_CHECK_POBJS) $(MHDR_CHECK_CS) $(MHDR_CHECK_MACROS)
-@rm -f $(OBJ_CHECKS)
endif
# The endif is for "ifdef CHECK_OBJS" a long way above.
#-----------------------------------------------------------------------------#
%_FLAGS: %_FLAGS.in ../config.status
@if test -f $*_FLAGS; then chmod u+w $*_FLAGS; fi
@../config.status --file $*_FLAGS
@chmod a-w $*_FLAGS
#-----------------------------------------------------------------------------#