mirror of
				https://github.com/mintty/wsltty.git
				synced 2025-10-31 07:04:00 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			376 lines
		
	
	
		
			12 KiB
		
	
	
	
		
			Makefile
		
	
	
	
	
	
			
		
		
	
	
			376 lines
		
	
	
		
			12 KiB
		
	
	
	
		
			Makefile
		
	
	
	
	
	
| #############################################################################
 | ||
| # build a wsltty installer package:
 | ||
| # configure ver=... and minttyver= in this makefile
 | ||
| # make targets:
 | ||
| # make [all]	build a distributable installer (default)
 | ||
| # make pkg	build an installer, bypassing the system checks
 | ||
| # make build	build the software (no installer)
 | ||
| # make install	install wsltty locally from build (no installer needed)
 | ||
| # make wsltty	build the software, using the local copy of mintty
 | ||
| 
 | ||
| 
 | ||
| ##############################
 | ||
| # mintty and wsltty release versions
 | ||
| wslttyver=3.8.0.2
 | ||
| 
 | ||
| minttyver=3.8.0
 | ||
| 
 | ||
| minrepo=git@github.com:mintty/mintty.git
 | ||
| 
 | ||
| ##############################
 | ||
| # wsltty appx release (obsolete) - must have 4 parts!
 | ||
| appxver=$(wslttyver).1
 | ||
| 
 | ||
| ##############################
 | ||
| 
 | ||
| # wslbridge2 repository and release version
 | ||
| repo=Biswa96/wslbridge2
 | ||
| wslbridgever=0.13
 | ||
| 
 | ||
| # wslbridge2 fork repository and version
 | ||
| #repo=mintty/wslbridge2
 | ||
| #wslbridgever=0.5.1
 | ||
| 
 | ||
| 
 | ||
| # wslbridge2 release or fork archive and dir
 | ||
| archive=v$(wslbridgever)
 | ||
| wslbridgedir=wslbridge2-$(wslbridgever)
 | ||
| 
 | ||
| 
 | ||
| # wslbridge2 latest version
 | ||
| #archive=master
 | ||
| #wslbridgedir=wslbridge2-$(archive)
 | ||
| 
 | ||
| 
 | ||
| # wslbridge2 branch or commit version (from fix-window-resize branch) and dir
 | ||
| #commit=70e0dcea1db122d076ce1578f2a45280cc92d09f
 | ||
| #commit=8b6dd7ee2b3102d72248990c21764c5cf86c6612
 | ||
| # trying post-0.12 WSL V2 patches:
 | ||
| #commit=5b2b652d1a7355b004e7860b4370a585737e5ac9
 | ||
| #commit=274530b35a05df203d3a69f0e28d5015844f39bd
 | ||
| # pixel size patch + fix (retagged as 0.13):
 | ||
| #commit=a7162d852ff438d2d5a8dd8dae61795addb3d980
 | ||
| #archive=$(commit)
 | ||
| #wslbridgedir=wslbridge2-$(archive)
 | ||
| 
 | ||
| 
 | ||
| ##############################
 | ||
| 
 | ||
| # mintty branch or commit version
 | ||
| #minttyver=master
 | ||
| 
 | ||
| # wslbridge branch or commit to build from source;
 | ||
| wslbridge=wslbridge-source wslbridge-frontend wslbridge-backend
 | ||
| 
 | ||
| ##############################
 | ||
| # build backend on a musl-libc-based distribution
 | ||
| # (reportedly not needed anymore but untested)
 | ||
| BuildDistr=-d Alpine
 | ||
| 
 | ||
| ##############################
 | ||
| # Windows SDK version for appx
 | ||
| WINSDKKEY=/HKEY_LOCAL_MACHINE/SOFTWARE/WOW6432Node/Microsoft/.NET Framework Platform/Setup/Multi-Targeting Pack
 | ||
| WINSDKVER=`regtool list '$(WINSDKKEY)' | sed -e '$$ q' -e d`
 | ||
| 
 | ||
| #############################################################################
 | ||
| # default target
 | ||
| 
 | ||
| all:	all-$(notdir $(CURDIR))
 | ||
| 
 | ||
| # targets and version checking
 | ||
| 
 | ||
| all-wsltty:	check committed pkg
 | ||
| 
 | ||
| all-wsltty.appx:	appx
 | ||
| 
 | ||
| committed:
 | ||
| 	if git status -suno | sed -e "s,^..,," | grep .; then false; fi
 | ||
| 
 | ||
| #############################################################################
 | ||
