New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge build systems in the byterun directory #981

Merged
merged 24 commits into from Dec 29, 2016
Commits
Jump to file or symbol
Failed to load files and symbols.
+216 −250
Diff settings

Always

Just for now

View
@@ -13,77 +13,239 @@
#* *
#**************************************************************************
include Makefile.shared
include ../config/Makefile
CFLAGS=$(BYTECCCOMPOPTS) $(IFLEXDIR)
DFLAGS=-g -DDEBUG $(BYTECCCOMPOPTS) $(IFLEXDIR)
IFLAGS=$(CFLAGS) -DCAML_INSTR
OBJS=$(COMMONOBJS) $(UNIX_OR_WIN32).o main.o
DOBJS=$(OBJS:.o=.d.o) instrtrace.d.o
IOBJS=$(OBJS:.o=.i.o)
PICOBJS=$(OBJS:.o=.pic.o)
ifeq "$(SUPPORTS_SHARED_LIBRARIES)" "true"
all:: libcamlrun_pic.a libcamlrun_shared.so
endif
INSTALL_BINDIR=$(DESTDIR)$(BINDIR)
INSTALL_LIBDIR=$(DESTDIR)$(LIBDIR)
ocamlrun$(EXE): libcamlrun.a prims.o
$(MKEXE) $(BYTECCLINKOPTS) -o ocamlrun$(EXE) \
prims.o libcamlrun.a $(BYTECCLIBS)
# The PROGRAMS (resp. LIBRARIES) variable list the files to build and
# install as programs in $(INSTALL_BINDIR) (resp. libraries in
# $(INSTALL_LIBDIR))
ocamlrund$(EXE): libcamlrund.a prims.o
$(MKEXE) $(MKEXEDEBUGFLAG) $(BYTECCLINKOPTS) -o ocamlrund$(EXE) \
prims.o libcamlrund.a $(BYTECCLIBS)
PROGRAMS = ocamlrun$(EXE)
LIBRARIES = ld.conf libcamlrun.$(A)
ocamlruni$(EXE): prims.o libcamlruni.a
$(MKEXE) $(BYTECCLINKOPTS) -o $@ $^ $(BYTECCLIBS)
ifeq "$(RUNTIMED)" "true"
PROGRAMS += ocamlrund$(EXE)
LIBRARIES += libcamlrund.$(A)
endif
libcamlrun.a: $(OBJS)
$(ARCMD) rc libcamlrun.a $(OBJS)
$(RANLIB) libcamlrun.a
ifeq "$(RUNTIMEI)" "true"
PROGRAMS += ocamlruni$(EXE)
LIBRARIES += libcamlruni.$(A)
endif
libcamlrund.a: $(DOBJS)
$(ARCMD) rc libcamlrund.a $(DOBJS)
$(RANLIB) libcamlrund.a
ifeq "$(UNIX_OR_WIN32)" "unix"
ifeq "$(SUPPORTS_SHARED_LIBRARIES)" "true"
LIBRARIES += libcamlrun_pic.$(A) libcamlrun_shared.$(SO)
endif
endif
libcamlruni.a: $(IOBJS)
$(ARCMD) rc $@ $^
$(RANLIB) $@
CC=$(BYTECC)
libcamlrun_pic.a: $(PICOBJS)
$(ARCMD) rc libcamlrun_pic.a $(PICOBJS)
$(RANLIB) libcamlrun_pic.a
ifdef BOOTSTRAPPING_FLEXLINK
CFLAGS=-DBOOTSTRAPPING_FLEXLINK
else
CFLAGS=
endif
libcamlrun_shared.so: $(PICOBJS)
$(MKDLL) -o libcamlrun_shared.so $(PICOBJS) $(BYTECCLIBS)
# On Windows, OCAML_STDLIB_DIR needs to be defined dynamically
install::
ifeq "$(SUPPORTS_SHARED_LIBRARIES)" "true"
cp libcamlrun_shared.so "$(INSTALL_LIBDIR)/libcamlrun_shared.so"
cp libcamlrun_pic.a "$(INSTALL_LIBDIR)/libcamlrun_pic.a"
cd "$(INSTALL_LIBDIR)"; $(RANLIB) libcamlrun_pic.a
ifeq "$(UNIX_OR_WIN32)" "win32"
CFLAGS += -DOCAML_STDLIB_DIR='"$(LIBDIR)"'
endif
clean::
rm -f libcamlrun_shared.so libcamlrun_pic.a
CFLAGS += $(IFLEXDIR) $(BYTECCCOMPOPTS)
%.d.o: %.c
$(CC) -c $(DFLAGS) $< -o $@
DFLAGS=$(CFLAGS) -DDEBUG
IFLAGS=$(CFLAGS) -DCAML_INSTR
PICFLAGS=$(CFLAGS) $(SHAREDCCCOMPOPTS)
%.i.o: %.c
$(CC) -c $(IFLAGS) -o $@ $<
ifneq "$(CCOMPTYPE)" "msvc"
DFLAGS += -g
endif
%.pic.o: %.c
$(CC) -c $(CFLAGS) $(SHAREDCCCOMPOPTS) $< -o $@
ifeq "$(CCOMPTYPE)" "msvc"
OUTPUTOBJ=-Fo
else
OUTPUTOBJ=-o
endif
DBGO=d.$(O)
ifeq "$(UNIX_OR_WIN32)" "win32"
LIBS = $(call SYSLIB,ws2_32) $(EXTRALIBS)
ifdef BOOTSTRAPPING_FLEXLINK
MAKE_OCAMLRUN=$(MKEXE_BOOT)
else
MAKE_OCAMLRUN = $(MKEXE) -o $(1) $(2)
endif
else
LIBS = $(BYTECCLIBS)
MAKE_OCAMLRUN = $(MKEXE) $(BYTECCLINKOPTS) -o $(1) $(2)
endif
PRIMS=\
alloc.c array.c compare.c extern.c floats.c gc_ctrl.c hash.c \
intern.c interp.c ints.c io.c lexing.c md5.c meta.c obj.c parsing.c \
signals.c str.c sys.c terminfo.c callback.c weak.c finalise.c stacks.c \
dynlink.c backtrace_prim.c backtrace.c spacetime.c afl.c
OBJS=$(addsuffix .$(O), \
interp misc stacks fix_code startup_aux startup \
freelist major_gc minor_gc memory alloc roots globroots \
fail signals signals_byt printexc backtrace_prim backtrace \
compare ints floats str array io extern intern \
hash sys meta parsing gc_ctrl terminfo md5 obj \
lexing callback debugger weak compact finalise custom \
dynlink spacetime afl $(UNIX_OR_WIN32) main)
DOBJS=$(OBJS:.$(O)=.$(DBGO)) instrtrace.$(DBGO)
IOBJS=$(OBJS:.$(O)=.i.$(O))
PICOBJS=$(OBJS:.$(O)=.pic.$(O))
.PHONY: all
all: $(LIBRARIES) $(PROGRAMS)
ld.conf: ../config/Makefile
echo "$(STUBLIBDIR)" > $@
echo "$(LIBDIR)" >> $@
.PHONY: install
install:
cp $(PROGRAMS) "$(INSTALL_BINDIR)"
cp $(LIBRARIES) "$(INSTALL_LIBDIR)"
mkdir -p "$(INSTALL_LIBDIR)/caml"
for i in caml/*.h; do \
sed -f ../tools/cleanup-header $$i \
> "$(INSTALL_LIBDIR)/$$i"; \
done
# If primitives contain duplicated lines (e.g. because the code is defined
# like
# #ifdef X
# CAMLprim value caml_foo() ...
# #else
# CAMLprim value caml_foo() ...
# end), horrible things will happen (duplicated entries in Runtimedef ->
# double registration in Symtable -> empty entry in the PRIM table ->
# the bytecode interpreter is confused).
# We sort the primitive file and remove duplicates to avoid this problem.
# Warning: we use "sort | uniq" instead of "sort -u" because in the MSVC
# port, the "sort" program in the path is Microsoft's and not cygwin's
# Warning: POSIX sort is locale dependent, that's why we set LC_ALL explicitly.
# Sort is unstable for "is_directory" and "isatty"
# see http://pubs.opengroup.org/onlinepubs/9699919799/utilities/sort.html:
# "using sort to process pathnames, it is recommended that LC_ALL .. set to C"
primitives : $(PRIMS)
sed -n -e "s/CAMLprim value \([a-z0-9_][a-z0-9_]*\).*/\1/p" $(PRIMS) \
| LC_ALL=C sort | uniq > primitives
prims.c : primitives
(echo '#define CAML_INTERNALS'; \
echo '#include "caml/mlvalues.h"'; \
echo '#include "caml/prims.h"'; \
sed -e 's/.*/extern value &();/' primitives; \
echo 'c_primitive caml_builtin_cprim[] = {'; \
sed -e 's/.*/ &,/' primitives; \
echo ' 0 };'; \
echo 'char * caml_names_of_builtin_cprim[] = {'; \
sed -e 's/.*/ "&",/' primitives; \
echo ' 0 };') > prims.c
caml/opnames.h : caml/instruct.h
sed -e '/\/\*/d' \
-e '/^#/d' \
-e 's/enum /char * names_of_/' \
-e 's/{$$/[] = {/' \
-e 's/\([[:upper:]][[:upper:]_0-9]*\)/"\1"/g' caml/instruct.h \
> caml/opnames.h
# caml/jumptbl.h is required only if you have GCC 2.0 or later
caml/jumptbl.h : caml/instruct.h
sed -n -e '/^ /s/ \([A-Z]\)/ \&\&lbl_\1/gp' \
-e '/^}/q' caml/instruct.h > caml/jumptbl.h
caml/version.h : ../VERSION ../tools/make-version-header.sh
../tools/make-version-header.sh ../VERSION > caml/version.h
.PHONY: clean
clean:
rm -f $(LIBRARIES) $(PROGRAMS) *.$(O) *.$(A) *.$(SO)
rm -f primitives prims.c caml/opnames.h caml/jumptbl.h
rm -f caml/version.h
ocamlrun$(EXE): prims.$(O) libcamlrun.$(A)
$(call MAKE_OCAMLRUN,$@,$^ $(LIBS))
libcamlrun.$(A): $(OBJS)
$(call MKLIB,$@, $^)
ocamlrund$(EXE): prims.$(O) libcamlrund.$(A)
$(MKEXE) $(MKEXEDEBUGFLAG) $(BYTECCLINKOPTS) -o $@ $^ $(LIBS)
libcamlrund.$(A): $(DOBJS)
$(call MKLIB,$@, $^)
ocamlruni$(EXE): prims.$(O) libcamlruni.$(A)
$(MKEXE) $(BYTECCLINKOPTS) -o $@ $^ $(LIBS)
libcamlruni.$(A): $(IOBJS)
$(call MKLIB,$@, $^)
libcamlrun_pic.$(A): $(PICOBJS)
$(call MKLIB,$@, $^)
libcamlrun_shared.$(SO): $(PICOBJS)
$(MKDLL) -o $@ $^ $(BYTECCLIBS)
%.$(O): %.c
$(CC) $(CFLAGS) -c $<
%.$(DBGO): %.c
$(CC) $(DFLAGS) -c $(OUTPUTOBJ)$@ $<
%.i.$(O): %.c
$(CC) $(IFLAGS) -c $(OUTPUTOBJ)$@ $<
%.pic.$(O): %.c
$(CC) $(PICFLAGS) -c $(OUTPUTOBJ)$@ $<
ifneq "$(TOOLCHAIN)" "msvc"
.PHONY: depend
depend : prims.c caml/opnames.h caml/jumptbl.h caml/version.h
-$(CC) -MM $(BYTECCCOMPOPTS) *.c > .depend
-$(CC) -MM $(BYTECCCOMPOPTS) -DDEBUG *.c | sed -e 's/\.o/.d.o/' \
>> .depend
-$(CC) -MM $(BYTECCCOMPOPTS) -DCAML_INSTR *.c | sed -e 's/\.o/.i.o/' \
>> .depend
-$(CC) -MM $(BYTECCCOMPOPTS) *.c | sed -e 's/\.o/.pic.o/' >> .depend
.PHONY: depend
endif
ifeq "$(UNIX_OR_WIN32)" "win32"
.depend.nt: .depend
rm -f .depend.win32
echo "win32.o: win32.c caml/fail.h caml/compatibility.h \\"\
>> .depend.win32
echo " caml/misc.h caml/config.h ../config/m.h ../config/s.h \\"\
>> .depend.win32
echo " caml/mlvalues.h caml/memory.h caml/gc.h caml/major_gc.h \\"\
>> .depend.win32
echo " caml/freelist.h caml/minor_gc.h caml/osdeps.h caml/signals.h"\
>> .depend.win32
cat .depend >> .depend.win32
sed -ne '/\.pic\.o/q' \
-e 's/^\(.*\)\.d\.o:/\1.$$(DBGO):/' \
-e 's/^\(.*\)\.o:/\1.$$(O):/' \
-e p \
.depend.win32 > .depend.nt
rm -f .depend.win32
include .depend.nt
else
include .depend
endif
View
@@ -13,59 +13,4 @@
#* *
#**************************************************************************
include Makefile.shared
CFLAGS=-DOCAML_STDLIB_DIR='"$(LIBDIR)"' $(IFLEXDIR)
DFLAGS=$(CFLAGS) -DDEBUG
ifdef BOOTSTRAPPING_FLEXLINK
MAKE_OCAMLRUN=$(MKEXE_BOOT)
CFLAGS:=-DBOOTSTRAPPING_FLEXLINK $(CFLAGS)
else
MAKE_OCAMLRUN=$(MKEXE) -o $(1) $(2)
endif
DBGO=d.$(O)
OBJS=$(COMMONOBJS:.o=.$(O)) win32.$(O) main.$(O)
DOBJS=$(OBJS:.$(O)=.$(DBGO)) instrtrace.$(DBGO)
ocamlrun$(EXE): libcamlrun.$(A) prims.$(O)
$(call MAKE_OCAMLRUN,ocamlrun$(EXE),prims.$(O) libcamlrun.$(A) \
$(call SYSLIB,ws2_32) $(EXTRALIBS))
ocamlrund$(EXE): libcamlrund.$(A) prims.$(O) main.$(O)
$(MKEXE) -o ocamlrund$(EXE) prims.$(O) \
$(call SYSLIB,ws2_32) $(EXTRALIBS) libcamlrund.$(A)
libcamlrun.$(A): $(OBJS)
$(call MKLIB,libcamlrun.$(A),$(OBJS))
libcamlrund.$(A): $(DOBJS)
$(call MKLIB,libcamlrund.$(A),$(DOBJS))
%.$(O): %.c
$(CC) $(CFLAGS) $(BYTECCCOMPOPTS) -c $<
# It is imperative that there is no space after $(NAME_OBJ_FLAG)
%.$(DBGO): %.c
$(CC) $(DFLAGS) $(BYTECCDBGCOMPOPTS) -c $(NAME_OBJ_FLAG)$@ $<
.depend.nt: .depend
rm -f .depend.win32
echo "win32.o: win32.c caml/fail.h caml/compatibility.h \\"\
>> .depend.win32
echo " caml/misc.h caml/config.h ../config/m.h ../config/s.h \\"\
>> .depend.win32
echo " caml/mlvalues.h caml/memory.h caml/gc.h caml/major_gc.h \\"\
>> .depend.win32
echo " caml/freelist.h caml/minor_gc.h caml/osdeps.h caml/signals.h"\
>> .depend.win32
cat .depend >> .depend.win32
sed -ne '/\.pic\.o/q' \
-e 's/^\(.*\)\.d\.o:/\1.$$(DBGO):/' \
-e 's/^\(.*\)\.o:/\1.$$(O):/' \
-e p \
.depend.win32 > .depend.nt
rm -f .depend.win32
include .depend.nt
include Makefile
Oops, something went wrong.
ProTip! Use n and p to navigate between commits in a pull request.