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
|
#-----------------------------------------------------------------------------#
# Copyright (C) 1998-1999 The University of Melbourne.
# This file may only be copied under the terms of the GNU General
# Public License - see the file COPYING in the Mercury distribution.
#-----------------------------------------------------------------------------#
# Mmake - Mmake file for the Mercury runtime library
MAIN_TARGET=runtime
MERCURY_DIR=..
include $(MERCURY_DIR)/Mmake.common
#-----------------------------------------------------------------------------#
CFLAGS = -g $(DLL_CFLAGS)
MGNUC = MERCURY_ALL_C_INCL_DIRS=" \
-I$(RUNTIME_DIR) \
-I$(BOEHM_GC_DIR) \
-I$(BOEHM_GC_DIR)/include \
" \
$(SCRIPTS_DIR)/mgnuc
MGNUCFLAGS = --no-ansi
MOD2C = $(SCRIPTS_DIR)/mod2c
#-----------------------------------------------------------------------------#
# keep this list in alphabetical order, please
HDRS = \
mercury_accurate_gc.h \
mercury_agc_debug.h \
mercury_array_macros.h \
mercury_bootstrap.h \
mercury_calls.h \
mercury_conf.h \
mercury_conf_param.h \
mercury_context.h \
mercury_debug.h \
mercury_deep_copy.h \
mercury_deep_copy_body.h \
mercury_dummy.h \
mercury_dlist.h \
mercury_engine.h \
mercury_float.h \
mercury_getopt.h \
mercury_goto.h \
mercury_grade.h \
mercury_hash_table.h \
mercury_heap.h \
mercury_heap_profile.h \
mercury_ho_call.h \
mercury_imp.h \
mercury_init.h \
mercury_label.h \
mercury_layout_util.h \
mercury_library_types.h \
mercury_memory.h \
mercury_memory_zones.h \
mercury_memory_handlers.h \
mercury_misc.h \
mercury_overflow.h \
mercury_prof.h \
mercury_prof_mem.h \
mercury_reg_workarounds.h \
mercury_regorder.h \
mercury_regs.h \
mercury_signal.h \
mercury_std.h \
mercury_stack_layout.h \
mercury_stack_trace.h \
mercury_stacks.h \
mercury_string.h \
mercury_tabling.h \
mercury_tags.h \
mercury_thread.h \
mercury_timing.h \
mercury_trace_base.h \
mercury_trail.h \
mercury_types.h \
mercury_type_info.h \
mercury_wrapper.h \
$(LIB_DLL_H)
# Note that $(LIB_GLOBALS_H) cannot be part of $(HDR), since it depends on
# lib$(RT_LIB_NAME)$(DLL_DEF_LIB).a, and $(OBJ) : $(HDR) would create a
# circular dependency.
MACHHDRS = machdeps/no_regs.h \
machdeps/i386_regs.h \
machdeps/mips_regs.h \
machdeps/sparc_regs.h \
machdeps/alpha_regs.h \
machdeps/pa_regs.h \
machdeps/rs6000_regs.h
# keep this list in alphabetical order, please
CFILES = \
mercury_accurate_gc.c \
mercury_agc_debug.c \
mercury_bootstrap.c \
mercury_context.c \
mercury_deep_copy.c \
mercury_dlist.c \
mercury_dummy.c \
mercury_engine.c \
mercury_float.c \
mercury_getopt.c \
mercury_getopt1.c \
mercury_grade.c \
mercury_hash_table.c \
mercury_heap_profile.c \
mercury_ho_call.c \
mercury_label.c \
mercury_layout_util.c \
mercury_memory.c \
mercury_memory_zones.c \
mercury_memory_handlers.c \
mercury_misc.c \
mercury_prof.c \
mercury_prof_mem.c \
mercury_reg_workarounds.c \
mercury_regs.c \
mercury_signal.c \
mercury_stack_trace.c \
mercury_stacks.c \
mercury_tabling.c \
mercury_thread.c \
mercury_timing.c \
mercury_trace_base.c \
mercury_trail.c \
mercury_type_info.c \
mercury_wrapper.c
OBJS = $(CFILES:.c=.o)
PIC_OBJS = $(CFILES:.c=.$(EXT_FOR_PIC_OBJECTS))
LDFLAGS = -L$(BOEHM_GC_DIR)
LDLIBS = \
` case "$(GRADE)" in \
*.gc*.prof*) echo "-lgc_prof" ;; \
*.gc*) echo "-lgc" ;; \
esac \
`
THREADLIBS = \
` case "$(GRADE)" in \
*.par*) echo "-lpthread" ;; \
esac \
`
HDR_CHECK_CS = $(HDRS:.h=_check.c)
HDR_CHECK_OBJS = $(HDRS:.h=_check.o)
HDR_CHECK_NMS = $(HDRS:.h=_check.nms)
HDR_CHECK_MACROS = $(HDRS:.h=_check.macros)
#-----------------------------------------------------------------------------#
# Stuff for Windows DLLs
ifeq ($(USE_DLLS),yes)
DLL_CFLAGS = -Dlib$(RT_LIB_NAME)_DEFINE_DLL
# the following header files are created automatically by Makefile.DLLs
LIB_DLL_H = lib$(RT_LIB_NAME)_dll.h
LIB_GLOBALS_H = lib$(RT_LIB_NAME)_globals.h
include $(MERCURY_DIR)/Makefile.DLLs
else
DLL_CFLAGS =
LIB_DLL_H =
LIB_GLOBALS_H =
DLL_DEF_LIB =
endif
#-----------------------------------------------------------------------------#
$(OBJS) $(PIC_OBJS): $(HDRS) $(MACHHDRS)
#-----------------------------------------------------------------------------#
.PHONY: runtime
runtime: lib$(RT_LIB_NAME).a lib$(RT_LIB_NAME).$(EXT_FOR_SHARED_LIB)
runtime: $(RT_LIB_NAME).init
runtime: $(LIB_DLL_H) $(LIB_GLOBALS_H)
lib$(RT_LIB_NAME)$(DLL_DEF_LIB).a: $(OBJS)
rm -f lib$(RT_LIB_NAME)$(DLL_DEF_LIB).a
ar cr lib$(RT_LIB_NAME)$(DLL_DEF_LIB).a $(OBJS)
$(RANLIB) lib$(RT_LIB_NAME)$(DLL_DEF_LIB).a
lib$(RT_LIB_NAME).so: $(PIC_OBJS)
$(LINK_SHARED_OBJ) -o lib$(RT_LIB_NAME).so $(PIC_OBJS) \
$(SHLIB_RPATH_OPT)$(FINAL_INSTALL_MERC_GC_LIB_DIR) \
$(LDFLAGS) $(LDLIBS) $(THREADLIBS) \
$(SHARED_LIBS)
$(RT_LIB_NAME).init: $(CFILES)
cat `vpath_find $(CFILES)` | grep '^INIT ' > $(RT_LIB_NAME).init
mercury_conf.h.date: $(MERCURY_DIR)/config.status mercury_conf.h.in
CONFIG_FILES= CONFIG_HEADERS=mercury_conf.h $(MERCURY_DIR)/config.status
echo datestamp > mercury_conf.h.date
mercury_conf.h: mercury_conf.h.date
@true
.PHONY: cs
cs: $(CFILES)
tags: $(CFILES) $(HDRS)
ctags $(CFILES) $(HDRS)
#-----------------------------------------------------------------------------#
#
# `mmake check_headers' performs various checks on the header files
# to make sure that the conform with our coding standards.
#
#
# $(HDR_CHECK_OBJS) is used to check that the header files are self-contained.
# The rule for foo_check.o checks that the header file foo.h is properly
# self-contained, i.e. that the header file foo.h includes any other
# header files that define types used by foo.h.
# It does this by compiling a foo_check.c file that contains only a single
# `#include' statement that includes foo.h.
#
%_check.c : %.h
echo "#include \"$*.h\"" > $*_check.c
# The mercury_deep_copy_body.h header is not meant to be self-contained.
# So the following rule is used to suppress that check for this header.
mercury_deep_copy_body_check.o:
@true
#
# $(HDR_CHECK_MACROS) is used to check that the headers are properly
# namespace-clean, with regard to the macros that they define.
# For each header file foo.h, the rule below produces a file
# foo_check.macros that contains a list of all the macros defined
# by the header file (or by headers that it includes, excluding
# standard headers) that do not start with `GC_', `MR_', or `MERCURY_'.
#
# XXX the `cmp' command below, which forces `mmake check_headers' to fail
# if the foo_check.macros file is non-empty, i.e. if the header is not
# macro-namespace-clean, is commented out because currently the headers
# are not namespace-clean.
#
AWK = awk
%_check.macros: %.h %_check.c
-$(MGNUC) $(ALL_GRADEFLAGS) $(ALL_MGNUCFLAGS) -E $*_check.c \
-nostdinc -dN \
2> /dev/null | $(AWK) '/^#define/ { print $$2; }' | \
grep -v -e '^MR_' -e '^GC_' -e '^MERCURY_' | \
sort | uniq > $@
#cmp $@ /dev/null # XXX disabled for now
.PHONY: check_headers
check_headers: $(HDR_CHECK_OBJS) $(HDR_CHECK_MACROS)
#-----------------------------------------------------------------------------#
# installation rules
.PHONY: install
install: install_headers install_init install_lib
.PHONY: install_dirs
install_dirs:
-[ -d $(INSTALL_INC_DIR)/machdeps ] || \
mkdir -p $(INSTALL_INC_DIR)/machdeps
-[ -d $(INSTALL_MODULE_DIR) ] || mkdir -p $(INSTALL_MODULE_DIR)
-[ -d $(INSTALL_MERC_LIB_DIR) ] || mkdir -p $(INSTALL_MERC_LIB_DIR)
.PHONY: install_headers
install_headers: $(HDRS) $(MACHHDRS) $(LIB_GLOBALS_H) install_dirs
cp `vpath_find $(HDRS) $(LIB_GLOBALS_H)` $(INSTALL_INC_DIR)
chmod u+w $(INSTALL_INC_DIR)/mercury_conf.h
cp `vpath_find $(MACHHDRS)` $(INSTALL_INC_DIR)/machdeps
.PHONY: install_init
install_init: $(RT_LIB_NAME).init install_dirs
cp `vpath_find $(RT_LIB_NAME).init` $(INSTALL_MODULE_DIR)
# "$(RT_LIB_NAME).init" used to be called "runtime.init".
# If there is still a version with an old name lying around,
# then delete it; otherwise the initialization would get done twice.
rm -f $(INSTALL_MODULE_DIR)/runtime.init
.PHONY: install_lib
install_lib: lib$(RT_LIB_NAME).a lib$(RT_LIB_NAME).$(EXT_FOR_SHARED_LIB) \
install_dirs
cp `vpath_find lib$(RT_LIB_NAME).a \
lib$(RT_LIB_NAME).$(EXT_FOR_SHARED_LIB)` \
$(INSTALL_MERC_LIB_DIR)
#-----------------------------------------------------------------------------#
# prevent Mmake from removing C files
RM_C=:
#-----------------------------------------------------------------------------#
clean_local: clean_o clean_check
.PHONY: clean_o
clean_o:
rm -f $(OBJS) $(PIC_OBJS)
.PHONY: clean_check
clean_check:
rm -f $(HDR_CHECK_OBJS) $(HDR_CHECK_CS) $(HDR_CHECK_MACROS)
realclean_local:
rm -f lib$(RT_LIB_NAME).a lib$(RT_LIB_NAME).so $(RT_LIB_NAME).init
rm -f mercury_conf.h mercury_conf.h.date
#-----------------------------------------------------------------------------#
|