summaryrefslogtreecommitdiff
path: root/byterun/Makefile.nt
blob: 51881c64a9e37e82f6d914d9a3ba5178e8ded426 (plain)
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
#########################################################################
#                                                                       #
#                            Objective Caml                             #
#                                                                       #
#            Xavier Leroy, projet Cristal, INRIA Rocquencourt           #
#                                                                       #
#   Copyright 1999 Institut National de Recherche en Informatique et    #
#   en Automatique.  All rights reserved.  This file is distributed     #
#   under the terms of the GNU Library General Public License, with     #
#   the special exception on linking described in file ../LICENSE.      #
#                                                                       #
#########################################################################

# $Id$

!include ..\config\Makefile.nt

CC=$(BYTECC)
CFLAGS=-DIN_OCAMLRUN -DOCAML_STDLIB_DIR="\"$(LIBDIR:\=\\)\""

OBJS=interp.obj misc.obj stacks.obj fix_code.obj startup.obj main.obj \
  fail.obj signals.obj freelist.obj major_gc.obj minor_gc.obj \
  memory.obj alloc.obj roots.obj compare.obj ints.obj floats.obj \
  str.obj array.obj io.obj extern.obj intern.obj hash.obj sys.obj \
  meta.obj parsing.obj gc_ctrl.obj terminfo.obj md5.obj obj.obj lexing.obj \
  win32.obj printexc.obj callback.obj debugger.obj weak.obj compact.obj \
  finalise.obj custom.obj backtrace.obj globroots.obj dynlink.obj

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

PUBLIC_INCLUDES=mlvalues.h alloc.h misc.h callback.h fail.h custom.h intext.h

all: ocamlrun.exe libcamlrun.lib
	if not exist ..\stdlib\caml mkdir ..\stdlib\caml
	cp $(PUBLIC_INCLUDES) ..\stdlib\caml
	sed -e "/#include .*\/m.h/r ..\config\m.h" \
            -e "/#include .*\/s.h/r ..\config\s.h" \
            -e "/#include /d" config.h > ..\stdlib\caml\config.h
	sed -e "/#include .*gc\.h/d" \
	    -e "/#define Alloc_small/,/^}/d" \
	    -e "/Modify/,/^}/d" memory.h > ..\stdlib\caml\memory.h

ocamlrun.exe: $(OBJS:.obj=.dobj) prims.dobj
	link /nologo /out:ocamlrun.exe $(OBJS:.obj=.dobj) prims.dobj $(CCLIBS)

libcamlrun.lib: $(OBJS:.obj=.sobj)
	$(MKLIB)libcamlrun.lib $(OBJS:.obj=.sobj)

install:
	cp ocamlrun.exe $(BINDIR)\ocamlrun.exe
	cp ocamlrun.lib $(LIBDIR)\ocamlrun.lib
	cp libcamlrun.lib $(LIBDIR)\libcamlrun.lib
	if not exist $(LIBDIR)\caml mkdir $(LIBDIR)\caml
	cp $(PUBLIC_INCLUDES) $(LIBDIR)\caml
	sed -e "/#include .*\/m.h/r ..\config\m.h" \
            -e "/#include .*\/s.h/r ..\config\s.h" \
            -e "/#include /d" config.h > $(LIBDIR)\caml\config.h
	sed -e "/#include .*gc\.h/d" \
	    -e "/#define Alloc_small/,/^}/d" \
	    -e "/Modify/,/^}/d" memory.h > $(LIBDIR)\caml\memory.h

clean:
	rm -f *.exe *.dobj *.sobj *.lib
	rm -f primitives prims.c opnames.h jumptbl.h

primitives : $(PRIMS)
	sed -n -e "s/CAMLprim value \([a-z0-9_][a-z0-9_]*\).*/\1/p" \
	    $(PRIMS) > primitives

prims.c : primitives
        echo #include "mlvalues.h" > prims.c
        echo #include "prims.h" >> prims.c
        sed -e "s/.*/extern value &();/" primitives >> prims.c
        echo c_primitive builtin_cprim[] = { >> prims.c
        sed -e "s/.*/   &,/" primitives >> prims.c
        echo     0 }; >> prims.c
        echo char * names_of_builtin_cprim[] = { >> prims.c
        sed -e "s/.*/   \"^&\",/" primitives >> prims.c
        echo     0 }; >> prims.c

opnames.h : instruct.h
	sed -e "/\/\*/d" \
	    -e "s\enum /char * names_of_/" \
	    -e "s/{$$/[] = {/" \
	    -e "s/\([A-Z][A-Z_0-9]*\)/"\1"/g" instruct.h > opnames.h

# jumptbl.h is required only if you have GCC 2.0 or later
jumptbl.h : instruct.h
	sed -n -e "/^  /s/ \([A-Z]\)/ \&\&lbl_\1/gp" \
	       -e "/^}/q" instruct.h > jumptbl.h

.SUFFIXES: .dobj .sobj

.c.dobj:
	$(CC) $(CFLAGS) $(DLLCCCOMPOPTS) -c $<
	mv $*.obj $*.dobj
.c.sobj:
	$(CC) $(CFLAGS) $(BYTECCCOMPOPTS) -c $<
	mv $*.obj $*.sobj

depend:
	sed -e "s/\.o/.dobj/g" .depend > .depend.nt
	sed -e "s/\.o/.sobj/g" .depend >> .depend.nt

!include .depend.nt