| # target checking and some defs
 | ||
| 
 | ||
| TARGET := $(shell $(CC) -dumpmachine)
 | ||
| 
 | ||
| ifeq ($(TARGET), i686-pc-cygwin)
 | ||
|   sys := cygwin32
 | ||
| else ifeq ($(TARGET), x86_64-pc-cygwin)
 | ||
|   sys := cygwin64
 | ||
| else ifeq ($(TARGET), i686-pc-msys)
 | ||
|   sys := msys32
 | ||
| else ifeq ($(TARGET), x86_64-pc-msys)
 | ||
|   sys := msys64
 | ||
| else
 | ||
|   $(error Target '$(TARGET)' not supported)
 | ||
| endif
 | ||
| 
 | ||
| wget=curl -R -L --connect-timeout 55 -O
 | ||
| wgeto=curl -R -L --connect-timeout 55
 | ||
| 
 | ||
| #############################################################################
 | ||
| # system check:
 | ||
| # - ensure the path name drag-and-drop adaptation works (-> Cygwin, not MSYS)
 | ||
| # - 64 Bit (x86_64) for more stable invocation (avoid fork issues)
 | ||
| 
 | ||
| arch:=$(shell uname -m)
 | ||
| 
 | ||
| check:	# checkarch
 | ||
| 	echo Building for:
 | ||
| 	echo $(arch) | grep .
 | ||
| 	# checking suitable host environment; run `make pkg` to bypass
 | ||
| 	# check cygwin (vs msys) for proper drag-and-drop paths:
 | ||
| 	uname | grep CYGWIN
 | ||
| 
 | ||
| checkarch:
 | ||
| 	# check 32 bit to ensure 32-Bit Windows support, just in case:
 | ||
| 	#uname -m | grep i686
 | ||
| 	# check 64 bit to provide 64-Bit stability support:
 | ||
| 	#uname -m | grep x86_64
 | ||
| 
 | ||
| #############################################################################
 | ||
| # patch version information for appx package configuration
 | ||
| 
 | ||
| fix-appxver:
 | ||
| 	echo patching $(WINSDKVER) into Launcher config
 | ||
| 	cd Launcher; sed -i~ -e "/<supportedRuntime / s,Version=v[.0-9]*,Version=$(WINSDKVER)," app.config
 | ||
| 	echo patched app.config
 | ||
| 	cd Launcher; sed -i~ -e "/<TargetFrameworkVersion>/ s,v[.0-9]*,$(WINSDKVER)," Launcher.csproj
 | ||
| 	echo patched Launcher.csproj
 | ||
| 	echo patching $(appxver) into app config
 | ||
| 	sed -i~ -e '/<Identity / s,Version="[.0-9]*",Version="$(appxver)",' AppxManifest.xml
 | ||
| 	echo patched AppxManifest.xml
 | ||
| 
 | ||
| #############################################################################
 | ||
| # clear binaries
 | ||
| 
 | ||
| clean:
 | ||
| 	rm -fr $(wslbridgedir)/bin
 | ||
| 	rm -fr bin
 | ||
| 
 | ||
| #############################################################################
 | ||
| # generation
 | ||
| 
 | ||
| wslbridge:	$(wslbridge)
 | ||
| 
 | ||
| $(wslbridgedir).zip:
 | ||
| 	$(wgeto) https://github.com/$(repo)/archive/$(archive).zip -o $(wslbridgedir).zip
 | ||
| 
 | ||
| wslbridge-source:	$(wslbridgedir).zip
 | ||
| 	unzip -o $(wslbridgedir).zip
 | ||
| 	cp $(wslbridgedir)/LICENSE LICENSE.wslbridge2
 | ||
| 	# the following two patches are obsolete with wslbridge2 v0.9
 | ||
| 	# patch to fix #220
 | ||
| 	# test case in mintty: (sleep 0.1; echo -e "\e[31;80t") & wslbridge2
 | ||
| 	#cd $(wslbridgedir); patch -p1 < ../0001-notify-size-change-inband.patch
 | ||
| 	# patch to https://github.com/Biswa96/wslbridge2/commit/41575379b416703c49e2687e957440239a4cdfb7
 | ||
| 	#cd $(wslbridgedir); patch -p0 < ../0002-add-com-for-lifted-wsl.patch
 | ||
| 	# patch to fix WSL 2 launching, again
 | ||
| 	# this was replaced with another patch upstream
 | ||
| 	#cd $(wslbridgedir); patch -p1 < ../0012-get-vmid-from-registry.patch
 | ||
