Skip to content

Commit

Permalink
Introduce and use ROOTDIR in more makefiles
Browse files Browse the repository at this point in the history
  • Loading branch information
shindere committed Sep 17, 2018
1 parent ba6362a commit 01b65ac
Show file tree
Hide file tree
Showing 9 changed files with 152 additions and 162 deletions.
119 changes: 49 additions & 70 deletions debugger/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,87 +13,66 @@
#* *
#**************************************************************************

include ../Makefile.config
include ../Makefile.common
ROOTDIR = ..

UNIXDIR=../otherlibs/$(UNIXLIB)
CAMLRUN ?= ../boot/ocamlrun
CAMLYACC ?= ../yacc/ocamlyacc$(EXE)
include $(ROOTDIR)/Makefile.config
include $(ROOTDIR)/Makefile.common

CAMLC=$(CAMLRUN) ../ocamlc -g -nostdlib -I ../stdlib
UNIXDIR=$(ROOTDIR)/otherlibs/$(UNIXLIB)
CAMLRUN ?= $(ROOTDIR)/boot/ocamlrun
CAMLYACC ?= $(ROOTDIR)/yacc/ocamlyacc$(EXE)

CAMLC=$(CAMLRUN) $(ROOTDIR)/ocamlc -g -nostdlib -I $(ROOTDIR)/stdlib
COMPFLAGS=$(INCLUDES) -absname -w +a-4-9-41-42-44-45-48 -warn-error A \
-safe-string -strict-sequence -strict-formats
LINKFLAGS=-linkall -I $(UNIXDIR)
YACCFLAGS=
CAMLLEX=$(CAMLRUN) ../boot/ocamllex
CAMLDEP=$(CAMLRUN) ../tools/ocamldep
CAMLLEX=$(CAMLRUN) $(ROOTDIR)/boot/ocamllex
CAMLDEP=$(CAMLRUN) $(ROOTDIR)/tools/ocamldep
DEPFLAGS=$(INCLUDES)

INCLUDES=\
-I ../utils -I ../parsing -I ../typing -I ../bytecomp -I ../toplevel \
-I ../driver -I $(UNIXDIR)

OTHEROBJS=\
$(UNIXDIR)/unix.cma \
../utils/config.cmo ../utils/build_path_prefix_map.cmo ../utils/misc.cmo \
../utils/identifiable.cmo ../utils/numbers.cmo \
../utils/arg_helper.cmo ../utils/clflags.cmo \
../utils/consistbl.cmo ../utils/warnings.cmo \
../utils/terminfo.cmo \
../parsing/location.cmo ../parsing/longident.cmo ../parsing/docstrings.cmo \
../parsing/syntaxerr.cmo \
../parsing/ast_helper.cmo ../parsing/ast_mapper.cmo \
../parsing/ast_iterator.cmo ../parsing/attr_helper.cmo \
../parsing/builtin_attributes.cmo \
../typing/ident.cmo ../typing/path.cmo ../typing/types.cmo \
../typing/btype.cmo ../typing/primitive.cmo ../typing/typedtree.cmo \
../typing/subst.cmo ../typing/predef.cmo \
../typing/datarepr.cmo ../typing/cmi_format.cmo ../typing/env.cmo \
../typing/oprint.cmo \
../typing/ctype.cmo ../typing/printtyp.cmo ../typing/mtype.cmo \
../typing/envaux.cmo \
../bytecomp/runtimedef.cmo ../bytecomp/bytesections.cmo \
../bytecomp/dll.cmo ../bytecomp/meta.cmo ../bytecomp/symtable.cmo \
../bytecomp/opcodes.cmo ../driver/compdynlink.cmo \
../toplevel/genprintval.cmo


OBJS=\
int64ops.cmo \
primitives.cmo \
unix_tools.cmo \
debugger_config.cmo \
parameters.cmo \
lexer.cmo \
input_handling.cmo \
question.cmo \
debugcom.cmo \
exec.cmo \
source.cmo \
pos.cmo \
checkpoints.cmo \
events.cmo \
program_loading.cmo \
symbols.cmo \
breakpoints.cmo \
trap_barrier.cmo \
history.cmo \
printval.cmo \
show_source.cmo \
time_travel.cmo \
program_management.cmo \
frames.cmo \
eval.cmo \
show_information.cmo \
loadprinter.cmo \
parser.cmo \
command_line.cmo \
main.cmo
DIRECTORIES=$(UNIXDIR) $(addprefix $(ROOTDIR)/,\
utils parsing typing bytecomp toplevel driver)

INCLUDES=$(addprefix -I ,$(DIRECTORIES))

