Skip to content

Commit

Permalink
Support installing both .par' and non-.par' versions of the GC libr…
Browse files Browse the repository at this point in the history
…ary.

Estimated hours taken: 3

Support installing both `.par' and non-`.par' versions of the GC library.

scripts/ml.in:
	Change the code for computing which version of the GC library
	to link in so that it also takes the `.par' grade component
	into account, rather than just the `.prof' grade component.
	Add new options `--print-gc-grade' (for use by the top-level
	Mmakefile) and `--print-grade' (for symmetry).

Mmakefile:
	When invoking sub-makes in the boehm_gc directory,
	pass down GC_GRADE instead of PROF.
	Compute the GC_GRADE value using `scripts/ml ... --print-gc-grade`
	rather than computing it manually, since this avoids code duplication.

boehm_gc/Mmakefile:
boehm_gc/Makefile:
boehm_gc/NT_MAKEFILE:
	s/gc$(PROF)/$(GC_GRADE)/g

runtime/Mmakefile:
trace/Mmakefile:
browser/Mmakefile:
bytecode/Mmakefile:
library/Mmakefile:
compiler/Mmakefile:
profiler/Mmakefile:
	Change the code for computing which version of the GC library
	to link in so that it also takes the `.par' grade component
	into account, rather than just the `.prof' grade component.
  • Loading branch information
Fergus Henderson committed Aug 17, 2000
1 parent 532e4ec commit d7ed113
Show file tree
Hide file tree
Showing 12 changed files with 121 additions and 74 deletions.
33 changes: 6 additions & 27 deletions Mmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,8 @@ scripts:

.PHONY: boehm_gc
boehm_gc: scripts
case $(GRADE) in \
*.prof*) \
prof=_prof \
;; \
*) \
prof= \
;; \
esac; \
cd boehm_gc && $(SUBDIR_MMAKE) PROF=$$prof
gc_grade=`scripts/ml --grade $(GRADE) --print-gc-grade`
cd boehm_gc && $(SUBDIR_MMAKE) GC_GRADE=$$gc_grade

.PHONY: runtime
runtime: scripts boehm_gc
Expand Down Expand Up @@ -303,15 +296,8 @@ install_trace: trace

.PHONY: install_boehm_gc
install_boehm_gc: boehm_gc
case $(GRADE) in \
*.prof*) \
prof=_prof \
;; \
*) \
prof= \
;; \
esac; \
cd boehm_gc && $(SUBDIR_MMAKE) install PROF=$$prof
gc_grade=`scripts/ml --grade $(GRADE) --print-gc-grade`
cd boehm_gc && $(SUBDIR_MMAKE) install GC_GRADE=$$gc_grade

.PHONY: install_library
install_library: dep_library library
Expand Down Expand Up @@ -358,16 +344,9 @@ install_grades: scripts
#
for grade in x $(LIBGRADES); do \
if [ "$$grade" != "x" ]; then \
case "$$grade" in \
*.prof*) \
prof=_prof \
;; \
*) \
prof= \
;; \
esac; \
gc_grade=`scripts/ml --grade $$grade --print-gc-grade`
( cd boehm_gc && \
$(SUBDIR_MMAKE) MC=mmc GRADE=$$grade PROF=$$prof \
$(SUBDIR_MMAKE) MC=mmc GRADE=$$grade GC_GRADE=$$gc_grade \
install_lib ) && \
( cd runtime && \
$(SUBDIR_MMAKE) MC=mmc GRADE=$$grade install_lib ) && \
Expand Down
18 changes: 9 additions & 9 deletions boehm_gc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -247,10 +247,10 @@ $(OBJS) test.o dyn_load.o dyn_load_sunos53.o: $(srcdir)/gc_priv.h $(srcdir)/gc_h
mark.o typd_mlc.o finalize.o: $(srcdir)/gc_mark.h

# Mercury-specific target:
libgc$(PROF)$(DLL_DEF_LIB).a: gc.a
rm -f libgc$(PROF)$(DLL_DEF_LIB).a
lib$(GC_GRADE)$(DLL_DEF_LIB).a: gc.a
rm -f lib$(GC_GRADE)$(DLL_DEF_LIB).a
# `ln -s' here doesn't work with gnu-win32, so we use `cp' instead
cp gc.a libgc$(PROF)$(DLL_DEF_LIB).a
cp gc.a lib$(GC_GRADE)$(DLL_DEF_LIB).a

base_lib gc.a: $(OBJS) dyn_load.o $(UTILS)
echo > base_lib
Expand Down Expand Up @@ -297,16 +297,16 @@ dyn_load_sunos53.o: dyn_load.c

