The unpac monorepo manager self-hosting as a monorepo using unpac
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Introduce the framework to build OCaml libraries

+107 -15
+107 -15
Makefile.common
··· 231 231 MERGEMANIFESTEXE = $(call if_file_exists, $(1).manifest, \ 232 232 mt -nologo -outputresource:$(1) -manifest $(1).manifest) 233 233 234 - # Macros and rules to compile OCaml programs 234 + # Macros and rules to compile OCaml programs and libraries 235 + 236 + # The following variable is used to accumulate a list of all the CMX 237 + # files that get built. Is is then used in the root Makefile to express 238 + # the dependency on all these files on the native compiler, so that 239 + # they get rebuilt if the native compiler is updated 240 + 241 + ALL_CMX_FILES = 235 242 236 243 # We use secondary expansion here so that variables like 237 244 # foo_LIBRARIES and foo_SOURCES can be defined after the calls ··· 240 247 241 248 .SECONDEXPANSION: 242 249 243 - # Each program foo is characterised by the foo_LIBRARIES and foo_SOURCES 244 - # variables. The following macros provide the infrastructure to build foo 245 - # from the object files whose names are derived from these two 246 - # varialbes. In particular, the following macros define several 247 - # variables whose names are prefixed with foo_ to compute the 248 - # different lists of files used to build foo. 250 + # Definitions that are common to both programs and libraries 249 251 250 - # The first macro, _OCAML_PROGRAM_BASE, is a private macro (hence the _ at the 251 - # beginning of its name) which defines foo_ variables common to both 252 - # bytecode and native programs. The next two macros, OCAML_BYTECODE_PROGRAM 253 - # and OCAML_NATIVE_PROGRAM are used to define programs that are provided 254 - # only in bytecode or native form, respectively. Programs provided 255 - # in both forms should use OCAML_PROGRAM. 256 - 257 - define _OCAML_PROGRAM_BASE 252 + define _OCAML_COMMON_BASE 258 253 $(basename $(notdir $(1)))_C_FILES = \ 259 254 $$(filter %.c, $$($(basename $(notdir $(1)))_SOURCES)) 260 255 $(basename $(notdir $(1)))_MLI_FILES = \ 261 256 $$(filter %.mli, \ 262 257 $$(subst .mly,.mli,\ 263 258 $$($(basename $(notdir $(1)))_SOURCES))) 259 + $(basename $(notdir $(1)))_CMI_FILES = \ 260 + $$(subst .mli,.cmi,$$($(basename $(notdir $(1)))_MLI_FILES)) 264 261 $(basename $(notdir $(1)))_ML_FILES = \ 265 262 $$(filter %.ml, \ 266 263 $$(subst .ml.in,.ml,$$(subst .mll,.ml,$$(subst .mly,.ml,\ ··· 280 277 $(basename $(notdir $(1)))_GENERATED_FILES = \ 281 278 $$($(basename $(notdir $(1)))_SECONDARY_FILES) \ 282 279 $$(patsubst %.mly,%.output, $$($(basename $(notdir $(1)))_MLY_FILES)) 280 + endef # _OCAML_COMMON_BASE 281 + 282 + # Macros to build OCaml programs 283 + 284 + # Each program foo is characterised by the foo_LIBRARIES and foo_SOURCES 285 + # variables. The following macros provide the infrastructure to build foo 286 + # from the object files whose names are derived from these two 287 + # varialbes. In particular, the following macros define several 288 + # variables whose names are prefixed with foo_ to compute the 289 + # different lists of files used to build foo. 290 + 291 + # The first macro, _OCAML_PROGRAM_BASE, is a private macro (hence the _ at the 292 + # beginning of its name) which defines foo_ variables common to both 293 + # bytecode and native programs. The next two macros, OCAML_BYTECODE_PROGRAM 294 + # and OCAML_NATIVE_PROGRAM are used to define programs that are provided 295 + # only in bytecode or native form, respectively. Programs provided 296 + # in both forms should use OCAML_PROGRAM. 297 + 298 + define _OCAML_PROGRAM_BASE 299 + $(eval $(call _OCAML_COMMON_BASE,$(1))) 283 300 endef # _OCAML_PROGRAM_BASE 284 301 285 302 LINK_BYTECODE_PROGRAM =\ ··· 323 340 $$(patsubst %.c,%.n.$(O), $$($(basename $(notdir $(1)))_C_FILES)) 324 341 $(basename $(notdir $(1)))_CMX_FILES = \ 325 342 $$(patsubst %.ml,%.cmx, $$($(basename $(notdir $(1)))_ML_FILES)) 343 + ALL_CMX_FILES += $$($(basename $(notdir $(1)))_CMX_FILES) 326 344 $(basename $(notdir $(1)))_NCOBJS = \ 327 345 $$($(basename $(notdir $(1)))_CMXA_FILES) \ 328 346 $$($(basename $(notdir $(1)))_NO_FILES) \ ··· 342 360 $(eval $(call _OCAML_BYTECODE_PROGRAM,$(1))) 343 361 $(eval $(call _OCAML_NATIVE_PROGRAM,$(1).opt)) 344 362 endef # OCAML_PROGRAM 363 + 364 + # Macros for OCaml libraries, similar to those for OCaml programs 365 + 366 + define _OCAML_LIBRARY_BASE 367 + $(eval $(call _OCAML_COMMON_BASE,$(1))) 368 + endef # _OCAML_LIBRARY_BASE 369 + 370 + LINK_BYTECODE_LIBRARY =\ 371 + $(CAMLC) $(OC_COMMON_LINKFLAGS) $(OC_BYTECODE_LINKFLAGS) 372 + 373 + # The _OCAML_BYTECODE_LIBRARY macro defines a bytecode library but assuming 374 + # that _OCAML_LIBRARY_BASE has already been called. Its public counterpart 375 + # does not rely on this assumption and rather does call _OCAML_LIBRARY_BASE 376 + # itself. 377 + 378 + define _OCAML_BYTECODE_LIBRARY 379 + $(basename $(notdir $(1)))_BYTE_CMI_FILES = \ 380 + $$(foreach F,$$($(basename $(notdir $(1)))_CMI_FILES),\ 381 + $$(if $$(findstring /native/,$$(F)),,$$(F))) 382 + $(basename $(notdir $(1)))_BO_FILES = \ 383 + $$(patsubst %.c,%.b.$(O), $$($(basename $(notdir $(1)))_C_FILES)) 384 + $(basename $(notdir $(1)))_CMO_FILES = \ 385 + $$(patsubst %.ml,%.cmo, \ 386 + $$(foreach F,$$($(basename $(notdir $(1)))_ML_FILES),\ 387 + $$(if $$(findstring /native/,$$(F)),,$$(F)))) 388 + $(basename $(notdir $(1)))_BCOBJS = \ 389 + $$($(basename $(notdir $(1)))_BO_FILES) \ 390 + $$($(basename $(notdir $(1)))_CMO_FILES) 391 + $(1).cma: \ 392 + $$$$($(basename $(notdir $(1)))_BYTE_CMI_FILES) \ 393 + $$$$($(basename $(notdir $(1)))_BCOBJS) 394 + $$(V_LINKC)$$(LINK_BYTECODE_LIBRARY) -a -o $$@ \ 395 + $$($(basename $(notdir $(1)))_BCOBJS) 396 + endef # _OCAML_BYTECODE_LIBRARY 397 + 398 + define OCAML_BYTECODE_LIBRARY 399 + $(eval $(call _OCAML_LIBRARY_BASE,$(1))) 400 + $(eval $(call _OCAML_BYTECODE_LIBRARY,$(1))) 401 + endef # OCAML_BYTECODE_LIBRARY 402 + 403 + LINK_NATIVE_LIBRARY =\ 404 + $(CAMLOPT) $(OC_COMMON_LINKFLAGS) $(OC_NATIVE_LINKFLAGS) 405 + 406 + define _OCAML_NATIVE_LIBRARY 407 + $(basename $(notdir $(1)))_NATIVE_CMI_FILES = \ 408 + $$(foreach F,$$($(basename $(notdir $(1)))_CMI_FILES),\ 409 + $$(if $$(findstring /byte/,$$(F)),,$$(F))) 410 + $(basename $(notdir $(1)))_NO_FILES = \ 411 + $$(patsubst %.c,%.n.$(O), $$($(basename $(notdir $(1)))_C_FILES)) 412 + $(basename $(notdir $(1)))_CMX_FILES = \ 413 + $$(patsubst %.ml,%.cmx, \ 414 + $$(foreach F,$$($(basename $(notdir $(1)))_ML_FILES),\ 415 + $$(if $$(findstring /byte/,$$(F)),,$$(F)))) 416 + ALL_CMX_FILES += $$($(basename $(notdir $(1)))_CMX_FILES) 417 + $(basename $(notdir $(1)))_NCOBJS = \ 418 + $$($(basename $(notdir $(1)))_NO_FILES) \ 419 + $$($(basename $(notdir $(1)))_CMX_FILES) 420 + $(1).cmxa: \ 421 + $$$$($(basename $(notdir $(1)))_NATIVE_CMI_FILES) \ 422 + $$$$($(basename $(notdir $(1)))_NCOBJS) 423 + $$(V_LINKOPT)$$(LINK_NATIVE_LIBRARY) -a -o $$@ \ 424 + $$($(basename $(notdir $(1)))_NCOBJS) 425 + endef # _OCAML_NATIVE_LIBRARY 426 + 427 + define OCAML_NATIVE_LIBRARY 428 + $(eval $(call _OCAML_LIBRARY_BASE,$(1))) 429 + $(eval $(call _OCAML_NATIVE_LIBRARY,$(1))) 430 + endef # OCAML_NATIVE_LIBRARY 431 + 432 + define OCAML_LIBRARY 433 + $(eval $(call _OCAML_LIBRARY_BASE,$(1))) 434 + $(eval $(call _OCAML_BYTECODE_LIBRARY,$(1))) 435 + $(eval $(call _OCAML_NATIVE_LIBRARY,$(1))) 436 + endef # OCAML_LIBRARY 345 437 346 438 # Installing a bytecode executable, with debug information removed 347 439 define INSTALL_STRIPPED_BYTE_PROG