utils_modules := $(addprefix utils/,\
config build_path_prefix_map misc identifiable numbers arg_helper clflags \
consistbl warnings terminfo)

parsing_modules := $(addprefix parsing/,\
location longident docstrings syntaxerr ast_helper ast_mapper ast_iterator \
attr_helper builtin_attributes)

typing_modules := $(addprefix typing/,\
ident path types btype primitive typedtree subst predef datarepr \
cmi_format env oprint ctype printtyp mtype envaux)

bytecomp_modules := $(addprefix bytecomp/,\
runtimedef bytesections dll meta symtable opcodes)

other_compiler_modules := \
driver/compdynlink toplevel/genprintval

compiler_modules := $(addprefix $(ROOTDIR)/,\
$(utils_modules) $(parsing_modules) $(typing_modules) \
$(bytecomp_modules) $(other_compiler_modules))

debugger_modules := \
int64ops primitives unix_tools debugger_config parameters lexer \
input_handling question debugcom exec source pos checkpoints events \
program_loading symbols breakpoints trap_barrier history printval \
show_source time_travel program_management frames eval \
show_information loadprinter parser command_line main

all_modules := $(compiler_modules) $(debugger_modules)

all_objects := $(addsuffix .cmo,$(all_modules))

all: ocamldebug$(EXE)

ocamldebug$(EXE): $(OBJS) $(OTHEROBJS)
$(CAMLC) $(LINKFLAGS) -o ocamldebug$(EXE) -linkall $(OTHEROBJS) $(OBJS)
ocamldebug$(EXE): $(UNIXDIR)/unix.cma $(all_objects)
$(CAMLC) $(LINKFLAGS) -o $@ -linkall $^

install:
$(INSTALL_PROG) ocamldebug$(EXE) "$(INSTALL_BINDIR)/ocamldebug$(EXE)"
Expand Down
6 changes: 4 additions & 2 deletions emacs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@
#* *
#**************************************************************************

include ../Makefile.config
include ../Makefile.common
ROOTDIR = ..

include $(ROOTDIR)/Makefile.config
include $(ROOTDIR)/Makefile.common

# Files to install
FILES= caml-font.el caml-hilit.el caml.el camldebug.el \
Expand Down
3 changes: 2 additions & 1 deletion man/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
#* *
#**************************************************************************

include ../Makefile.config
ROOTDIR = ..
include $(ROOTDIR)/Makefile.config

INSTALL_DIR=$(DESTDIR)$(MANDIR)/man$(PROGRAMS_MAN_SECTION)

Expand Down
61 changes: 26 additions & 35 deletions otherlibs/dynlink/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,19 @@

# FIXME reduce redundancy by including ../Makefile

include ../../Makefile.config
include ../../Makefile.common
ROOTDIR = ../..

CAMLRUN ?= ../../boot/ocamlrun
include $(ROOTDIR)/Makefile.config
include $(ROOTDIR)/Makefile.common

CAMLRUN ?= $(ROOTDIR)/boot/ocamlrun

ROOTDIR = ../..
OCAMLC = $(CAMLRUN) $(ROOTDIR)/ocamlc -nostdlib -I $(ROOTDIR)/stdlib
OCAMLOPT = $(CAMLRUN) $(ROOTDIR)/ocamlopt -nostdlib -I $(ROOTDIR)/stdlib

INCLUDES=-I ../../utils -I ../../typing -I ../../bytecomp -I ../../asmcomp
INCLUDES=$(addprefix -I $(ROOTDIR)/,utils typing bytecomp asmcomp)
COMPFLAGS=$(INCLUDES) -absname -w +a-4-9-41-42-44-45-48 -bin-annot -g \
-I ../../stdlib -warn-error A \
-I $(ROOTDIR)/stdlib -warn-error A \
-safe-string -strict-sequence -strict-formats
ifeq "$(FLAMBDA)" "true"
OPTCOMPFLAGS=-O3
Expand All @@ -38,29 +39,21 @@ endif

OBJS=dynlinkaux.cmo dynlink.cmo