| 	# patch to add WINCH/pty pixel size support (Biswa96/wslbridge2#44)
 | ||
| 	#cd $(wslbridgedir); patch -p1 < ../0013-pty-pixel-size.patch
 | ||
| 	# patch to fix the pixel patch of 0.13
 | ||
| 	#cd $(wslbridgedir); patch -p1 < ../0013-pty-pixel-size-fix.patch
 | ||
| 
 | ||
| wslbridge-frontend:
 | ||
| 	echo ------------- Compiling wslbridge2 frontend
 | ||
| 	mkdir -p bin
 | ||
| 	# frontend build
 | ||
| 	cd $(wslbridgedir)/src; make -f Makefile.frontend RELEASE=1
 | ||
| 	# extract binaries
 | ||
| 	cp $(wslbridgedir)/bin/wslbridge2.exe bin/
 | ||
| 
 | ||
| windir=$(shell cd "${WINDIR}"; pwd)
 | ||
| 
 | ||
| wslbridge-backend:
 | ||
| 	echo ------------- Compiling wslbridge2 backend
 | ||
| 	#uname -m | grep x86_64
 | ||
| 	mkdir -p bin
 | ||
| 	# provide dependencies for backend build
 | ||
| 	PATH="$(windir)/Sysnative:${PATH}" cmd /C wsl.exe -u root $(BuildDistr) $(shell env | grep http_proxy=) apk add make g++ linux-headers < /dev/null
 | ||
| 	# invoke backend build
 | ||
| 	cd $(wslbridgedir)/src; PATH="$(windir)/Sysnative:${PATH}" cmd /C wsl.exe $(BuildDistr) make -f Makefile.backend RELEASE=1 < /dev/null
 | ||
| 	# extract binaries
 | ||
| 	cp $(wslbridgedir)/bin/wslbridge2-backend bin/
 | ||
| 
 | ||
| mintty-get:	mintty-git	# mintty-download or mintty-git
 | ||
| 	cp mintty-$(minttyver)/icon/terminal.ico mintty.ico
 | ||
| 
 | ||
| mintty-download:
 | ||
| 	$(wgeto) https://github.com/mintty/mintty/archive/$(minttyver).zip -o mintty-$(minttyver).zip
 | ||
| 	unzip -o mintty-$(minttyver).zip
 | ||
| 
 | ||
| mintty-git:
 | ||
| 	test -d mintty-$(minttyver) || git clone --branch $(minttyver) --depth 1 $(minrepo) mintty-$(minttyver)
 | ||
| 	cd mintty-$(minttyver); git checkout $(minttyver)
 | ||
| 
 | ||
| wslbuild=LDFLAGS="-static -static-libgcc -s"
 | ||
| appxbuild=$(wslbuild) CCOPT=-DWSLTTY_APPX
 | ||
| wslversion=VERSION_SUFFIX="– wsltty $(wslttyver)" WSLTTY_VERSION="$(wslttyver)"
 | ||
| appxversion=VERSION_SUFFIX="– wsltty appx $(appxver)" WSLTTY_VERSION="$(appxver)"
 | ||
| 
 | ||
| mintty-build:
 | ||
| 	# ensure rebuild of version-specific check and message
 | ||
| 	rm -f mintty-$(minttyver)/bin/*/windialog.o
 | ||
| 	rm -f mintty-$(minttyver)/bin/*/winmain.o
 | ||
| 	# build mintty
 | ||
| 	cd mintty-$(minttyver)/src; make $(wslbuild) $(wslversion)
 | ||
| 	mkdir -p bin
 | ||
| 	cp mintty-$(minttyver)/bin/mintty.exe bin/
 | ||
| 	strip bin/mintty.exe
 | ||
| 
 | ||
| mintty-build-appx:
 | ||
| 	# ensure rebuild of version-specific check and message
 | ||
