Skip to content

Commit 35c572c

Browse files
committed
mllib: Build a mllib.cma/mllib.cmxa library.
Instead of linking with individual objects, which is very tedious, build a proper library and link the other tools with it. This doesn't make the resulting binaries any larger.
1 parent 875128f commit 35c572c

File tree

11 files changed

+31
-127
lines changed

11 files changed

+31
-127
lines changed

builder/Makefile.am

+3-23
Original file line numberDiff line numberDiff line change
@@ -89,15 +89,10 @@ SOURCES_ML = \
8989
builder.ml
9090

9191
SOURCES_C = \
92-
../mllib/dev_t-c.c \
93-
../mllib/fsync-c.c \
94-
../mllib/getopt-c.c \
95-
../mllib/uri-c.c \
96-
../mllib/mkdtemp-c.c \
9792
../customize/perl_edit-c.c \
9893
../customize/crypt-c.c \
99-
../fish/uri.c \
10094
../fish/file-edit.c \
95+
../fish/file-edit.h \
10196
index-scan.c \
10297
index-struct.c \
10398
index-parse.c \
@@ -133,21 +128,6 @@ virt_builder_CFLAGS = \
133128
$(YAJL_CFLAGS)
134129

135130
BOBJECTS = \
136-
$(OCAML_BYTES_COMPAT_CMO) \
137-
$(top_builddir)/mllib/libdir.cmo \
138-
$(top_builddir)/mllib/guestfs_config.cmo \
139-
$(top_builddir)/mllib/common_gettext.cmo \
140-
$(top_builddir)/mllib/dev_t.cmo \
141-
$(top_builddir)/mllib/stringMap.cmo \
142-
$(top_builddir)/mllib/getopt.cmo \
143-
$(top_builddir)/mllib/common_utils.cmo \
144-
$(top_builddir)/mllib/fsync.cmo \
145-
$(top_builddir)/mllib/planner.cmo \
146-
$(top_builddir)/mllib/regedit.cmo \
147-
$(top_builddir)/mllib/JSON.cmo \
148-
$(top_builddir)/mllib/URI.cmo \
149-
$(top_builddir)/mllib/mkdtemp.cmo \
150-
$(top_builddir)/mllib/curl.cmo \
151131
$(top_builddir)/customize/customize_utils.cmo \
152132
$(top_builddir)/customize/urandom.cmo \
153133
$(top_builddir)/customize/random_seed.cmo \
@@ -199,11 +179,11 @@ OCAMLFLAGS = $(OCAML_FLAGS) $(OCAML_WARN_ERROR)
199179
if !HAVE_OCAMLOPT
200180
OBJECTS = $(BOBJECTS)
201181
BEST = c
202-
OCAMLLINKFLAGS = mlguestfs.cma -custom
182+
OCAMLLINKFLAGS = mlguestfs.cma mllib.cma -custom
203183
else
204184
OBJECTS = $(XOBJECTS)
205185
BEST = opt
206-
OCAMLLINKFLAGS = mlguestfs.cmxa
186+
OCAMLLINKFLAGS = mlguestfs.cmxa mllib.cmxa
207187
endif
208188

209189
virt_builder_DEPENDENCIES = $(OBJECTS) $(top_srcdir)/ocaml-link.sh

customize/Makefile.am

+3-17
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,8 @@ SOURCES_ML = \
6868
customize_main.ml
6969

7070
SOURCES_C = \
71-
../fish/uri.c \
7271
../fish/file-edit.c \
7372
../fish/file-edit.h \
74-
../mllib/dev_t-c.c \
75-
../mllib/getopt-c.c \
76-
../mllib/uri-c.c \
7773
crypt-c.c \
7874
perl_edit-c.c
7975

@@ -94,17 +90,7 @@ virt_customize_CFLAGS = \
9490
$(LIBVIRT_CFLAGS) \
9591
$(LIBXML2_CFLAGS)
9692

97-
BOBJECTS = \
98-
$(OCAML_BYTES_COMPAT_CMO) \
99-
$(top_builddir)/mllib/guestfs_config.cmo \
100-
$(top_builddir)/mllib/common_gettext.cmo \
101-
$(top_builddir)/mllib/dev_t.cmo \
102-
$(top_builddir)/mllib/stringMap.cmo \
103-
$(top_builddir)/mllib/getopt.cmo \
104-
$(top_builddir)/mllib/common_utils.cmo \
105-
$(top_builddir)/mllib/regedit.cmo \
106-
$(top_builddir)/mllib/URI.cmo \
107-
$(SOURCES_ML:.ml=.cmo)
93+
BOBJECTS = $(SOURCES_ML:.ml=.cmo)
10894
XOBJECTS = $(BOBJECTS:.cmo=.cmx)
10995

