@@ -282,11 +282,17 @@ MKDIR_TARGETS += _output/share/lima/templates _output/share/lima/templates/exper
282
282
_output/share/lima/templates/% : examples/%
283
283
cp -aL $< $@
284
284
285
+ # returns "force" if GOOS==windows, or GOOS!=windows and the file $(1) is not a symlink.
286
+ # $(1): target file
287
+ # On Windows, always copy to ensure the target has the same file as the source.
288
+ force_link = $(if $(filter windows,$(GOOS ) ) ,force,$(shell test ! -L $(1 ) && echo force) )
285
289
286
290
# _output/share/lima/examples
287
291
.PHONY : create-examples-link
288
292
create-examples-link : _output/share/lima/examples
289
- _output/share/lima/examples : _output/share/lima/templates
293
+ _output/share/lima/examples : _output/share/lima/templates $$(call force_link,$$@ )
294
+ # remove the existing directory or symlink
295
+ rm -rf $@
290
296
ifneq ($(GOOS ) ,windows)
291
297
ln -sf templates $@
292
298
else
@@ -311,17 +317,20 @@ _output/share/doc/lima/%: % | _output/share/doc/lima
311
317
312
318
MKDIR_TARGETS += _output/share/doc/lima
313
319
314
-
315
320
.PHONY : create-links-in-doc-dir
316
321
create-links-in-doc-dir : _output/share/doc/lima/templates _output/share/doc/lima/examples
317
- _output/share/doc/lima/templates : _output/share/lima/templates
322
+ _output/share/doc/lima/templates : _output/share/lima/templates $$(call force_link,$$@ )
323
+ # remove the existing directory or symlink
324
+ rm -rf $@
318
325
ifneq ($(GOOS ) ,windows)
319
326
ln -sf ../../lima/templates $@
320
327
else
321
328
# copy from templates built in build process
322
329
cp -aL $< $@
323
330
endif
324
- _output/share/doc/lima/examples : _output/share/doc/lima/templates
331
+ _output/share/doc/lima/examples : _output/share/doc/lima/templates $$(call force_link,$$@ )
332
+ # remove the existing directory or symlink
333
+ rm -rf $@
325
334
ifneq ($(GOOS ) ,windows)
326
335
ln -sf templates $@
327
336
else
0 commit comments