COMPILEROBJS=\
../../utils/config.cmo ../../utils/build_path_prefix_map.cmo \
../../utils/misc.cmo \
../../utils/identifiable.cmo ../../utils/numbers.cmo \
../../utils/arg_helper.cmo ../../utils/clflags.cmo \
../../utils/consistbl.cmo \
../../utils/terminfo.cmo ../../utils/warnings.cmo \
../../parsing/asttypes.cmi \
../../parsing/location.cmo ../../parsing/longident.cmo \
../../parsing/docstrings.cmo ../../parsing/syntaxerr.cmo \
../../parsing/ast_helper.cmo \
../../parsing/ast_mapper.cmo ../../parsing/ast_iterator.cmo \
../../parsing/attr_helper.cmo \
../../parsing/builtin_attributes.cmo \
../../typing/ident.cmo ../../typing/path.cmo \
../../typing/primitive.cmo ../../typing/types.cmo \
../../typing/btype.cmo ../../typing/subst.cmo ../../typing/predef.cmo \
../../typing/datarepr.cmo ../../typing/cmi_format.cmo ../../typing/env.cmo \
../../bytecomp/lambda.cmo ../../bytecomp/instruct.cmo \
../../bytecomp/cmo_format.cmi ../../bytecomp/opcodes.cmo \
../../bytecomp/runtimedef.cmo ../../bytecomp/bytesections.cmo \
../../bytecomp/dll.cmo ../../bytecomp/meta.cmo \
../../bytecomp/symtable.cmo
COMPILEROBJS = $(addprefix $(ROOTDIR)/,\
utils/config.cmo utils/build_path_prefix_map.cmo utils/misc.cmo \
utils/identifiable.cmo utils/numbers.cmo utils/arg_helper.cmo \
utils/clflags.cmo utils/consistbl.cmo \
utils/terminfo.cmo utils/warnings.cmo \
parsing/asttypes.cmi parsing/location.cmo parsing/longident.cmo \
parsing/docstrings.cmo parsing/syntaxerr.cmo \
parsing/ast_helper.cmo parsing/ast_mapper.cmo parsing/ast_iterator.cmo \
parsing/attr_helper.cmo parsing/builtin_attributes.cmo \
typing/ident.cmo typing/path.cmo typing/primitive.cmo typing/types.cmo \
typing/btype.cmo typing/subst.cmo typing/predef.cmo \
typing/datarepr.cmo typing/cmi_format.cmo typing/env.cmo \
bytecomp/lambda.cmo bytecomp/instruct.cmo bytecomp/cmo_format.cmi \
bytecomp/opcodes.cmo bytecomp/runtimedef.cmo bytecomp/bytesections.cmo \
bytecomp/dll.cmo bytecomp/meta.cmo bytecomp/symtable.cmo)

NATOBJS=dynlink.cmx

Expand All @@ -69,15 +62,13 @@ all: dynlink.cma extract_crc
allopt: dynlink.cmxa

dynlink.cma: $(OBJS)
$(OCAMLC) $(COMPFLAGS) -ccopt "$(NATDYNLINKOPTS)" -a -o dynlink.cma \
$(OBJS)
$(OCAMLC) $(COMPFLAGS) -ccopt "$(NATDYNLINKOPTS)" -a -o $@ $^

dynlink.cmxa: $(NATOBJS)
$(OCAMLOPT) $(COMPFLAGS) -ccopt "$(NATDYNLINKOPTS)" -a -o dynlink.cmxa \
$(NATOBJS)
$(OCAMLOPT) $(COMPFLAGS) -ccopt "$(NATDYNLINKOPTS)" -a -o $@ $^

dynlinkaux.cmo: $(COMPILEROBJS)
$(OCAMLC) $(COMPFLAGS) -pack -o dynlinkaux.cmo $(COMPILEROBJS)
$(OCAMLC) $(COMPFLAGS) -pack -o $@ $^

dynlinkaux.cmi: dynlinkaux.cmo

Expand All @@ -87,7 +78,7 @@ dynlink.cmx: dynlink.cmi natdynlink.ml
rm -f dynlink.mlopt

extract_crc: dynlink.cma extract_crc.cmo
$(OCAMLC) -o extract_crc dynlink.cma extract_crc.cmo
$(OCAMLC) -o $@ $^

install:
$(INSTALL_DATA) \
Expand Down
37 changes: 19 additions & 18 deletions otherlibs/threads/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,25 @@

# FIXME reduce redundancy by including ../Makefile

include ../../Makefile.config
include ../../Makefile.common
ROOTDIR = ../..

CAMLRUN ?= ../../boot/ocamlrun
include $(ROOTDIR)/Makefile.config
include $(ROOTDIR)/Makefile.common

CAMLRUN ?= $(ROOTDIR)/boot/ocamlrun

OC_CFLAGS += $(SHAREDLIB_CFLAGS)
OC_CPPFLAGS += -I../../runtime
ROOTDIR=../..
OC_CPPFLAGS += -I$(ROOTDIR)/runtime
CAMLC=$(CAMLRUN) $(ROOTDIR)/ocamlc -nostdlib \
-I $(ROOTDIR)/stdlib -I $(ROOTDIR)/otherlibs/unix
MKLIB=$(CAMLRUN) ../../tools/ocamlmklib
MKLIB=$(CAMLRUN) $(ROOTDIR)/tools/ocamlmklib
COMPFLAGS=-w +33..39 -warn-error A -bin-annot -g -safe-string