11096
# -I $(top_builddir)/src/.libs is a hack which forces corresponding -L
@@ -134,11 +120,11 @@ OCAMLFLAGS = $(OCAML_FLAGS) $(OCAML_WARN_ERROR)
134120
if !HAVE_OCAMLOPT
135121
OBJECTS = $(BOBJECTS)
136122
BEST = c
137-
OCAMLLINKFLAGS = mlguestfs.cma -custom
123+
OCAMLLINKFLAGS = mlguestfs.cma mllib.cma -custom
138124
else
139125
OBJECTS = $(XOBJECTS)
140126
BEST = opt
141-
OCAMLLINKFLAGS = mlguestfs.cmxa
127+
OCAMLLINKFLAGS = mlguestfs.cmxa mllib.cmxa
142128
endif
143129

144130
virt_customize_DEPENDENCIES = $(OBJECTS) $(top_srcdir)/ocaml-link.sh

dib/Makefile.am

+3-14
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,7 @@ SOURCES_ML = \
3333
dib.ml
3434

3535
SOURCES_C = \
36-
../mllib/dev_t-c.c \
37-
../mllib/getopt-c.c \
38-
../mllib/mkdtemp-c.c
36+
dummy.c
3937

4038
bin_PROGRAMS =
4139

@@ -56,15 +54,6 @@ virt_dib_CFLAGS = \
5654
$(WARN_CFLAGS) $(WERROR_CFLAGS)
5755

5856
BOBJECTS = \
59-
$(OCAML_BYTES_COMPAT_CMO) \
60-
$(top_builddir)/mllib/libdir.cmo \
61-
$(top_builddir)/mllib/guestfs_config.cmo \
62-
$(top_builddir)/mllib/common_gettext.cmo \
63-
$(top_builddir)/mllib/dev_t.cmo \
64-
$(top_builddir)/mllib/stringMap.cmo \
65-
$(top_builddir)/mllib/getopt.cmo \
66-
$(top_builddir)/mllib/common_utils.cmo \
67-
$(top_builddir)/mllib/mkdtemp.cmo \
6857
$(SOURCES_ML:.ml=.cmo)
6958
XOBJECTS = $(BOBJECTS:.cmo=.cmx)
7059

@@ -93,11 +82,11 @@ OCAMLFLAGS = $(OCAML_FLAGS) $(OCAML_WARN_ERROR)
9382
if !HAVE_OCAMLOPT
9483
OBJECTS = $(BOBJECTS)
9584
BEST = c
96-
OCAMLLINKFLAGS = mlguestfs.cma -custom
85+
OCAMLLINKFLAGS = mlguestfs.cma mllib.cma -custom
9786
else
9887
OBJECTS = $(XOBJECTS)
9988
BEST = opt
100-
OCAMLLINKFLAGS = mlguestfs.cmxa
89+
OCAMLLINKFLAGS = mlguestfs.cmxa mllib.cmxa
10190
endif
10291

10392
virt_dib_DEPENDENCIES = $(OBJECTS) $(top_srcdir)/ocaml-link.sh

dib/dummy.c

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/* Dummy source, to be used for OCaml-based tools with no C sources. */
2+
enum { foo = 1 };

get-kernel/Makefile.am

+4-17
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,7 @@ SOURCES_ML = \
2727
get_kernel.ml
2828

2929
SOURCES_C = \
30-
../mllib/dev_t-c.c \
31-
../mllib/getopt-c.c \
32-
../mllib/uri-c.c \
33-
../fish/uri.c
30+
dummy.c
3431

3532
man_MANS =
3633
noinst_DATA =
@@ -54,17 +51,7 @@ virt_get_kernel_CFLAGS = \
5451
$(WARN_CFLAGS) $(WERROR_CFLAGS) \
5552
$(LIBXML2_CFLAGS)
5653

57-
BOBJECTS = \
58-
$(OCAML_BYTES_COMPAT_CMO) \
59-
$(top_builddir)/mllib/libdir.cmo \
60-
$(top_builddir)/mllib/guestfs_config.cmo \
61-
$(top_builddir)/mllib/common_gettext.cmo \
62-
$(top_builddir)/mllib/dev_t.cmo \
63-
$(top_builddir)/mllib/stringMap.cmo \
64-
$(top_builddir)/mllib/getopt.cmo \
65-
$(top_builddir)/mllib/common_utils.cmo \
66-
$(top_builddir)/mllib/URI.cmo \
67-
$(SOURCES_ML:.ml=.cmo)
54+
BOBJECTS = $(SOURCES_ML:.ml=.cmo)
6855
XOBJECTS = $(BOBJECTS:.cmo=.cmx)
6956

