Makefile.OCaml (9932B)
1 # Unison file synchronizer: src/Makefile.OCaml 2 # See ../LICENSE for terms. 3 4 # IMPORTANT! 5 # 6 # This file is portable and compatible with GNU Make, BSD make, Solaris 7 # (d)make and NMAKE. Do not make any changes in this file unless you are 8 # certain that the changes do not break this portability. 9 10 all: tui guimaybe macuimaybe fsmonitor 11 .PHONY: all # This .PHONY definition must come after the first target, 12 # so that make implementations which don't support .PHONY 13 # don't treat it as the default target (which in turn 14 # would cause _all_ targets to be made). 15 .PHONY: clean 16 17 # NAME, VERSION, and MAJORVERSION 18 include Makefile.ProjectInfo 19 20 # Automatically generated configuration 21 include Makefile.cfg 22 23 #################################################################### 24 # Makefile rules for compiling ocaml programs # 25 #################################################################### 26 27 #################################################################### 28 ### Try to automatically guess UI style 29 30 .PHONY: guimaybe 31 guimaybe: 32 33 .PHONY: macuimaybe 34 macuimaybe: 35 36 #################################################################### 37 ### Default parameters 38 39 INCLFLAGS = -I lwt -I ubase -I system -I system/$(SYSTEM) -I lwt/$(SYSTEM) 40 DEP_INCLFLAGS = -I lwt -I ubase -I system \ 41 -I fsmonitor -I fsmonitor/inotify -I fsmonitor/solaris -I fsmonitor/windows 42 43 ubase/projectInfo.ml: Makefile.ProjectInfo 44 ocaml make_tools.ml projectinfo NAME="$(NAME)" VERSION="$(VERSION)" MAJORVERSION="$(MAJORVERSION)" > $@ 45 46 clean:: 47 cd ubase && $(RM) projectInfo.ml 48 49 #################################################################### 50 ### Unison objects and libraries 51 52 # OCaml objects for the bytecode version 53 # File extensions will be substituted for the native code version 54 55 OCAMLOBJS = \ 56 ubase/umarshal.cmo \ 57 ubase/rx.cmo \ 58 \ 59 unicode_tables.cmo unicode.cmo bytearray.cmo \ 60 system/system_generic.cmo $(WINOBJS) \ 61 system/$(SYSTEM)/system_impl.cmo \ 62 system.cmo \ 63 \ 64 ubase/projectInfo.cmo ubase/myMap.cmo ubase/safelist.cmo \ 65 ubase/util.cmo ubase/uarg.cmo \ 66 ubase/prefs.cmo ubase/trace.cmo ubase/proplist.cmo \ 67 \ 68 lwt/pqueue.cmo lwt/lwt.cmo lwt/lwt_util.cmo \ 69 lwt/$(SYSTEM)/lwt_unix_impl.cmo lwt/lwt_unix.cmo \ 70 \ 71 features.cmo uutil.cmo case.cmo pred.cmo terminal.cmo \ 72 fileutil.cmo name.cmo path.cmo fspath.cmo fs.cmo fingerprint.cmo \ 73 abort.cmo osx.cmo fswatch.cmo propsdata.cmo \ 74 props.cmo fileinfo.cmo os.cmo lock.cmo clroot.cmo common.cmo \ 75 tree.cmo checksum.cmo transfer.cmo xferhint.cmo \ 76 remote.cmo external.cmo negotiate.cmo globals.cmo fswatchold.cmo \ 77 fpcache.cmo update.cmo copy.cmo stasher.cmo \ 78 files.cmo sortri.cmo recon.cmo transport.cmo \ 79 strings.cmo uicommon.cmo uitext.cmo test.cmo \ 80 main.cmo 81 82 # OCaml libraries for the bytecode version 83 # File extensions will be substituted for the native code version 84 OCAMLLIBS = unix.cma str.cma 85 OCAMLINCLUDES = -I +unix -I +str 86 87 # C objects for both bytecode and native versions 88 COBJS = osxsupport$(OBJ_EXT) pty$(OBJ_EXT) bytearray_stubs$(OBJ_EXT) \ 89 hash_compat$(OBJ_EXT) props_xattr$(OBJ_EXT) props_acl$(OBJ_EXT) \ 90 copy_stubs$(OBJ_EXT) $(WINCOBJS) 91 92 #################################################################### 93 ### User Interface setup 94 95 ## Text UI 96 OCAMLOBJS_TUI = linktext.cmo 97 98 ## Mac UI 99 OCAMLOBJS_MAC = uimacbridge.cmo 100 OCAMLLIBS_MAC = threads.cma 101 CAMLFLAGS_MAC = -I +threads 102 103 ## Graphic UI 104 OCAMLOBJS_GUI = pixmaps.cmo uigtk3.cmo linkgtk3.cmo 105 OCAMLLIBS_GUI = lablgtk3.cma cairo.cma 106 107 #################################################################### 108 ### Unison executables 109 110 NAME_GUI = $(NAME)-gui 111 112 .PHONY: buildexecutable 113 buildexecutable: 114 115 .PHONY: tui 116 tui: buildexecutable $(NAME)$(EXEC_EXT) 117 118 .PHONY: gui 119 gui: buildexecutable $(NAME_GUI)$(EXEC_EXT) 120 121 .PHONY: macui 122 macui: buildexecutable macexecutable 123 124 .PHONY: macexecutable 125 macexecutable: $(NAME)-blob.o 126 cd uimac && $(MAKE) macexecutable VERSION="$(VERSION)" OCAMLLIBDIR="$(OCAMLLIBDIR)" XCODEFLAGS="$(XCODEFLAGS)" 127 128 clean:: 129 -cd uimac && $(MAKE) clean 130 131 #################################################################### 132 ### Filesystem monitoring 133 134 NAME_FSM = $(NAME)-fsmonitor 135 136 .PHONY: fsmonitor 137 fsmonitor: 138 139 .PHONY: fsmonitorexecutable 140 fsmonitorexecutable: buildexecutable $(NAME_FSM)$(EXEC_EXT) 141 142 CAMLFLAGS_FSM = -I fsmonitor -I ./$(FSMDIR) 143 144 #################################################################### 145 ### Dependencies 146 147 # Include an automatically generated list of dependencies 148 include .depend 149 # Additional dependencies depending on the system 150 system.cmo fspath.cmo fs.cmo: system/$(SYSTEM)/system_impl.cmo 151 system.cmx fspath.cmx fs.cmx: system/$(SYSTEM)/system_impl.cmx 152 lwt/lwt_unix.cmo: lwt/$(SYSTEM)/lwt_unix_impl.cmo 153 lwt/lwt_unix.cmx: lwt/$(SYSTEM)/lwt_unix_impl.cmx 154 lwt/win/lwt_win.cmo: lwt/win/lwt_unix_impl.cmo system/system_win.cmo 155 lwt/win/lwt_win.cmx: lwt/win/lwt_unix_impl.cmx system/system_win.cmx 156 157 .PHONY: depend 158 depend: 159 ocamlc -depend $(DEP_INCLFLAGS) *.mli *.ml */*.ml */*.mli */*/*.ml */*/*.mli > .depend 160 161 .PHONY: dependgraph 162 dependgraph: depend 163 echo 'digraph G {' > .depend.dot.tmp 164 echo '{ rank = same; "Fileinfo"; "Props"; "Fspath"; "Os"; "Path"; }'\ 165 >>.depend.dot.tmp 166 echo '{ rank = same; "Uitext"; "Uigtk"; }'>>.depend.dot.tmp 167 echo '{ rank = same; "Recon"; "Update"; "Transport"; "Files"; }'\ 168 >>.depend.dot.tmp 169 echo '{ rank = same; "Tree"; "Safelist"; }'>>.depend.dot.tmp 170 echo '{ rank = same; "Uarg"; "Prefs"; }'>>.depend.dot.tmp 171 echo 'Attempting to use ocamldot and dot to produce a dependency graph:' 172 -ocamldot .depend | tail -n +2 >> .depend.dot.tmp 173 -dot -Tps -o DEPENDENCIES.ps .depend.dot.tmp 174 175 #################################################################### 176 ### Compilation 177 178 win32rc/unison.res: win32rc/unison.rc win32rc/U.ico 179 rc win32rc/unison.rc 180 181 win32rc/unison.res.lib: win32rc/unison.rc win32rc/U.ico 182 $(WINDRES) win32rc/unison.rc win32rc/unison.res 183 $(WINDRES) win32rc/unison.res win32rc/unison.res.lib 184 185 # Context-specific variables, enabling target local variables 186 CAMLFLAGS_X = $(CAMLFLAGS) $(OCAMLINCLUDES) $(CAMLFLAGS_GUI_X) $(CAMLFLAGS_FSM_X) $(CAMLFLAGS_MAC_X) 187 CAMLCFLAGS_X = $(CAMLCFLAGS) $(CAMLCFLAGS_FSM_X) 188 189 .SUFFIXES: 190 .SUFFIXES: .mli .cmi .ml .cmo .cmx .c .o .obj 191 192 .mli.cmi: 193 @echo "$(CAMLC): $< ---> $@" 194 $(CAMLC) $(CAMLFLAGS_X) -c $(CWD)/$< 195 196 .ml.cmo: 197 @echo "$(OCAMLC): $< ---> $@" 198 $(OCAMLC) $(CAMLFLAGS_X) -c $(CWD)/$< 199 200 .ml.cmx: 201 @echo "$(OCAMLOPT): $< ---> $@" 202 $(OCAMLOPT) $(CAMLFLAGS_X) -c $(CWD)/$< 203 204 .c$(OBJ_EXT): 205 @echo "$(CAMLC): $< ---> $@" 206 $(CAMLC) $(CAMLFLAGS_X) $(CAMLCFLAGS_X) -ccopt $(OUTPUT_SEL)$(CWD)/$@ -c $(CWD)/$< 207 208 # The second part of configuration must be included here because rule lines 209 # are expanded at parsing, so we need all variables to be defined by then. 210 include Makefile2.cfg 211 212 $(NAME)$(EXEC_EXT): $(CAMLOBJS) $(CAMLOBJS_TUI) $(COBJS) 213 @echo Linking $@ 214 $(CAMLC) -verbose $(CAMLFLAGS_X) $(CAMLLDFLAGS) -o $@ $(CAMLLIBS) $(ALL__SRC) $(CLIBS) 215 216 $(NAME_GUI)$(EXEC_EXT): $(CAMLOBJS) $(CAMLOBJS_GUI) $(COBJS) 217 @echo Linking $@ 218 $(CAMLC) -verbose $(CAMLFLAGS_X) $(CAMLLDFLAGS) $(CAMLLDFLAGS_GUI) -o $@ $(CAMLLIBS) $(CAMLLIBS_GUI) $(ALL__SRC) $(CLIBS) 219 220 $(NAME_FSM)$(EXEC_EXT): $(CAMLOBJS_FSM) $(FSMCOBJS) 221 @echo Linking $@ 222 $(CAMLC) -verbose $(CAMLFLAGS_X) $(CAMLLDFLAGS) -o $@ $(CAMLLIBS_FSM) $(ALL__SRC) $(CLIBS) $(CLIBS_FSM) 223 224 # Unfortunately -output-obj does not put .o files into the output, only .cmx 225 # files, so we have to use $(LD) to take care of COBJS. 226 # [2023-07] The limitations of -output-obj have been overcome by a new option 227 # -output-complete-obj, available since OCaml 4.02.2. Still, this option can't 228 # be used here because there is a bug which breaks linking on macOS when using 229 # threads (needed by uimacbridge): https://github.com/ocaml/ocaml/issues/7933 230 $(NAME)-blob.o: $(CAMLOBJS) $(CAMLOBJS_MAC) $(COBJS) 231 @echo Linking $@ 232 $(CAMLC) -dstartup -output-obj -verbose -cclib -keep_private_externs $(CAMLFLAGS_X) -o u-b.o $(CAMLLDFLAGS) $(CAMLLIBS) $(CAMLLIBS_MAC) $(CLIBS) $(CAMLOBJS) $(CAMLOBJS_MAC) 233 $(LD) -r -keep_private_externs -o $@ u-b.o $(COBJS) 234 $(RM) u-b.o 235 236 #################################################################### 237 ### Documentation 238 239 .PHONY: manpage 240 manpage: 241 242 .PHONY: manpagefile 243 manpagefile: ../man/$(NAME).1 244 245 ../man/$(NAME).1: ../man/$(NAME).1.in opt_short.tmp opt_full.tmp 246 sed -e '/@OPTIONS_SHORT@/r ./opt_short.tmp' \ 247 -e '/@OPTIONS_SHORT@/d' \ 248 -e '/@OPTIONS_FULL@/r ./opt_full.tmp' \ 249 -e '/@OPTIONS_FULL@/d' ../man/$(NAME).1.in > $@ 250 251 # Listing of preferences 252 opt_short.tmp: $(NAME)$(EXEC_EXT) 253 ./$(NAME)$(EXEC_EXT) -prefsman short > $@ 254 255 opt_full.tmp: $(NAME)$(EXEC_EXT) 256 ./$(NAME)$(EXEC_EXT) -prefsman full > $@ 257 258 clean:: 259 cd ../man && $(RM) *.tmp $(NAME).1 260 261 .PHONY: docs 262 docs: 263 264 .PHONY: docfiles 265 docfiles: manpagefile 266 cd ../doc && $(MAKE) all 267 268 #################################################################### 269 ### Misc 270 271 RM_FILES = $(RM) *.cmi *.cmo *.cmx *.cma *.cmxa *.o *.obj *.lib *.exp *~ .*~ *.bak *.tmp 272 273 clean:: 274 -$(RM) Makefile.cfg Makefile2.cfg _mk.cfg 275 -$(RM) $(NAME) $(NAME).exe 276 -$(RM) $(NAME_GUI) $(NAME_GUI).exe 277 -$(RM) $(NAME_FSM) $(NAME_FSM).exe 278 -$(RM) $(NAME)-blob.o 279 -$(RM) TAGS tags 280 -$(RM) core gmon.out 281 -$(RM) *.tmp *.bak?.tmp .*.bak?.tmp 282 -$(RM) .depend.dot.tmp DEPENDENCIES.ps 283 -(cd win32rc && $(RM) unison.res unison.res.lib) 284 -$(RM_FILES) 285 -(cd system && $(RM_FILES)) 286 -(cd system/generic && $(RM_FILES)) 287 -(cd system/win && $(RM_FILES)) 288 -(cd fsmonitor && $(RM_FILES)) 289 -(cd fsmonitor/../$(FSMDIR) && $(RM_FILES)) 290 -(cd ubase && $(RM_FILES)) 291 -(cd lwt && $(RM_FILES)) 292 -(cd lwt/generic && $(RM_FILES)) 293 -(cd lwt/win && $(RM_FILES)) 294 295 .PHONY: paths 296 paths: 297 @echo PATH = '$(PATH)' 298 @echo OCAMLLIBDIR = '$(OCAMLLIBDIR)'