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
|
#-----------------------------------------------------------------------------#
# Copyright (C) 1995-1999 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)
#-----------------------------------------------------------------------------#
# 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$(TRACE_DIR) \
-I$(RUNTIME_DIR) \
-I$(BOEHM_GC_DIR) \
-I$(BOEHM_GC_DIR)/include \
"
MCD = $(M_ENV) $(MC) --generate-dependencies
MCI = $(M_ENV) $(MC) --make-interface
MCPI = $(M_ENV) $(MC) --make-private-interface
MCSI = $(M_ENV) $(MC) --make-short-interface
MCOI = $(M_ENV) $(MC) --make-optimization-interface
MCTOI = $(M_ENV) $(MC) --make-transitive-optimization-interface
MCG = $(M_ENV) $(MC) --compile-to-c
MCS = $(M_ENV) $(MC) --split-c-files -c --cflags $(ALL_CFLAGS)
MGNUC = $(M_ENV) $(SCRIPTS_DIR)/mgnuc
C2INIT = MERCURY_MOD_LIB_MODS="$(BROWSER_DIR)/$(BROWSER_LIB_NAME).init $(LIBRARY_DIR)/$(STD_LIB_NAME).init $(RUNTIME_DIR)/$(RT_LIB_NAME).init" \
MERCURY_MKINIT=$(UTIL_DIR)/mkinit $(SCRIPTS_DIR)/c2init
ML = MERCURY_C_LIB_DIR=. $(SCRIPTS_DIR)/ml
MLFLAGS = --mercury-libs none
MLLIBS = $(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 \
*.gc*.prof*) echo $(BOEHM_GC_DIR)/libgc_prof.a ;; \
*.gc*) echo $(BOEHM_GC_DIR)/libgc.a ;; \
esac \
` -lm
MTAGS = $(SCRIPTS_DIR)/mtags
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
#-----------------------------------------------------------------------------#
# 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
#-----------------------------------------------------------------------------#
# Add some additional dependencies, so that Mmake knows to remake the
# compiler if one of the libraries changes.
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:
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)
#-----------------------------------------------------------------------------#
|