Files
mercury/compiler/Mmakefile
Fergus Henderson 9cf20611cc Link with the shared version of the C standard library,
Estimated hours taken: 1

Link with the shared version of the C standard library,
rather than linking the C library in statically.
This works around an lcc bug with static linking.

compiler/Mmakefile:
profiler/Mmakefile:
	Add `--shared' to `MLFLAGS'.
	The overrides the default `--static' on Linux.
	(Since we name all the Mercury libraries that we link with
	explicitly, this only affects the way we link with the C
	library, not with the Mercury runtime or standard library.)
2001-01-17 02:30:57 +00:00

248 lines
7.7 KiB
Plaintext

#-----------------------------------------------------------------------------#
# Copyright (C) 1995-2001 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 - this is Mmake file for building the Mercury compiler
MERCURY_DIR=..
include $(MERCURY_DIR)/Mmake.common
MAIN_TARGET=mercury
VPATH=$(LIBRARY_DIR) $(BROWSER_DIR)
#-----------------------------------------------------------------------------#
# Specify which compilers to use to compile the compiler.
# Don't change these without good reason - if you want to
# do a temporary change, change ../Mmake.params
M_ENV = MERCURY_INT_DIR=$(LIBRARY_DIR) \
MERCURY_ALL_C_INCL_DIRS="\
-I$(BROWSER_DIR) \
-I$(TRACE_DIR) \
-I$(LIBRARY_DIR) \
-I$(RUNTIME_DIR) \
-I$(BOEHM_GC_DIR) \
-I$(BOEHM_GC_DIR)/include \
"
SMC = $(MC) --search-directory $(BROWSER_DIR)
MCD = $(M_ENV) $(SMC) --generate-dependencies
MCI = $(M_ENV) $(SMC) --make-interface
MCPI = $(M_ENV) $(SMC) --make-private-interface
MCSI = $(M_ENV) $(SMC) --make-short-interface
MCOI = $(M_ENV) $(SMC) --make-optimization-interface
MCTOI = $(M_ENV) $(SMC) --make-transitive-optimization-interface
MCG = $(M_ENV) $(SMC) --compile-to-c
MCS = $(M_ENV) $(SMC) --split-c-files -c --cflags "$(ALL_CFLAGS)"
MGNUC = $(M_ENV) $(SCRIPTS_DIR)/mgnuc
C2INIT = MERCURY_MOD_LIB_MODS="$(LIBRARY_DIR)/$(STD_LIB_NAME).init $(RUNTIME_DIR)/$(RT_LIB_NAME).init" \
MERCURY_TRACE_LIB_MODS="$(BROWSER_DIR)/$(BROWSER_LIB_NAME).init" \
MERCURY_MKINIT=$(UTIL_DIR)/mkinit $(SCRIPTS_DIR)/c2init
C2INITFLAGS = --library
ML = MERCURY_C_LIB_DIR=. $(SCRIPTS_DIR)/ml
MLFLAGS = --shared --mercury-libs none
MLLIBS = ../main.$O \
$(TRACE_DIR)/lib$(TRACE_LIB_NAME).$A \
$(BROWSER_DIR)/lib$(BROWSER_LIB_NAME).$A \
$(LIBRARY_DIR)/lib$(STD_LIB_NAME).$A \
$(RUNTIME_DIR)/lib$(RT_LIB_NAME).$A ` \
case $(GRADE) in \
*.par*.gc*.prof*) \
echo $(BOEHM_GC_DIR)/libpar_gc_prof.$A ;; \
*.par*.gc*) echo $(BOEHM_GC_DIR)/libpar_gc.$A ;; \
*.gc*.prof*) echo $(BOEHM_GC_DIR)/libgc_prof.$A ;; \
*.gc*) echo $(BOEHM_GC_DIR)/libgc.$A ;; \
esac \
` $(MATH_LIB)
MTAGS = $(SCRIPTS_DIR)/mtags
MTAGSFLAGS = $(EXTRA_MTAGSFLAGS)
#
# Work-around for a fixed limit: on alpha-dec-osf3.2, if we compile with
# `-O5', then when linking mercury_compile we get an error message of the form
#
# /usr/bin/ld:
# Too many GOT entries in object file '/usr/lib/cmplrs/cc/libexc_init.a';
# Found 8190 (6660 locals + 1530 globals) but max is 8189
#
# unless we link it statically.
#
ifeq ($(FULLARCH),alpha-dec-osf3.2)
MLFLAGS += --static
endif
# Compilation of rl_code.c is really slow (about 26 minutes on traveller with
# --trace deep) at the default level of -O2, due to the C optimizer's use of
# quadratic algorithms on a couple of 20,000-line functions (the automatically
# generated index and compare routines on the bytecode type). The code in this
# module can't really benefit from those algorithms anyway. With -O1, the 26
# minutes drops to less than 26 seconds.
CFLAGS-rl_code=-O1
# The c_code in the module gcc.m needs the header files from the GNU C
# distribution.
GCC_SRC_DIR= ../../../..
CFLAGS-gcc = -DMERCURY_BOOTSTRAP_H \
-DIN_GCC -DHAVE_CONFIG_H \
-I. \
-I$(GCC_SRC_DIR)/gcc \
-I$(GCC_SRC_DIR)/gcc/mercury \
-I$(GCC_SRC_DIR)/gcc/config \
-I$(GCC_SRC_DIR)/include \
#-----------------------------------------------------------------------------#
# Rules for preprocessing `.pp' files.
# `.pp_date' files are used as timestamps as for interface files.
ifeq ($(INCLUDE_ADITI_OUTPUT),yes)
# Remove the #if line and everything between the #else and #endif lines.
$(dates_subdir)%.pp_date: %.pp
-m_file=$(<:.pp=.m); \
[ ! -f $$m_file ] || chmod +w $$m_file; \
sed -e '/^#if *INCLUDE_ADITI_OUTPUT/s/.*//' \
-e '/^#else/,/^#endif/s/.*//' \
$< > $$m_file.tmp; \
mercury_update_interface -v $$m_file; \
touch $@; \
chmod -w $$m_file
else
# Remove everything between the #if line and the #else line,
# and the #endif line.
$(dates_subdir)%.pp_date: %.pp
-m_file=$(<:.pp=.m); \
[ ! -f $$m_file ] || chmod +w $$m_file; \
sed -e '/^#if *INCLUDE_ADITI_OUTPUT/,/^#else/s/.*//' \
-e '/^#endif/s/.*//' \
$< > $$m_file.tmp; \
mercury_update_interface -v $$m_file; \
touch $@; \
chmod -w $$m_file
endif
PREPROCESSED_MODULES = rl_file rl_out
PREPROCESSED_FILES = $(PREPROCESSED_MODULES:%=%.pp)
PREPROCESSED_M_FILES = $(PREPROCESSED_MODULES:%=%.m)
PP_DATE_FILES = $(PREPROCESSED_MODULES:%=$(dates_subdir)%.pp_date)
# Force regeneration of the preprocessed modules.
# This is necessary if the setting of `INCLUDE_ADITI_OUTPUT' has changed.
regenerate_preprocessed_files:
touch $(PREPROCESSED_FILES)
$(MMAKE) $(PREPROCESSED_M_FILES)
# The `.m' files for the preprocessed modules depend on the `.pp_date' files.
$(PREPROCESSED_M_FILES): %.m: $(dates_subdir)%.pp_date
@:
#-----------------------------------------------------------------------------#
# targets
#
# mercury_compile
.PHONY: depend
depend: mercury_compile.depend
mercury_compile.depend: regenerate_preprocessed_files
.PHONY: all
all: mercury
.PHONY: mercury
mercury: mercury_compile
.PHONY: libmmc
libmmc: libmercury_compile.a mercury_compile_init.$O
#-----------------------------------------------------------------------------#
# Add some additional dependencies, so that Mmake knows to remake the
# compiler if one of the libraries changes.
mercury_compile: ../main.$O
mercury_compile: $(RUNTIME_DIR)/lib$(RT_LIB_NAME).$A
mercury_compile: $(LIBRARY_DIR)/lib$(STD_LIB_NAME).$A
mercury_compile: $(BROWSER_DIR)/lib$(BROWSER_LIB_NAME).$A
mercury_compile: $(TRACE_DIR)/lib$(TRACE_LIB_NAME).$A
# Should also depend on $(BOEHM_GC_DIR)/libgc(_prof).$A, but only
# if in .gc(.prof) grade; GNU make does not support dynamic dependencies,
# so just leave it out.
mercury_compile_init.c: $(UTIL_DIR)/mkinit
#-----------------------------------------------------------------------------#
.PHONY: check
check : mercury_compile.check
.PHONY: ints
ints : mercury_compile.ints
#-----------------------------------------------------------------------------#
tags : $(mercury_compile.ms) $(LIBRARY_DIR)/*.m
$(MTAGS) $(MTAGSFLAGS) $(mercury_compile.ms) $(LIBRARY_DIR)/*.m
mercury_compile.stats : source_stats.awk $(mercury_compile.ms)
awk -f `vpath_find source_stats.awk` \
`vpath_find $(mercury_compile.ms)` > $@
#-----------------------------------------------------------------------------#
.PHONY: dates
dates :
touch $(mercury_compile.dates)
#-----------------------------------------------------------------------------#
.PHONY: os cs
os: $(mercury_compile.os) $(os_subdir)mercury_compile_init.$O
cs: $(mercury_compile.cs) $(cs_subdir)mercury_compile_init.c
#-----------------------------------------------------------------------------#
clean_local:
rm -f ../main.$O
for file in *.pp; do \
if [ "$$file" != "*.pp" ]; then \
rm -f `basename $$file .pp`.m; \
fi; \
done
realclean_local:
rm -f tags mercury_compile.stats $(PP_DATE_FILES)
#-----------------------------------------------------------------------------#
#-----------------------------------------------------------------------------#
# Installation targets
.PHONY: install
install: install_mercury
.PHONY: install_all
install_all: install_mercury
.PHONY: install_mercury
install_mercury: install_compiler
.PHONY: install_dirs
install_dirs:
-[ -d $(INSTALL_MERC_BIN_DIR) ] || mkdir -p $(INSTALL_MERC_BIN_DIR)
.PHONY: install_compiler
install_compiler: mercury_compile install_dirs
cp `vpath_find mercury_compile$(EXT_FOR_EXE)` $(INSTALL_MERC_BIN_DIR)
#-----------------------------------------------------------------------------#