[m-dev.] For Review: Bytecode interpreter

Levi Cameron l.cameron2 at ugrad.unimelb.edu.au
Thu Jan 25 13:18:03 AEDT 2001


Fergus Henderson wrote:

>
> ...
>

> 
> > +EXTRA_MGNUCFLAGS= --no-ansi $(INC_DIRS)
> 
> `--no-ansi' should preferably not be used.
> 
> If it has to be used, then you should document exactly why it needs to
> be used.
> 

mb_disasm uses snprintf

If I try MGNUCFLAGS-mb_disasm = --no-ansi
mgnuc gets the --no-ansi option but then I get the error message:

cc1: Invalid option `-fno-ansi`

Making it a global C option is the only thing I can find to get it to
work (short of explicitly writing a custom make rule for mb_disasm.c)

> > +MFILES               =       \
> > +                     simple01.m \
> > +                     mb_interface_stub.m
>
> Hmm, generally we have avoided including `.m' files and `.c' source
> files in the same directory (that is why the `trace' and `browser'
> directories are separate, for example).

I wondered about that but there is only one bytecode mercury file -
should this perhaps go in its own subdirectory nonetheless?

 Here a much cleaner makefile (rather than just a hacked version of the
original bytecode makefile, as is was previously). It should fix all
the issues you raised except those listed above.
 It no longer depends on any particular Mmake.params settings.
=================================================================================
#-----------------------------------------------------------------------------#
# Copyright (C) 1998-2001 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 bytecode interpreter

MAIN_TARGET=all

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

#-----------------------------------------------------------------------------#
# NOTE: any library functions that called from bytecode must be compiled
# with trace information. (So their entry labels can be looked up)
#-----------------------------------------------------------------------------#

MERCURY_SYSTEM	= \
		$(RUNTIME_DIR)/*.c $(RUNTIME_DIR)/*.h \
		$(RUNTIME_DIR)/machdeps/*.c $(RUNTIME_DIR)/machdeps/*.h\
		$(TRACE_DIR)/*.h $(TRACE_DIR)/*.c \
		$(BROWSER_DIR)/*.h $(BROWSER_DIR)/*.c \
		$(BOEHM_GC_DIR)/*.h $(BOEHM_GC_DIR)/include/*.h

MERCURY_INC	= \
		-I$(LIBRARY_DIR) \
		 -I$(RUNTIME_DIR) \
		 -I$(BOEHM_GC_DIR) \
		 -I$(BOEHM_GC_DIR)/include \
		 -I$(TRACE_DIR)
	
#-----------------------------------------------------------------------------#

MGNUCFLAGS	= --no-ansi $(MERCURY_INC)

MCFLAGS		= --generate-bytecode -O 0

C2INITFLAGS	= --trace
MLFLAGS		= --trace
MCFLAGS		= --trace shallow

#-----------------------------------------------------------------------------#
# keep these lists in alphabetical order, please

# bytecode headers
MB_HDRS		= \
		mb_basetypes.h \
		mb_bytecode.h \
		mb_disasm.h \
		mb_interface.h \
		mb_machine.h \
		mb_machine_def.h \
		mb_machine_show.h \
		mb_mem.h \
		mb_module.h \
		mb_stack.h \
		mb_util.h

# bytecode c files
MB_CFILES	= \
		mb_bytecode.c \
		mb_disasm.c \
		mb_interface.c \
		mb_machine.c \
		mb_machine_show.c \
		mb_mem.c \
		mb_module.c \
		mb_stack.c \
		mb_util.c

# bytecode mercury files
MB_MFILES	= \
		mb_interface_stub.m

# bytecode object files
MB_OBJS		= $(MB_MFILES:%.m=%.o) $(MB_CFILES:%.c=%.o)

$(MB_OBJS): $(MB_HDRS)


#-----------------------------------------------------------------------------#
# The actual program (as distinct from bytecode interpreter)

HDRS		=

CFILES		= 

MFILES		= simple01.m

OBJS		= simple01_init.o $(MFILES:%.m=%.o) $(CFILES:%.c=%.o)

$(OBJS): $(HDRS) $(MB_HDRS)

#-----------------------------------------------------------------------------#
ALL_HDRS	= $(HDRS) $(MB_HDRS)
ALL_MFILES	= $(MFILES) $(MB_MFILES)
ALL_CFILES	= $(CFILES) $(MB_CFILES)
ALL_OBJS	= $(OBJS) $(MB_OBJS)

ALL_DEPENDS=$(ALL_MFILES:%=%.depend)

#-----------------------------------------------------------------------------#
.PHONY: all
all: test

test: $(ALL_OBJS)
	$(ML) $(ALL_GRADEFLAGS) $(ALL_MLFLAGS) $(ALL_OBJS) \
	-o test

#-----------------------------------------------------------------------------#
# tags actually depends on $(MERCURY_SYSTEM) too but since changes to
that
# hardly ever have an effect, just ignore them
tags: $(ALL_MFILES) $(ALL_CFILES) $(ALL_HDRS)
	ctags $(TAGFLAGS) $(ALL_MFILES) $(ALL_CFILES) $(ALL_HDRS)
$(MERCURY_SYSTEM)


.PHONY: depend
depend: $(ALL_DEPENDS)


clean_local: clean_o

realclean_local: realclean_o

.PHONY: clean_o
clean_o:
	rm -f $(ALL_MFILES:%.m=%.mbc)
	rm -f $(ALL_MFILES:%.m=%.bytedebug)
	rm -f $(ALL_OBJS)

.PHONY: realclean_o
realclean_o:
	rm -f tags test

#-----------------------------------------------------------------------------#
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list