Skip to content

Commit

Permalink
Merge pull request #1096 from tleedjarv/portable-make-6
Browse files Browse the repository at this point in the history
Portable makefiles 6
  • Loading branch information
gdt authored Dec 16, 2024
2 parents 05e4407 + 21e2f5c commit fbbc624
Showing 1 changed file with 27 additions and 19 deletions.
46 changes: 27 additions & 19 deletions src/Makefile.OCaml
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,9 @@ ifeq ($(NATIVE), true)
CAMLOBJS_FSM = $(FSMOCAMLOBJS:.cmo=.cmx)

CAMLLIBS = $(OCAMLLIBS:.cma=.cmxa)
CAMLLIBS_GUI = $(OCAMLLIBS_GUI:.cma=.cmxa)
CAMLLIBS_MAC = $(OCAMLLIBS_MAC:.cma=.cmxa)
CAMLLIBS_FSM = $(FSMOCAMLLIBS:.cma=.cmxa)

else
## Set up for bytecode compilation
Expand All @@ -229,7 +232,10 @@ else
CAMLOBJS_MAC = $(OCAMLOBJS_MAC)
CAMLOBJS_FSM = $(FSMOCAMLOBJS)

CAMLLIBS=$(OCAMLLIBS)
CAMLLIBS = $(OCAMLLIBS)
CAMLLIBS_GUI = $(OCAMLLIBS_GUI)
CAMLLIBS_MAC = $(OCAMLLIBS_MAC)
CAMLLIBS_FSM = $(FSMOCAMLLIBS)

endif

Expand Down Expand Up @@ -291,7 +297,7 @@ OCAMLOBJS_TUI+=linktext.cmo
## Mac UI
OCAMLOBJS_MAC+=uimacbridge.cmo
OCAMLLIBS_MAC+=threads.cma
INCLFLAGS_MAC+=-I +threads
CAMLFLAGS_MAC+=-I +threads

## Graphic UI
ifndef OCAMLFIND
Expand Down Expand Up @@ -346,8 +352,8 @@ ifneq ($(findstring $(OSARCH),FreeBSD OpenBSD NetBSD DragonFly),)
rm -f inotifytest__.ml inotifytest__.cm[oix] inotifytest__.o inotifytest__ > /dev/null 2>&1)
ifeq ($(FOUND_LIBINOTIFY), true)
FSMDIR = fsmonitor/inotify
$(NAME_FSM)$(EXEC_EXT): CAMLCFLAGS += $(LIBINOTIFY_INC)
$(NAME_FSM)$(EXEC_EXT): CLIBS += $(LIBINOTIFY_LIB)
$(FSMCOBJS): CAMLCFLAGS_FSM_X = $(LIBINOTIFY_INC)
CLIBS_FSM = $(LIBINOTIFY_LIB)
endif
endif

Expand Down Expand Up @@ -411,42 +417,44 @@ win32rc/unison.res.lib: win32rc/unison.rc win32rc/U.ico
$(WINDRES) win32rc/unison.rc win32rc/unison.res
$(WINDRES) win32rc/unison.res win32rc/unison.res.lib

# Context-specific variables, enabling target local variables
CAMLFLAGS_X = $(CAMLFLAGS) $(CAMLFLAGS_GUI_X) $(CAMLFLAGS_FSM_X) $(CAMLFLAGS_MAC_X)
CAMLCFLAGS_X = $(CAMLCFLAGS) $(CAMLCFLAGS_FSM_X)

.SUFFIXES:
.SUFFIXES: .mli .cmi .ml .cmo .cmx .c .o .obj

.mli.cmi:
@echo "$(CAMLC): $< ---> $@"
$(CAMLC) $(CAMLFLAGS) -c $(CWD)/$<
$(CAMLC) $(CAMLFLAGS_X) -c $(CWD)/$<

.ml.cmo:
@echo "$(OCAMLC): $< ---> $@"
$(OCAMLC) $(CAMLFLAGS) -c $(CWD)/$<
$(OCAMLC) $(CAMLFLAGS_X) -c $(CWD)/$<

.ml.cmx:
@echo "$(OCAMLOPT): $< ---> $@"
$(OCAMLOPT) $(CAMLFLAGS) -c $(CWD)/$<
$(OCAMLOPT) $(CAMLFLAGS_X) -c $(CWD)/$<