# Mercury-specific target:
# generic shared library version of the collector
libgc$(PROF).so: $(OBJS) $(UTILS) # dyn_load_sunos53.o
lib$(GC_GRADE).so: $(OBJS) $(UTILS) # dyn_load_sunos53.o
rm -f on_sparc_sunos5_so
./if_mach SPARC SUNOS5 touch on_sparc_sunos5_so
./if_mach SPARC SUNOS5 $(MAKE) dyn_load_sunos53.o
./if_mach SPARC SUNOS5 \
$(LINK_SHARED_OBJ) -o libgc$(PROF).so $(OBJS) dyn_load_sunos53.o \
$(LINK_SHARED_OBJ) -o lib$(GC_GRADE).so $(OBJS) dyn_load_sunos53.o \
-ldl `./threadlibs`
./if_not_there on_sparc_sunos5_so $(MAKE) dyn_load.o
./if_not_there on_sparc_sunos5_so \
$(LINK_SHARED_OBJ) -o libgc$(PROF).so $(OBJS) dyn_load.o -lc
$(LINK_SHARED_OBJ) -o lib$(GC_GRADE).so $(OBJS) dyn_load.o -lc


# SunOS5 shared library version of the collector
Expand Down Expand Up @@ -489,10 +489,10 @@ user_namespace: $(SRCS)
# so we need targets `a', `so', and `dll'.

.PHONY: a
a: libgc$(PROF).a
a: lib$(GC_GRADE).a

.PHONY: so
so: libgc$(PROF).so
so: lib$(GC_GRADE).so

#-----------------------------------------------------------------------------#
# support for DLLs using gnu-win32
Expand All @@ -509,7 +509,7 @@ dll: libgc.dll libgc.a libgc_dll.h libgc_globals.h
@echo Made DLL

# GNU Make seems to need these extra dependencies as a hint
libgc$(PROF).dll: libgc$(PROF)$(DLL_DEF_LIB) libgc.def
lib$(GC_GRADE).dll: lib$(GC_GRADE)$(DLL_DEF_LIB) libgc.def

test_dll.o: test.c libgc_dll.h libgc_globals.h
$(CC) $(CFLAGS) -UGC_DEFINE_DLL -c test.c -o test_dll.o
Expand Down
28 changes: 16 additions & 12 deletions boehm_gc/Mmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,25 @@

# Mmake - Mmake file for Hans Boehm's conservative garbage collector.

PROF=
MAIN_TARGET=libgc$(PROF)
# The invoker is expected to set GC_GRADE on the command line
# in cases when this default is not appropriate.
GC_GRADE=gc

MAIN_TARGET=lib$(GC_GRADE)

MERCURY_DIR=..
include $(MERCURY_DIR)/Mmake.common

#-----------------------------------------------------------------------------#

.PHONY: libgc$(PROF)
libgc$(PROF): submake
.PHONY: lib$(GC_GRADE)
lib$(GC_GRADE): submake

libgc$(PROF).$A: submake
lib$(GC_GRADE).$A: submake

libgc$(PROF).so: submake
lib$(GC_GRADE).so: submake

libgc$(PROF).dll: submake
lib$(GC_GRADE).dll: submake

MMAKEFLAGS=

Expand All @@ -31,8 +34,9 @@ MMAKEFLAGS=
# We don't use `unset', since the Ultrix /bin/sh doesn't have `unset'.
submake: force
MAKEFLAGS=""; export MAKEFLAGS; \
$(MAKE) $(BOEHMGC_MAKEFILE) $(MMAKEFLAGS) GRADE=$(GRADE) PROF=$(PROF) \
libgc$(PROF).$A libgc$(PROF).$(EXT_FOR_SHARED_LIB) \
$(MAKE) $(BOEHMGC_MAKEFILE) $(MMAKEFLAGS) GRADE=$(GRADE) \
GC_GRADE=$(GC_GRADE) \
lib$(GC_GRADE).$A lib$(GC_GRADE).$(EXT_FOR_SHARED_LIB) \
$(EXT_FOR_SHARED_LIB)

.PHONY: force
Expand Down Expand Up @@ -85,8 +89,8 @@ install_headers: install_dirs
cp $(PRIVATE_HEADERS) $(INSTALL_INC_DIR)/private

.PHONY: install_lib
install_lib: libgc$(PROF).$A libgc$(PROF).$(EXT_FOR_SHARED_LIB) install_dirs
cp `vpath_find libgc$(PROF).$A libgc$(PROF).$(EXT_FOR_SHARED_LIB)` \
$(INSTALL_MERC_GC_LIB_DIR) \
install_lib: lib$(GC_GRADE).$A lib$(GC_GRADE).$(EXT_FOR_SHARED_LIB) install_dirs
cp `vpath_find lib$(GC_GRADE).$A lib$(GC_GRADE).$(EXT_FOR_SHARED_LIB)` \
$(INSTALL_MERC_GC_LIB_DIR)