7057
# -I $(top_builddir)/src/.libs is a hack which forces corresponding -L
@@ -92,11 +79,11 @@ OCAMLFLAGS = $(OCAML_FLAGS) $(OCAML_WARN_ERROR)
9279
if !HAVE_OCAMLOPT
9380
OBJECTS = $(BOBJECTS)
9481
BEST = c
95-
OCAMLLINKFLAGS = mlguestfs.cma -custom
82+
OCAMLLINKFLAGS = mlguestfs.cma mllib.cma -custom
9683
else
9784
OBJECTS = $(XOBJECTS)
9885
BEST = opt
99-
OCAMLLINKFLAGS = mlguestfs.cmxa
86+
OCAMLLINKFLAGS = mlguestfs.cmxa mllib.cmxa
10087
endif
10188

10289
virt_get_kernel_DEPENDENCIES = $(OBJECTS) $(top_srcdir)/ocaml-link.sh

get-kernel/dummy.c

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/* Dummy source, to be used for OCaml-based tools with no C sources. */
2+
enum { foo = 1 };

resize/Makefile.am

+4-21
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,7 @@ SOURCES_ML = \
3030
resize.ml
3131

3232
SOURCES_C = \
33-
../mllib/dev_t-c.c \
34-
../mllib/fsync-c.c \
35-
../mllib/getopt-c.c \
36-
../fish/progress.c \
37-
../mllib/progress-c.c \
38-
../fish/uri.c \
39-
../mllib/uri-c.c
33+
dummy.c
4034

4135
if HAVE_OCAML
4236

@@ -54,18 +48,7 @@ virt_resize_CFLAGS = \
5448
$(WARN_CFLAGS) $(WERROR_CFLAGS) \
5549
$(LIBXML2_CFLAGS)
5650

57-
BOBJECTS = \
58-
$(OCAML_BYTES_COMPAT_CMO) \
59-
$(top_builddir)/mllib/fsync.cmo \
60-
$(top_builddir)/mllib/progress.cmo \
61-
$(top_builddir)/mllib/URI.cmo \
62-
$(top_builddir)/mllib/guestfs_config.cmo \
63-
$(top_builddir)/mllib/common_gettext.cmo \
64-
$(top_builddir)/mllib/dev_t.cmo \
65-
$(top_builddir)/mllib/stringMap.cmo \
66-
$(top_builddir)/mllib/getopt.cmo \
67-
$(top_builddir)/mllib/common_utils.cmo \
68-
$(SOURCES_ML:.ml=.cmo)
51+
BOBJECTS = $(SOURCES_ML:.ml=.cmo)
6952
XOBJECTS = $(BOBJECTS:.cmo=.cmx)
7053

7154
# -I $(top_builddir)/src/.libs is a hack which forces corresponding -L
@@ -93,11 +76,11 @@ OCAMLFLAGS = $(OCAML_FLAGS) $(OCAML_WARN_ERROR)
9376
if !HAVE_OCAMLOPT
9477
OBJECTS = $(BOBJECTS)
9578
BEST = c
96-
OCAMLLINKFLAGS = mlguestfs.cma -custom
79+
OCAMLLINKFLAGS = mlguestfs.cma mllib.cma -custom
9780
else
9881
OBJECTS = $(XOBJECTS)
9982
BEST = opt
100-
OCAMLLINKFLAGS = mlguestfs.cmxa
83+
OCAMLLINKFLAGS = mlguestfs.cmxa mllib.cmxa
10184
endif
10285

10386
virt_resize_DEPENDENCIES = $(OBJECTS) $(top_srcdir)/ocaml-link.sh

resize/dummy.c

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/* Dummy source, to be used for OCaml-based tools with no C sources. */
2+
enum { foo = 1 };

sparsify/Makefile.am

+4-18
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,7 @@ SOURCES_ML = \
3636
sparsify.ml
3737

3838
SOURCES_C = \
39-
../fish/progress.c \
40-
../mllib/dev_t-c.c \
41-
../mllib/getopt-c.c \
42-
../mllib/progress-c.c \
43-
../mllib/statvfs-c.c
39+
dummy.c
4440

4541
if HAVE_OCAML
4642

