windows host: add embedded manifest file

Without a manifest, Windows applications force a fixed PATH_MAX limit
to any pathname; this is unnecessary.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
This commit is contained in:
H. Peter Anvin 2024-01-29 17:19:32 -08:00
parent adf4f5cd5e
commit 1e965e30ff
7 changed files with 64 additions and 16 deletions

View File

@ -55,6 +55,7 @@ ASCIIDOC = @ASCIIDOC@
XMLTO = @XMLTO@
MAKENSIS = @MAKENSIS@
XZ = @XZ@
WINDRES = @WINDRES@
# Optional targets
MANPAGES = @MANPAGES@
@ -98,6 +99,8 @@ endif
.xml.1:
$(XMLTO) man --skip-validation $< 2>/dev/null
MANIFEST = @MANIFEST@
#-- Begin File Lists --#
NASM = asm/nasm.$(O)
NDISASM = disasm/ndisasm.$(O)
@ -159,7 +162,7 @@ LIBOBJ = $(LIBOBJ_NW) $(WARNOBJ)
ALLOBJ_NW = $(PROGOBJ) $(LIBOBJ_NW)
ALLOBJ = $(PROGOBJ) $(LIBOBJ)
SUBDIRS = stdlib nasmlib output asm disasm x86 common macros
SUBDIRS = stdlib nasmlib output asm disasm x86 common macros win
XSUBDIRS = test doc nsis
DEPDIRS = . include config x86 $(SUBDIRS)
#-- End File Lists --#
@ -177,11 +180,11 @@ $(NASMLIB): $(LIBOBJ)
$(AR) cq $(NASMLIB) $(LIBOBJ)
$(RANLIB) $(NASMLIB)
nasm$(X): $(NASM) $(NASMLIB)
$(CC) $(ALL_LDFLAGS) -o nasm$(X) $(NASM) $(NASMLIB) $(LIBS)
nasm$(X): $(NASM) $(MANIFEST) $(NASMLIB)
$(CC) $(ALL_LDFLAGS) -o nasm$(X) $^ $(LIBS)
ndisasm$(X): $(NDISASM) $(NASMLIB)
$(CC) $(ALL_LDFLAGS) -o ndisasm$(X) $(NDISASM) $(NASMLIB) $(LIBS)
ndisasm$(X): $(NDISASM) $(MANIFEST) $(NASMLIB)
$(CC) $(ALL_LDFLAGS) -o ndisasm$(X) $^ $(LIBS)
#-- Begin Generated File Rules --#
@ -362,6 +365,11 @@ nsis: nsis/nasm.nsi nsis/arch.nsh nsis/version.nsh
#-- End NSIS Rules --#
# Windows embedded manifest
MANIFEST_RC = win/manifest.rc
win/manifest.$(O): win/manifest.xml $(MANIFEST_RC)
$(WINDRES) -I. -Iwin -DMANIFEST_FILE='\"$<\"' -i $(MANIFEST_RC) -o $@
# Generated manpages, also pregenerated for distribution
manpages: nasm.1 ndisasm.1

View File

@ -18,12 +18,15 @@ exec_prefix = $(prefix)
bindir = $(prefix)/bin
mandir = $(prefix)/man
MANIFEST_FLAGS = /MANIFEST:EMBED /MANIFESTFILE:$(MANIFEST)
!IF "$(DEBUG)" == "1"
CFLAGS = /Od /Zi
LDFLAGS = /DEBUG
LDFLAGS = /DEBUG $(MANIFEST_FLAGS)
!ELSE
CFLAGS = /O2 /Zi
LDFLAGS = /DEBUG /OPT:REF /OPT:ICF # (latter two undoes /DEBUG harm)
# /OPT:REF and /OPT:ICF two undo /DEBUG harm
LDFLAGS = /DEBUG /OPT:REF /OPT:ICF $(MANIFEST_FLAGS)
!ENDIF
CC = cl
@ -59,6 +62,8 @@ X = .exe
.c.obj:
$(CC) /c $(ALL_CFLAGS) /Fo$@ $<
MANIFEST = win/manifest.xml
#-- Begin File Lists --#
# Edit in Makefile.in, not here!
NASM = asm\nasm.$(O)
@ -77,7 +82,8 @@ LIBOBJ_NW = stdlib\snprintf.$(O) stdlib\vsnprintf.$(O) stdlib\strlcpy.$(O) \
nasmlib\file.$(O) nasmlib\mmap.$(O) nasmlib\ilog2.$(O) \
nasmlib\realpath.$(O) nasmlib\path.$(O) \
nasmlib\filename.$(O) nasmlib\rlimit.$(O) \
nasmlib\zerobuf.$(O) nasmlib\readnum.$(O) nasmlib\bsi.$(O) \
nasmlib\readnum.$(O) nasmlib\numstr.$(O) \
nasmlib\zerobuf.$(O) nasmlib\bsi.$(O) \
nasmlib\rbtree.$(O) nasmlib\hashtbl.$(O) \
nasmlib\raa.$(O) nasmlib\saa.$(O) \
nasmlib\strlist.$(O) \
@ -120,7 +126,7 @@ LIBOBJ = $(LIBOBJ_NW) $(WARNOBJ)
ALLOBJ_NW = $(PROGOBJ) $(LIBOBJ_NW)
ALLOBJ = $(PROGOBJ) $(LIBOBJ)
SUBDIRS = stdlib nasmlib output asm disasm x86 common macros
SUBDIRS = stdlib nasmlib output asm disasm x86 common macros win
XSUBDIRS = test doc nsis
DEPDIRS = . include config x86 $(SUBDIRS)
#-- End File Lists --#
@ -129,10 +135,10 @@ NASMLIB = libnasm.$(A)
all: nasm$(X) ndisasm$(X)
nasm$(X): $(NASM) $(NASMLIB)
nasm$(X): $(NASM) $(MANIFEST) $(NASMLIB)
$(CC) /Fe$@ $(NASM) $(LDFLAGS) $(NASMLIB) $(LIBS)
ndisasm$(X): $(NDISASM) $(NASMLIB)
ndisasm$(X): $(NDISASM) $(MANIFEST) $(NASMLIB)
$(CC) /Fe$@ $(NDISASM) $(LDFLAGS) $(NASMLIB) $(LIBS)
$(NASMLIB): $(LIBOBJ)