#-----------------------------------------------------------------------------#
16 changes: 8 additions & 8 deletions boehm_gc/NT_MAKEFILE
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ OBJS= alloc.obj reclaim.obj allchblk.obj misc.obj mach_dep.obj os_dep.obj mark_r

all: gctest.exe cord\de.exe test_cpp.exe

dll: libgcd$(PROF)$(DLL_DEF_LIB).dll
libgc$(PROF)$(DLL_DEF_LIB).dll: libgcd.dll
dll: lib$(GC_GRADE)d$(DLL_DEF_LIB).dll
lib$(GC_GRADE)$(DLL_DEF_LIB).dll: libgcd.dll
# had -DSMALL_CONFIG
%.obj:%.c
$(cc) $(cdebug) $(CFLAGS) $(cvars) -DSILENT -DLARGE_CONFIG -DALL_INTERIOR_POINTERS -D__STDC__ /c /Fo$*.obj $*.c
Expand All @@ -38,16 +38,16 @@ $(OBJS) test.obj: gc_priv.h gc_hdrs.h gc.h
gc.lib: $(OBJS)
lib /MACHINE:i386 /out:gc.lib $(OBJS)
# a .def defining exports should be made....
libgcd$(PROF)$(DLL_DEF_LIB).dll: $(OBJS)
# $(link) /MACHINE:i386 /DLL /out:libgcd.dll $(OBJS)
lib$(GC_GRADE)d$(DLL_DEF_LIB).dll: $(OBJS)
# $(link) /MACHINE:i386 /DLL /out:lib$(GC_GRADE)d.dll $(OBJS)

# The original NT SDK used lib32 instead of lib


libgc$(PROF)$(DLL_DEF_LIB).lib: gc.lib
rm -f libgc$(PROF)$(DLL_DEF_LIB).lib
lib$(GC_GRADE)$(DLL_DEF_LIB).lib: gc.lib
rm -f lib$(GC_GRADE)$(DLL_DEF_LIB).lib
# `ln -s' here doesn't work with gnu-win32, so we use `cp' instead
cp gc.lib libgc$(PROF)$(DLL_DEF_LIB).lib
cp gc.lib lib$(GC_GRADE)$(DLL_DEF_LIB).lib

gctest.exe: test.obj libgc.lib
# The following works for win32 debugging. For win32s debugging use debugtype:coff
Expand Down Expand Up @@ -91,7 +91,7 @@ clean:
# so we need targets `a', `so', and `dll'.

.PHONY: lib
lib: libgc$(PROF).lib
lib: lib$(GC_GRADE).lib

.PHONY: so
so:
Expand Down
6 changes: 4 additions & 2 deletions browser/Mmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,10 @@ MGNUCFLAGS = $(DLL_CFLAGS)
LDFLAGS = -L$(LIBRARY_DIR) -L$(RUNTIME_DIR) -L$(BOEHM_GC_DIR)
LDLIBS = -l$(STD_LIB_NAME) -l$(RT_LIB_NAME) \
` case "$(GRADE)" in \
*.gc*.prof*) echo "-lgc_prof" ;; \
*.gc*) echo "-lgc" ;; \
*.par*.gc*.prof*) echo "-lpar_gc_prof" ;; \
*.par*.gc*) echo "-lpar_gc" ;; \
*.gc*.prof*) echo "-lgc_prof" ;; \
*.gc*) echo "-lgc" ;; \
esac \
`

Expand Down
8 changes: 5 additions & 3 deletions bytecode/Mmakefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#-----------------------------------------------------------------------------#
# Copyright (C) 1997-1999 The University of Melbourne.
# Copyright (C) 1997-2000 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.
#-----------------------------------------------------------------------------#
Expand Down Expand Up @@ -39,8 +39,10 @@ ORIG_CS = bytecode.c dict.c disasm.c machine.c mbi.c mbi_main.c \

LIBS = -lmer ` \
case "$(GRADE)" in \
*.gc.prof*) echo "-lgc_prof" ;; \
*.gc) echo "-lgc" ;; \
*.par*.gc*.prof*) echo "-lpar_gc_prof" ;; \
*.par*.gc*) echo "-lpar_gc" ;; \
*.gc*.prof*) echo "-lgc_prof" ;; \
*.gc*) echo "-lgc" ;; \
esac \
`