| 	rm -f mintty-$(minttyver)/bin/*/windialog.o
 | ||
| 	# build mintty
 | ||
| 	cd mintty-$(minttyver)/src; make $(appxbuild) $(appxversion)
 | ||
| 	mkdir -p bin
 | ||
| 	cp mintty-$(minttyver)/bin/mintty.exe bin/
 | ||
| 	strip bin/mintty.exe
 | ||
| 
 | ||
| terminfoxt=78/xterm 78/xterm-vt220 78/xterm-256color 78/xterm-direct
 | ||
| terminfovt=76/vt100 76/vt220 76/vt340 76/vt420 76/vt525
 | ||
| terminfomt=6d/mintty 6d/mintty-direct
 | ||
| terminfo=$(terminfoxt) $(terminfovt) $(terminfomt)
 | ||
| 
 | ||
| mintty-pkg:
 | ||
| 	cp mintty-$(minttyver)/LICENSE LICENSE.mintty
 | ||
| 	cd mintty-$(minttyver)/lang; zoo a lang *.po; mv lang.zoo ../../
 | ||
| 	cd mintty-$(minttyver)/themes; zoo a themes *[!~]; mv themes.zoo ../../
 | ||
| 	cd mintty-$(minttyver)/sounds; zoo a sounds *.wav *.WAV *.md; mv sounds.zoo ../../
 | ||
| 	cd /usr/share/terminfo; zoo a /tmp/terminfo $(terminfo)
 | ||
| 	mv /tmp/terminfo.zoo .
 | ||
| 	# add charnames.txt to support "Character Info"
 | ||
| 	cd mintty-$(minttyver)/src; sh ./mknames
 | ||
| 	cp mintty-$(minttyver)/src/charnames.txt .
 | ||
| 
 | ||
| mintty-appx:
 | ||
| 	mkdir -p usr/share/mintty
 | ||
| 	cd usr/share/mintty; mkdir -p lang themes sounds info emojis
 | ||
| 	cp mintty-$(minttyver)/lang/*.po usr/share/mintty/lang/
 | ||
| 	cp mintty-$(minttyver)/themes/*[!~] usr/share/mintty/themes/
 | ||
| 	cp mintty-$(minttyver)/sounds/*.wav usr/share/mintty/sounds/
 | ||
| 	cp mintty-$(minttyver)/sounds/*.WAV usr/share/mintty/sounds/
 | ||
| 	# add charnames.txt to support "Character Info"
 | ||
| 	cd mintty-$(minttyver)/src; sh ./mknames
 | ||
| 	cp mintty-$(minttyver)/src/charnames.txt usr/share/mintty/info/
 | ||
| 	cp /usr/share/mintty/emojis/get*[!~] usr/share/mintty/emojis/
 | ||
| 
 | ||
| cygwin:	# mkshortcutexe
 | ||
| 	mkdir -p bin
 | ||
| 	cp /bin/cygwin1.dll bin/
 | ||
| 	cp /bin/cygwin-console-helper.exe bin/
 | ||
| 	cp /bin/dash.exe bin/
 | ||
| 	cp /bin/regtool.exe bin/
 | ||
| 	cp /bin/zoo.exe bin/
 | ||
| 
 | ||
| mkshortcutexe:	bin/mkshortcut.exe
 | ||
| 
 | ||
| bin/mkshortcut.exe:	mkshortcut.c
 | ||
| 	echo mksh
 | ||
| 	gcc -o bin/mkshortcut mkshortcut.c -lpopt -lole32 /usr/lib/w32api/libuuid.a
 | ||
| 	cp /bin/cygpopt-0.dll bin/
 | ||
| 	cp /bin/cygiconv-2.dll bin/
 | ||
| 	cp /bin/cygintl-8.dll bin/
 | ||
| 
 | ||
| appx-bin:
 | ||
| 	mkdir -p bin
 | ||
| 	cp /bin/cygwin1.dll bin/
 | ||
| 	cp /bin/cygwin-console-helper.exe bin/
 | ||
| 
 | ||
| CAB=wsltty-$(wslttyver)-$(arch)
 | ||
| 
 | ||
| copcab:	ver
 | ||
| 	mkdir -p $(CAB)
 | ||
| 	cp bin/cygwin1.dll $(CAB)/
 | ||
| 	cp bin/cygwin-console-helper.exe $(CAB)/
 | ||
| 	cp bin/dash.exe $(CAB)/
 | ||
| 	cp bin/regtool.exe $(CAB)/
 | ||
| 	cp bin/mintty.exe $(CAB)/
 | ||
| 	cp bin/zoo.exe $(CAB)/
 | ||
| 	cp lang.zoo $(CAB)/
 | ||
| 	cp themes.zoo $(CAB)/
 | ||
| 	cp sounds.zoo $(CAB)/
 | ||
| 	cp terminfo.zoo $(CAB)/
 | ||
| 	cp charnames.txt $(CAB)/
 | ||
| 	cp bin/wslbridge2.exe $(CAB)/
 | ||
| 	cp bin/wslbridge2-backend $(CAB)/
 | ||
| 	cp mkshortcut.vbs $(CAB)/
 | ||
| 	#cp bin/mkshortcut.exe $(CAB)/
 | ||
| 	#cp bin/cygpopt-0.dll $(CAB)/
 | ||
| 	#cp bin/cygiconv-2.dll $(CAB)/
 | ||
| 	#cp bin/cygintl-8.dll $(CAB)/
 | ||
| 	cp LICENSE.* $(CAB)/
 | ||
| 	cp VERSION $(CAB)/
 | ||
| 	cp *.lnk $(CAB)/
 | ||
| 	cp *.ico $(CAB)/
 | ||
| 	cp *.url $(CAB)/
 | ||
| 	cp *.bat $(CAB)/
 | ||
| 	cp config-distros.sh $(CAB)/
 | ||
| 	cp mkshortcut.vbs $(CAB)/
 | ||
| 	cp mintty-$(minttyver)/tools/get*[!~] $(CAB)/
 | ||
| 
 | ||
| cop:	copcab
 | ||
| 	mkdir -p rel
 | ||
| 	cp -fl $(CAB)/* rel/
 | ||
| 
 | ||
| installer:	cop cab normal-installer silent-installer portable-installer
 | ||
| 
 | ||
| cab:
 | ||
| 	# build cab archive
 | ||
| 	lcab -r $(CAB) rel/$(CAB).cab
 | ||
| 
 | ||
| normal-installer:
 | ||
| 	# prepare build of installer
 | ||
| 	rm -f rel/$(CAB)-install.exe
 | ||
| 	sed -e "s,%version%,$(wslttyver)," -e "s,%arch%,$(arch)," makewinx.cfg > rel/wsltty.SED
 | ||
| 	# build installer
 | ||
| 	cd rel; iexpress /n /q wsltty.SED
 | ||
| 
 | ||
| silent-installer:
 | ||
| 	# prepare build of installer
 | ||
| 	rm -f rel/$(CAB)-install-quiet.exe
 | ||
| 	cd rel; sed -e "/ShowInstallProgramWindow/ s/0/1/" -e "/HideExtractAnimation/ s/0/1/" -e "/InstallPrompt/ s/=.*/=/" -e "/FinishMessage/ s/=.*/=/" -e "/TargetName/ s/install.exe/install-quiet.exe/" wsltty.SED > wsltty-quiet.SED
 | ||