@@ -56,17 +52,7 @@ virt_sparsify_CPPFLAGS = \
5652
virt_sparsify_CFLAGS = \
5753
$(WARN_CFLAGS) $(WERROR_CFLAGS)
5854

59-
BOBJECTS = \
60-
$(OCAML_BYTES_COMPAT_CMO) \
61-
$(top_builddir)/mllib/guestfs_config.cmo \
62-
$(top_builddir)/mllib/common_gettext.cmo \
63-
$(top_builddir)/mllib/dev_t.cmo \
64-
$(top_builddir)/mllib/stringMap.cmo \
65-
$(top_builddir)/mllib/getopt.cmo \
66-
$(top_builddir)/mllib/common_utils.cmo \
67-
$(top_builddir)/mllib/progress.cmo \
68-
$(top_builddir)/mllib/StatVFS.cmo \
69-
$(SOURCES_ML:.ml=.cmo)
55+
BOBJECTS = $(SOURCES_ML:.ml=.cmo)
7056
XOBJECTS = $(BOBJECTS:.cmo=.cmx)
7157

7258
# -I $(top_builddir)/src/.libs is a hack which forces corresponding -L
@@ -94,11 +80,11 @@ OCAMLFLAGS = $(OCAML_FLAGS) $(OCAML_WARN_ERROR)
9480
if !HAVE_OCAMLOPT
9581
OBJECTS = $(BOBJECTS)
9682
BEST = c
97-
OCAMLLINKFLAGS = mlguestfs.cma -custom
83+
OCAMLLINKFLAGS = mlguestfs.cma mllib.cma -custom
9884
else
9985
OBJECTS = $(XOBJECTS)
10086
BEST = opt
101-
OCAMLLINKFLAGS = mlguestfs.cmxa
87+
OCAMLLINKFLAGS = mlguestfs.cmxa mllib.cmxa
10288
endif
10389

10490
virt_sparsify_DEPENDENCIES = $(OBJECTS) $(top_srcdir)/ocaml-link.sh

sparsify/dummy.c

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/* Dummy source, to be used for OCaml-based tools with no C sources. */
2+
enum { foo = 1 };

sysprep/Makefile.am

+2-17
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,8 @@ SOURCES_ML = \
8080
main.ml
8181

8282
SOURCES_C = \
83-
../mllib/dev_t-c.c \
84-
../mllib/getopt-c.c \
85-
../mllib/uri-c.c \
86-
../mllib/mkdtemp-c.c \
8783
../customize/crypt-c.c \
8884
../customize/perl_edit-c.c \
89-
../fish/uri.c \
9085
../fish/file-edit.c
9186

9287
if HAVE_OCAML
@@ -106,16 +101,6 @@ virt_sysprep_CFLAGS = \
106101
$(LIBXML2_CFLAGS)
107102

108103
BOBJECTS = \
109-
$(OCAML_BYTES_COMPAT_CMO) \
110-
$(top_builddir)/mllib/guestfs_config.cmo \
111-
$(top_builddir)/mllib/common_gettext.cmo \
112-
$(top_builddir)/mllib/dev_t.cmo \
113-
$(top_builddir)/mllib/stringMap.cmo \
114-
$(top_builddir)/mllib/getopt.cmo \
115-
$(top_builddir)/mllib/common_utils.cmo \
116-
$(top_builddir)/mllib/URI.cmo \
117-
$(top_builddir)/mllib/mkdtemp.cmo \
118-
$(top_builddir)/mllib/regedit.cmo \
119104
$(top_builddir)/customize/customize_utils.cmo \
120105
$(top_builddir)/customize/crypt.cmo \
121106
$(top_builddir)/customize/urandom.cmo \
@@ -160,11 +145,11 @@ OCAMLFLAGS = $(OCAML_FLAGS) $(OCAML_WARN_ERROR)
160145
if !HAVE_OCAMLOPT
161146
OBJECTS = $(BOBJECTS)
162147
BEST = c
163-
OCAMLLINKFLAGS = mlguestfs.cma -custom
148+
OCAMLLINKFLAGS = mlguestfs.cma mllib.cma -custom
164149
else
165150
OBJECTS = $(XOBJECTS)
166151
BEST = opt
167-
OCAMLLINKFLAGS = mlguestfs.cmxa
152+
OCAMLLINKFLAGS = mlguestfs.cmxa mllib.cmxa
168153
endif
169154

170155
virt_sysprep_DEPENDENCIES = $(OBJECTS) $(top_srcdir)/ocaml-link.sh

0 commit comments

Comments
 (0)