Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

494 lines (410 sloc) 18.035 kb
#-----------------------------------------------------------------------------#
# Copyright (C) 1995-2006, 2009-2012 The University of Melbourne.
# 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
# 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@
# Additional options to pass to the C compiler when building Boehm-GC for
# threads.
#
BOEHM_CFLAGS_FOR_THREADS = @ENABLE_BOEHM_THREAD_LOCAL_ALLOC@ \
@ENABLE_BOEHM_PARALLEL_MARK@ \
@BOEHM_MISC_CFLAGS_FOR_THREADS@
# 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@
ifdef ALWAYS_MMAKE_TAGS_FILE
TAGS_FILE_EXISTS = tags_file_exists
else
TAGS_FILE_EXISTS =
endif
#-----------------------------------------------------------------------------#
INSTALL_INFO=@INSTALL_INFO@
INFO=@INFO@
TEXI2DVI=@TEXI2DVI@
DVIPS=@DVIPS@
PDFTEX=@PDFTEX@
MAKEINFO=@MAKEINFO@
LYNX=@LYNX@
PERL=@PERL@
NM=@NM@
#-----------------------------------------------------------------------------#
# 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 the getopt.h header file available?
GETOPT_H_AVAILABLE=@GETOPT_H_AVAILABLE@
#-----------------------------------------------------------------------------#
# 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 [ ! -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_OBJS = $(CHECK_HDRS:.h=.check_hdr.$O)
HDR_CHECK_MACROS = $(CHECK_HDRS:.h=.check.macros)
MHDR_CHECK_CS = $(CHECK_MHDRS:.mh=.check_mhdr.c)
MHDR_CHECK_OBJS = $(CHECK_MHDRS:.mh=.check_mhdr.$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
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)
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) -g $< | awk '$$1 != "U" { print $$3; }' | \
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 header files 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
# 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_OBJS) $(MHDR_CHECK_OBJS)
.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_OBJS) $(HDR_CHECK_CS) $(HDR_CHECK_MACROS)
-rm -f $(MHDR_CHECK_OBJS) $(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
#-----------------------------------------------------------------------------#
Jump to Line
Something went wrong with that request. Please try again.