summaryrefslogtreecommitdiff
path: root/Build/source/texk/am/script_links.am
blob: a73f397ecc34e0af715266de5ea44bc9fed7be2c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
## texk/am/perl_links.am: Makefile fragment for perl script links.
##
## Copyright (C) 2011 Peter Breitenlohner <tex-live@tug.org>
## You may freely use, modify and/or distribute this file.
##
## Install/uninstall 'linked scripts' or win32 wrappers
## to use it, add prerequisite uninstall-links to uninstall-hook and
##  one ore more of install-{lua,perl,shell}-scripts to install-data-hook
##
## requires conditionals WIN32 and WIN32_WRAP
## requires $(scriptsdir): e.g., texmf/scripts/chktex
## appends to $(nodist_bin_SCRIPTS)
#
## install-lua-scripts requires $(lua_scripts), e.g., musixflx
## install-perl-scripts requires $(perl_scripts), e.g., deweb
## install-shell-scripts requires $(shell_scripts), e.g. htlatex
##
## shell_scripts are somewhat special because win32 needs
## additional .bat scripts or similar
.PHONY: install-lua-links install-perl-links install-shell-links \
	install-links make-links uninstall-links

all_scripts = $(lua_scripts) $(perl_scripts) $(shell_scripts)

if WIN32
if WIN32_WRAP
## We treat the WIN32 wrappers as SCRIPTS to avoid automatic build rules
wrappers = $(all_scripts:=.exe)
nodist_bin_SCRIPTS += $(wrappers)
runscript = $(top_srcdir)/../../texk/texlive/w32_wrapper/runscript.exe
$(wrappers): $(runscript)
	$(LN_S) $(runscript) $@
endif WIN32_WRAP
endif WIN32

install-lua-links:
if !WIN32
	$(MAKE) $(AM_MAKEFLAGS) TYPE=lua EXT=lua install-links
endif !WIN32

install-perl-links:
if !WIN32
	$(MAKE) $(AM_MAKEFLAGS) TYPE=perl EXT=pl install-links
endif !WIN32

install-shell-links:
if !WIN32
	$(MAKE) $(AM_MAKEFLAGS) TYPE=shell EXT=sh install-links
endif !WIN32

# We support both multiplatform and non-multiplatform builds.
install-links:
	case "$(bindir)" in \
	  */bin) $(MAKE) $(AM_MAKEFLAGS) REL=.. TYPE=$(TYPE) EXT=$(EXT) make-links;; \
	  */bin/*) $(MAKE) $(AM_MAKEFLAGS) REL=../.. TYPE=$(TYPE) EXT=$(EXT) make-links;; \
	  *) echo "strange directory '$(bindir)' for linked $(TYPE) scripts" >&2; \
	     exit 1;; \
	esac

make-links:
	@cd $(DESTDIR)$(bindir) && \
	  for f in $($(TYPE)_scripts); do \
	    rm -f $$f; \
	    echo "creating link '$$f' -> '$(REL)/$(scriptsdir)/$$f.$(EXT)'"; \
	    $(LN_S) $(REL)/$(scriptsdir)/$$f.$(EXT) $$f || exit 1; \
	  done  

uninstall-links:
if !WIN32
	@for f in $(all_scripts); do \
	  echo "rm -f '$(DESTDIR)$(bindir)/$$f'"; \
	  rm -f "$(DESTDIR)$(bindir)/$$f"; \
	done
endif !WIN32