| 	# build installer
 | ||
| 	cd rel; iexpress /n /q wsltty-quiet.SED
 | ||
| 
 | ||
| InstallPrompt=Install Mintty terminal for WSL Portable?
 | ||
| FinishMessage=Mintty for WSL Portable installation finished
 | ||
| 
 | ||
| portable-installer:
 | ||
| 	# prepare build of installer
 | ||
| 	rm -f rel/$(CAB)-install-portable.exe
 | ||
| 	cd rel; sed -e "/InstallPrompt/ s/=.*/=$(InstallPrompt)/" -e "/FinishMessage/ s/=.*/=$(FinishMessage)/" -e "/AppLaunched/ s/install/install-portable/" -e "/TargetName/ s/install.exe/install-portable.exe/" wsltty.SED > wsltty-portable.SED
 | ||
| 	# build installer
 | ||
| 	cd rel; iexpress /n /q wsltty-portable.SED
 | ||
| 
 | ||
| install:	cop installbat
 | ||
| 
 | ||
| installbat:
 | ||
| 	cd rel; cmd /C install
 | ||
| 
 | ||
| ver:
 | ||
| 	echo $(wslttyver) > VERSION
 | ||
| 
 | ||
| mintty:	mintty-get mintty-build
 | ||
| 
 | ||
| mintty-usr:	mintty-get mintty-appx
 | ||
| 
 | ||
| # local wsltty build target:
 | ||
| wsltty:	wslbridge cygwin mintty-build mintty-pkg
 | ||
| 
 | ||
| # build software without installer:
 | ||
| build:	wslbridge cygwin mintty-get mintty-build mintty-pkg
 | ||
| 
 | ||
| # standalone wsltty package build target:
 | ||
| pkg:	wslbridge cygwin mintty-get mintty-build mintty-pkg installer
 | ||
| 
 | ||
| # appx package contents target:
 | ||
| wsltty-appx:	wslbridge appx-bin mintty-get mintty-build-appx mintty-appx
 | ||
| 
 | ||
| # appx package target:
 | ||
| appx:	wsltty-appx fix-appxver
 | ||
| 	sh ./build.sh
 | ||
| 
 | ||
| #############################################################################
 | ||
| # end
 |