Mercurial > mxe-octave
annotate src/ocaml-core.mk @ 3006:dabfd7db980c
use cp for ln on mingw native builds
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 30 May 2013 13:28:23 -0400 |
parents | 5ebcd132140a |
children | 100e618349f7 |
rev | line source |
---|---|
2836 | 1 # This file is part of mingw-cross-env. |
2 # See doc/index.html for further information. | |
3 | |
4 # zlib | |
5 PKG := ocaml-core | |
6 $(PKG)_IGNORE := | |
7 $(PKG)_CHECKSUM := $(ocaml-native_CHECKSUM) | |
8 $(PKG)_SUBDIR := $(ocaml-native_SUBDIR) | |
9 $(PKG)_FILE := $(ocaml-native_FILE) | |
10 $(PKG)_URL := $(ocaml-native_URL) | |
11 $(PKG)_DEPS := gcc bfd ocaml-flexdll ocaml-native | |
12 | |
13 define $(PKG)_UPDATE | |
14 $(call ocaml-native_UPDATE) | |
15 endef | |
16 | |
17 | |
18 OTHER_LIBS := win32unix str num dynlink bigarray systhreads win32graph | |
19 | |
20 define $(PKG)_BUILD | |
21 # Build native ocamlrun and ocamlc which contain the | |
22 # filename-win32-dirsep patch. | |
23 # | |
24 # Note that we must build a 32 bit compiler, even on 64 bit build | |
25 # architectures, because this compiler will try to do strength | |
26 # reduction optimizations using its internal int type, and that must | |
27 # match Windows' int type. (That's what -cc and -host are for). | |
28 cd '$(1)' && ./configure \ | |
29 -prefix '$(PREFIX)/$(TARGET)' \ | |
30 -bindir '$(PREFIX)/$(TARGET)/bin' \ | |
31 -libdir '$(PREFIX)/$(TARGET)/lib/ocaml' \ | |
32 -no-tk \ | |
33 -cc "gcc -m32" \ | |
34 -no-shared-libs \ | |
35 -host '$(TARGET)' \ | |
36 -x11lib /usr/lib \ | |
37 -verbose | |
38 $(MAKE) -C '$(1)' core | |
39 # Now move the working ocamlrun, ocamlc into the boot/ directory, | |
40 # overwriting the binary versions which ship with the compiler with | |
41 # ones that contain the filename-win32-dirsep patch. | |
42 $(MAKE) -C '$(1)' coreboot | |
43 # second time, otherwise Segfault in some cases (depending on the runing system?) | |
44 $(MAKE) -C '$(1)' coreboot | |
45 $(MAKE) -C '$(1)' all | |
46 # install ocamldoc and camlp4 (non cross versions) | |
47 $(MAKE) -C '$(1)/ocamldoc' install | |
48 cd '$(1)' && BINDIR=$(PREFIX)/$(TARGET)/bin \ | |
49 LIBDIR=$(PREFIX)/$(TARGET)/lib/ocaml \ | |
50 PREFIX=$(PREFIX)/$(TARGET) \ | |
51 ./build/partial-install.sh | |
52 | |
53 ####### patch mingw include | |
54 # Now patch utils/clflags.ml to hardcode mingw-specific include. | |
55 $(SED) -i "s,@libdir@,$(PREFIX)/$(TARGET)/lib,g" \ | |
56 $(1)/hardcode_mingw_include.patch | |
57 cd '$(1)' && patch -p2 < hardcode_mingw_include.patch | |
58 | |
59 ####### prepare cross build | |
60 # Replace the compiler configuration (config/{s.h,m.h,Makefile}) | |
61 # with ones as they would be on a 32 bit Windows system. | |
62 cp -f '$(1)/config/m-nt.h' '$(1)/config/m.h' | |
63 cp -f $(1)/config/s-nt.h $(1)/config/s.h | |
64 # config/Makefile is a custom one which we supply. | |
65 rm -f $(1)/config/Makefile | |
66 $(SED) \ | |
67 -e "s,@prefix@,$(PREFIX)/$(TARGET),g" \ | |
68 -e "s,@toolpref@,$(TARGET),g" \ | |
69 -e "s,@otherlibraries@,$(OTHER_LIBS),g" \ | |
70 < $(1)/Makefile-mingw.in > $(1)/config/Makefile | |
71 $(SED) -i "s,@libdir@,$(PREFIX)/$(TARGET)/lib,g" $(1)/otherlibs/Makefile.shared | |
72 # We're going to build in otherlibs/win32unix and otherlibs/win32graph | |
73 # directories, but since they would normally only be built under | |
74 # Windows, they only have the Makefile.nt files. Just symlink | |
75 # Makefile -> Makefile.nt for these cases. | |
76 $(SED) -i "s,@libdir@,$(PREFIX)/$(TARGET)/lib,g" $(1)/otherlibs/win32unix/Makefile.nt | |
77 $(SED) -i "s,@libdir@,$(PREFIX)/$(TARGET)/lib,g" $(1)/otherlibs/win32graph/Makefile.nt | |
78 $(SED) -i "s,@libdir@,$(PREFIX)/$(TARGET)/lib,g" $(1)/otherlibs/systhreads/Makefile.nt | |
79 for d in $(1)/otherlibs/win32unix \ | |
80 $(1)/otherlibs/win32graph \ | |
81 $(1)/otherlibs/bigarray \ | |
82 $(1)/otherlibs/systhreads; do \ | |
3006
dabfd7db980c
use cp for ln on mingw native builds
John W. Eaton <jwe@octave.org>
parents:
2836
diff
changeset
|
83 $(LN_SF) Makefile.nt $$d/Makefile; \ |
2836 | 84 done |
85 # Now clean the temporary files from the previous build. This | |
86 # will also cause asmcomp/arch.ml (etc) to be linked to the 32 bit | |
87 # i386 versions, essentially causing ocamlopt to use the Win/i386 code | |
88 # generator. | |
89 $(MAKE) -C '$(1)' partialclean | |
90 # We need to remove any .o object for make sure they are | |
91 # recompiled later.. | |
92 cd $(1) && rm byterun/*.o | |
93 | |
94 ####### build mingw ocaml | |
95 # Just rebuild some small bits that we need for the following | |
96 # 'make opt' to work. Note that 'make all' fails here. | |
97 $(MAKE) -C '$(1)/byterun' libcamlrun.a | |
98 $(MAKE) -C '$(1)' ocaml ocamlc | |
99 $(MAKE) -C '$(1)/stdlib' | |
100 $(MAKE) -C '$(1)/tools' ocamlmklib | |
101 # Build ocamlopt | |
102 $(MAKE) -C '$(1)' opt | |
103 # Now build otherlibs for ocamlopt | |
104 cd '$(1)' && \ | |
105 for i in $(OTHER_LIBS); do \ | |
106 $(MAKE) -C otherlibs/$$i clean; \ | |
107 $(MAKE) -C otherlibs/$$i all; \ | |
108 $(MAKE) -C otherlibs/$$i allopt; \ | |
109 done | |
110 | |
111 ####### installation | |
112 $(MAKE) -C '$(1)' install | |
113 $(MAKE) -C '$(1)' installopt | |
114 # Rename all the binaries to target-binary | |
115 for f in ocamlc ocamlcp ocamlrun ocamldep ocamlmklib ocamlmktop ocamlopt ocamlprof camlp4prof camlp4boot camlp4 camlp4oof camlp4of camlp4o camlp4rf camlp4r camlp4orf ocamldoc ; do \ | |
116 cp -f $(PREFIX)/$(TARGET)/bin/$$f $(PREFIX)/bin/$(TARGET)-$$f; \ | |
117 done | |
118 | |
119 # test ocamlopt | |
120 cp '$(2).ml' '$(1)/test.ml' | |
121 cd '$(1)' && '$(TARGET)-ocamlopt' test.ml | |
122 # test ocamlbuild | |
123 mkdir '$(1)/tmp' && cp '$(2).ml' '$(1)/tmp/test.ml' | |
124 cd '$(1)/tmp' && $(TARGET)-ocamlbuild test.native | |
125 # test | |
126 cp '$(2).ml' '$(1)/test.ml' | |
127 cd '$(1)' && '$(TARGET)-ocamlopt' test.ml | |
128 endef |