.c$(OBJ_EXT):
@echo "$(CAMLC): $< ---> $@"
$(CAMLC) $(CAMLFLAGS) $(CAMLCFLAGS) -ccopt $(OUTPUT_SEL)$(CWD)/$@ -c $(CWD)/$<
$(CAMLC) $(CAMLFLAGS_X) $(CAMLCFLAGS_X) -ccopt $(OUTPUT_SEL)$(CWD)/$@ -c $(CWD)/$<

$(NAME)$(EXEC_EXT): $(CAMLOBJS) $(CAMLOBJS_TUI) $(COBJS)
@echo Linking $@
$(CAMLC) -verbose $(CAMLFLAGS_X) $(CAMLLDFLAGS) -o $@ $(CAMLLIBS) $^ $(CLIBS)

$(NAME_GUI)$(EXEC_EXT): OCAMLLIBS += $(OCAMLLIBS_GUI)
$(NAME_GUI)$(EXEC_EXT): CAMLFLAGS += $(CAMLFLAGS_GUI)
$(NAME_GUI)$(EXEC_EXT): CAMLLDFLAGS += $(CAMLLDFLAGS_GUI)
$(NAME_GUI)$(EXEC_EXT) $(CAMLOBJS_GUI): CAMLFLAGS_GUI_X = $(CAMLFLAGS_GUI)
$(NAME_GUI)$(EXEC_EXT): $(CAMLOBJS) $(CAMLOBJS_GUI) $(COBJS)
@echo Linking $@
$(CAMLC) -verbose $(CAMLFLAGS_X) $(CAMLLDFLAGS) $(CAMLLDFLAGS_GUI) -o $@ $(CAMLLIBS) $(CAMLLIBS_GUI) $^ $(CLIBS)

$(NAME_FSM)$(EXEC_EXT): OCAMLLIBS = $(FSMOCAMLLIBS)
$(NAME_FSM)$(EXEC_EXT): CAMLFLAGS += -I fsmonitor -I $(FSMDIR)
$(NAME_FSM)$(EXEC_EXT) $(CAMLOBJS_FSM) $(FSMOCAMLOBJS:.cmo=.cmi): CAMLFLAGS_FSM_X = -I fsmonitor -I $(FSMDIR)
$(NAME_FSM)$(EXEC_EXT): $(CAMLOBJS_FSM) $(FSMCOBJS)

$(NAME)$(EXEC_EXT) $(NAME_GUI)$(EXEC_EXT) $(NAME_FSM)$(EXEC_EXT):
@echo Linking $@
$(CAMLC) -verbose $(CAMLFLAGS) $(CAMLLDFLAGS) -o $@ $(CAMLLIBS) $^ $(CLIBS)
$(CAMLC) -verbose $(CAMLFLAGS_X) $(CAMLLDFLAGS) -o $@ $(CAMLLIBS_FSM) $^ $(CLIBS) $(CLIBS_FSM)

$(NAME)-blob.o: OCAMLLIBS += $(OCAMLLIBS_MAC)
$(NAME)-blob.o: INCLFLAGS += $(INCLFLAGS_MAC)
$(NAME)-blob.o $(CAMLOBJS_MAC): CAMLFLAGS_MAC_X = $(CAMLFLAGS_MAC)
# Unfortunately -output-obj does not put .o files into the output, only .cmx
# files, so we have to use $(LD) to take care of COBJS.
# [2023-07] The limitations of -output-obj have been overcome by a new option
Expand All @@ -455,7 +463,7 @@ $(NAME)-blob.o: INCLFLAGS += $(INCLFLAGS_MAC)
# threads (needed by uimacbridge): https://github.com/ocaml/ocaml/issues/7933
$(NAME)-blob.o: $(CAMLOBJS) $(CAMLOBJS_MAC) $(COBJS)
@echo Linking $@
$(CAMLC) -dstartup -output-obj -verbose -cclib -keep_private_externs $(CAMLFLAGS) -o u-b.o $(CAMLLDFLAGS) $(CAMLLIBS) $(CLIBS) $(CAMLOBJS) $(CAMLOBJS_MAC)
$(CAMLC) -dstartup -output-obj -verbose -cclib -keep_private_externs $(CAMLFLAGS_X) -o u-b.o $(CAMLLDFLAGS) $(CAMLLIBS) $(CAMLLIBS_MAC) $(CLIBS) $(CAMLOBJS) $(CAMLOBJS_MAC)
$(LD) -r -keep_private_externs -o $@ u-b.o $(COBJS)
$(RM) u-b.o

Expand Down

0 comments on commit fbbc624

Please sign in to comment.