C_OBJS=scheduler.o

CAML_OBJS=thread.cmo mutex.cmo condition.cmo event.cmo threadUnix.cmo

LIB=../../stdlib
LIB=$(ROOTDIR)/stdlib

# Object file prefix
P=stdlib__
Expand Down Expand Up @@ -69,13 +70,13 @@ libvmthreads.a: $(C_OBJS)
$(MKLIB) -o threads -oc vmthreads $(C_OBJS)

threads.cma: $(CAML_OBJS)
$(MKLIB) -ocamlc '$(CAMLC)' -o threads -oc vmthreads $(CAML_OBJS)
$(MKLIB) -ocamlc '$(CAMLC)' -o threads -oc vmthreads $^

stdlib.cma: $(LIB_OBJS)
$(CAMLC) -a -o stdlib.cma $(LIB_OBJS)
$(CAMLC) -a -o $@ $^

unix.cma: $(UNIXLIB_OBJS)
$(MKLIB) -ocamlc '$(CAMLC)' -o unix -linkall $(UNIXLIB_OBJS)
$(MKLIB) -ocamlc '$(CAMLC)' -o unix -linkall $^

stdlib.cmo: stdlib.mli stdlib.cmi stdlib.ml
$(CAMLC) ${COMPFLAGS} -nopervasives \
Expand All @@ -85,23 +86,23 @@ stdlib.mli: $(LIB)/stdlib.mli
ln -s $(LIB)/stdlib.mli stdlib.mli

stdlib.cmi: $(LIB)/stdlib.cmi
rm -f stdlib.cmi
ln -s $(LIB)/stdlib.cmi stdlib.cmi
rm -f $@
ln -s $< $@

$(P)marshal.cmo: marshal.mli $(P)marshal.cmi marshal.ml
$(CAMLC) ${COMPFLAGS} -o$@ -c marshal.ml
$(P)marshal.cmo: marshal.ml marshal.mli $(P)marshal.cmi
$(CAMLC) ${COMPFLAGS} -o$@ -c $<

marshal.mli: $(LIB)/marshal.mli
ln -s $(LIB)/marshal.mli marshal.mli
ln -s $< $@

$(P)marshal.cmi: $(LIB)/$(P)marshal.cmi
ln -s $(LIB)/$(P)marshal.cmi $(P)marshal.cmi
ln -s $< $@

unix.mli: $(UNIXLIB)/unix.mli
ln -s -f $(UNIXLIB)/unix.mli unix.mli
ln -s -f $< $@

unix.cmi: $(UNIXLIB)/unix.cmi
ln -s -f $(UNIXLIB)/unix.cmi unix.cmi
ln -s -f $< $@

unix.cmo: unix.mli unix.cmi $(UNIXLIB)/unixLabels.cmo
$(CAMLC) ${COMPFLAGS} -c unix.ml
Expand Down
14 changes: 8 additions & 6 deletions runtime/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@
#* *
#**************************************************************************

include ../Makefile.config
include ../Makefile.common
ROOTDIR = ..

include $(ROOTDIR)/Makefile.config
include $(ROOTDIR)/Makefile.common

# Lists of source files

Expand Down Expand Up @@ -167,7 +169,7 @@ OC_PROF_CFLAGS=-pg
OC_PROF_CPPFLAGS=-DPROFILING
endif

ASPPFLAGS = -DSYS_$(SYSTEM) -I../runtime
ASPPFLAGS = -DSYS_$(SYSTEM) -I$(ROOTDIR)/runtime
ifeq "$(UNIX_OR_WIN32)" "unix"
ASPPFLAGS += -DMODEL_$(MODEL)
endif
Expand Down Expand Up @@ -224,7 +226,7 @@ distclean: clean

# Generated non-object files

ld.conf: ../Makefile.config
ld.conf: $(ROOTDIR)/Makefile.config
echo "$(STUBLIBDIR)" > $@
echo "$(LIBDIR)" >> $@

Expand Down Expand Up @@ -277,8 +279,8 @@ caml/jumptbl.h : caml/instruct.h
sed -n -e '/^ /s/ \([A-Z]\)/ \&\&lbl_\1/gp' \
-e '/^}/q' > $@

caml/version.h : ../VERSION ../tools/make-version-header.sh
../tools/make-version-header.sh ../VERSION > caml/version.h
caml/version.h : $(ROOTDIR)/tools/make-version-header.sh $(ROOTDIR)/VERSION
$^ > $@

# Libraries and programs

Expand Down
Loading

0 comments on commit 01b65ac

Please sign in to comment.