View File

@ -48,6 +48,8 @@ X = .exe
@set INCLUDE=
$(CC) -c $(ALL_CFLAGS) -fo=$^@ $[@
MANIFEST =
#-- Begin File Lists --#
# Edit in Makefile.in, not here!
NASM = asm\nasm.$(O)
@ -66,7 +68,8 @@ LIBOBJ_NW = stdlib\snprintf.$(O) stdlib\vsnprintf.$(O) stdlib\strlcpy.$(O) &
nasmlib\file.$(O) nasmlib\mmap.$(O) nasmlib\ilog2.$(O) &
nasmlib\realpath.$(O) nasmlib\path.$(O) &
nasmlib\filename.$(O) nasmlib\rlimit.$(O) &
nasmlib\zerobuf.$(O) nasmlib\readnum.$(O) nasmlib\bsi.$(O) &
nasmlib\readnum.$(O) nasmlib\numstr.$(O) &
nasmlib\zerobuf.$(O) nasmlib\bsi.$(O) &
nasmlib\rbtree.$(O) nasmlib\hashtbl.$(O) &
nasmlib\raa.$(O) nasmlib\saa.$(O) &
nasmlib\strlist.$(O) &
@ -109,7 +112,7 @@ LIBOBJ = $(LIBOBJ_NW) $(WARNOBJ)
ALLOBJ_NW = $(PROGOBJ) $(LIBOBJ_NW)
ALLOBJ = $(PROGOBJ) $(LIBOBJ)
SUBDIRS = stdlib nasmlib output asm disasm x86 common macros
SUBDIRS = stdlib nasmlib output asm disasm x86 common macros win
XSUBDIRS = test doc nsis
DEPDIRS = . include config x86 $(SUBDIRS)
#-- End File Lists --#

View File

@ -17,9 +17,6 @@ dnl cross-compiling when in fact we are; running Wine here is at
dnl the best very slow and doesn't buy us a single thing at all.
PA_CROSS_COMPILE
dnl Get the canonical target system name
AC_CANONICAL_HOST
dnl Enable any available C extensions
AC_PROG_CC
AC_USE_SYSTEM_EXTENSIONS
@ -151,6 +148,13 @@ AC_CHECK_INCLUDES_DEFAULT
dnl Check for variadic macro support
PA_VARIADIC_MACROS
dnl Handle Windows embedded manifests
AS_CASE([$host],
[*-win* | *-mingw*],
[AC_CHECK_TOOL(WINDRES, windres, false)
AS_IF([test x"$WINDRES" != xfalse],
[AC_SUBST(MANIFEST, ['win/manifest.$(O)'])])])
PA_ADD_HEADERS(string.h)
PA_ADD_HEADERS(stdarg.h)
PA_ADD_HEADERS(inttypes.h)

1
win/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
!*.xml

2
win/manifest.rc Normal file
View File

@ -0,0 +1,2 @@
LANGUAGE 0,0
1 24 MANIFEST_FILE

24
win/manifest.xml Normal file
View File

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="asInvoker" />
</requestedPrivileges>
</security>
</trustInfo>
<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">
<longPathAware>true</longPathAware>
</windowsSettings>
</application>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}" />
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}" />
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" />
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}" />
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />
</application>
</compatibility>
</assembly>