Expand Down
3 changes: 3 additions & 0 deletions compiler/Mmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ MLLIBS = $(TRACE_DIR)/lib$(TRACE_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 \
Expand Down
6 changes: 4 additions & 2 deletions library/Mmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,10 @@ LDFLAGS = -L$(BOEHM_GC_DIR) -L$(RUNTIME_DIR)
ALL_LDFLAGS = $(LDFLAGS) $(EXTRA_LDFLAGS)
LDLIBS = -l$(RT_LIB_NAME) \
` case "$(GRADE)" in \
*.gc*.prof*) echo "-lgc_prof" ;; \
*.gc*) echo "-lgc" ;; \
*.par*.gc*.prof*) echo "-lpar_gc_prof" ;; \
*.par*.gc*) echo "-lpar_gc" ;; \
*.gc*.prof*) echo "-lgc_prof" ;; \
*.gc*) echo "-lgc" ;; \
esac \
`
ALL_LDLIBS = $(LDLIBS) $(EXTRA_LDLIBS)
Expand Down
7 changes: 5 additions & 2 deletions profiler/Mmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,11 @@ MLLIBS = $(TRACE_DIR)/lib$(TRACE_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 ;; \
*.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 \
` -lm
MSL = MERCURY_SP_LIB_DIR=$(LIBRARY_DIR) $(SCRIPTS_DIR)/msl
Expand Down
6 changes: 4 additions & 2 deletions runtime/Mmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,10 @@ 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" ;; \
*.par*.gc*.prof*) echo "-lpar_gc_prof" ;; \
*.par*.gc*) echo "-lpar_gc" ;; \
*.gc*.prof*) echo "-lgc_prof" ;; \
*.gc*) echo "-lgc" ;; \
esac \
`
THREADLIBS = \
Expand Down
62 changes: 55 additions & 7 deletions scripts/ml.in
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ make_shared_lib=false
leave_shlib_dirs_relative=false
user_shlib_dirs=""
use_thread_libs=false
print_grade=false
print_gc_grade=false

# include the file `init_grade_options.sh-subr'
@INIT_GRADE_OPTIONS@
Expand All @@ -100,6 +102,14 @@ Diagnostics options:
executables, unresolved symbols are always errors.
This option is useful when building shared libraries
that are not intended to be self-contained.
--print-grade
Compute the grade of the Mercury libraries to link with based
on the command line options, print it to the standard output,
and then exit (don't actually link anything).
--print-gc-grade
Compute the base name of the garbage collection library to
link with based on the command line options, print it to the
standard output, and then exit (don't actually link anything).
Dynamic/static linking options:
--mercury-libs {shared, static, none}
Expand Down Expand Up @@ -284,6 +294,19 @@ EOF
use_thread_libs=false
;;

--print-grade)
print_grade=true
;;
--no-print-grade)
print_grade=false
;;
--print-gc-grade)
print_gc_grade=true
;;
--no-print-gc-grade)
print_gc_grade=false
;;

# include the file `parse_grade_options.sh-subr'
@PARSE_GRADE_OPTIONS@

Expand Down Expand Up @@ -438,21 +461,46 @@ case $stack_trace,$require_tracing in
false,false) ;;
esac

# if the --print-grade option is specified,
# then all we do is print the grade and then exit
case "$print_grade" in true)
echo $GRADE
exit 0
esac

# Compute the gc grade from the grade
case "$GRADE" in
*.gc.prof*)
LIBGC="-lgc_prof"
LIBGC_STATIC=`@CYGPATH@ $LIBDIR/$FULLARCH/libgc_prof.@LIB_SUFFIX@`
;;
*.par*.gc*.prof*)
gc_grade=par_gc_prof ;;
*.par*.gc*)
gc_grade=par_gc ;;
*.gc*.prof*)
gc_grade=gc_prof ;;
*.gc*)
LIBGC="-lgc"
LIBGC_STATIC=`@CYGPATH@ $LIBDIR/$FULLARCH/libgc.@LIB_SUFFIX@`
;;
gc_grade=gc ;;
*)
gc_grade=nogc ;;
esac

# if the --print-gc-grade option is specified,
# then all we do is print the gc grade and then exit
case "$print_gc_grade" in true)
echo $gc_grade
exit 0
esac

case "$gc_grade" in
nogc)
LIBGC=
LIBGC_STATIC=
;;
*)
LIBGC="-l$gc_grade"
LIBGC_STATIC=`@CYGPATH@ $LIBDIR/$FULLARCH/lib$gc_grade.@LIB_SUFFIX@`
;;
esac


case $readline in
true) ;;
false) READLINE_LIBRARIES=
Expand Down
2 changes: 2 additions & 0 deletions trace/Mmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ LDFLAGS = -L$(BROWSER_DIR) -L$(LIBRARY_DIR) \
-L$(RUNTIME_DIR) -L$(BOEHM_GC_DIR)
LDLIBS = -l$(BROWSER_LIB_NAME) -l$(STD_LIB_NAME) -l$(RT_LIB_NAME) \
` case "$(GRADE)" in \
*.par*.gc*.prof*) echo "-lpar_gc_prof" ;; \
*.par*.gc*) echo "-lpar_gc" ;; \
*.gc*.prof*) echo "-lgc_prof" ;; \
*.gc*) echo "-lgc" ;; \
esac \
Expand Down

0 comments on commit d7ed113

Please sign in to comment.