Skip to content

Commit 1e965e3

Browse files
author
H. Peter Anvin
committed
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 <[email protected]>
1 parent adf4f5c commit 1e965e3

File tree

7 files changed

+64
-16
lines changed

7 files changed

+64
-16
lines changed

Makefile.in

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ ASCIIDOC = @ASCIIDOC@
5555
XMLTO = @XMLTO@
5656
MAKENSIS = @MAKENSIS@
5757
XZ = @XZ@
58+
WINDRES = @WINDRES@
5859

5960
# Optional targets
6061
MANPAGES = @MANPAGES@
@@ -98,6 +99,8 @@ endif
9899
.xml.1:
99100
$(XMLTO) man --skip-validation $< 2>/dev/null
100101

102+
MANIFEST = @MANIFEST@
103+
101104
#-- Begin File Lists --#
102105
NASM = asm/nasm.$(O)
103106
NDISASM = disasm/ndisasm.$(O)
@@ -159,7 +162,7 @@ LIBOBJ = $(LIBOBJ_NW) $(WARNOBJ)
159162
ALLOBJ_NW = $(PROGOBJ) $(LIBOBJ_NW)
160163
ALLOBJ = $(PROGOBJ) $(LIBOBJ)
161164

162-
SUBDIRS = stdlib nasmlib output asm disasm x86 common macros
165+
SUBDIRS = stdlib nasmlib output asm disasm x86 common macros win
163166
XSUBDIRS = test doc nsis
164167
DEPDIRS = . include config x86 $(SUBDIRS)
165168
#-- End File Lists --#
@@ -177,11 +180,11 @@ $(NASMLIB): $(LIBOBJ)
177180
$(AR) cq $(NASMLIB) $(LIBOBJ)
178181
$(RANLIB) $(NASMLIB)
179182

180-
nasm$(X): $(NASM) $(NASMLIB)
181-
$(CC) $(ALL_LDFLAGS) -o nasm$(X) $(NASM) $(NASMLIB) $(LIBS)
183+
nasm$(X): $(NASM) $(MANIFEST) $(NASMLIB)
184+
$(CC) $(ALL_LDFLAGS) -o nasm$(X) $^ $(LIBS)
182185

183-
ndisasm$(X): $(NDISASM) $(NASMLIB)
184-
$(CC) $(ALL_LDFLAGS) -o ndisasm$(X) $(NDISASM) $(NASMLIB) $(LIBS)
186+
ndisasm$(X): $(NDISASM) $(MANIFEST) $(NASMLIB)
187+
$(CC) $(ALL_LDFLAGS) -o ndisasm$(X) $^ $(LIBS)
185188

186189
#-- Begin Generated File Rules --#
187190

@@ -362,6 +365,11 @@ nsis: nsis/nasm.nsi nsis/arch.nsh nsis/version.nsh
362365

363366
#-- End NSIS Rules --#
364367

368+
# Windows embedded manifest
369+
MANIFEST_RC = win/manifest.rc
370+
win/manifest.$(O): win/manifest.xml $(MANIFEST_RC)
371+
$(WINDRES) -I. -Iwin -DMANIFEST_FILE='\"$<\"' -i $(MANIFEST_RC) -o $@
372+
365373
# Generated manpages, also pregenerated for distribution
366374
manpages: nasm.1 ndisasm.1
367375

Mkfiles/msvc.mak

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,15 @@ exec_prefix = $(prefix)
1818
bindir = $(prefix)/bin
1919
mandir = $(prefix)/man
2020

21+
MANIFEST_FLAGS = /MANIFEST:EMBED /MANIFESTFILE:$(MANIFEST)
22+
2123
!IF "$(DEBUG)" == "1"
2224
CFLAGS = /Od /Zi
23-
LDFLAGS = /DEBUG
25+
LDFLAGS = /DEBUG $(MANIFEST_FLAGS)
2426
!ELSE
2527
CFLAGS = /O2 /Zi
26-
LDFLAGS = /DEBUG /OPT:REF /OPT:ICF # (latter two undoes /DEBUG harm)
28+
# /OPT:REF and /OPT:ICF two undo /DEBUG harm
29+
LDFLAGS = /DEBUG /OPT:REF /OPT:ICF $(MANIFEST_FLAGS)
2730
!ENDIF
2831

2932
CC = cl
@@ -59,6 +62,8 @@ X = .exe
5962
.c.obj:
6063
$(CC) /c $(ALL_CFLAGS) /Fo$@ $<
6164

65+
MANIFEST = win/manifest.xml
66+
6267
#-- Begin File Lists --#
6368
# Edit in Makefile.in, not here!
6469
NASM = asm\nasm.$(O)
@@ -77,7 +82,8 @@ LIBOBJ_NW = stdlib\snprintf.$(O) stdlib\vsnprintf.$(O) stdlib\strlcpy.$(O) \
7782
nasmlib\file.$(O) nasmlib\mmap.$(O) nasmlib\ilog2.$(O) \
7883
nasmlib\realpath.$(O) nasmlib\path.$(O) \
7984
nasmlib\filename.$(O) nasmlib\rlimit.$(O) \
80-
nasmlib\zerobuf.$(O) nasmlib\readnum.$(O) nasmlib\bsi.$(O) \
85+
nasmlib\readnum.$(O) nasmlib\numstr.$(O) \
86+
nasmlib\zerobuf.$(O) nasmlib\bsi.$(O) \
8187
nasmlib\rbtree.$(O) nasmlib\hashtbl.$(O) \
8288
nasmlib\raa.$(O) nasmlib\saa.$(O) \
8389
nasmlib\strlist.$(O) \
@@ -120,7 +126,7 @@ LIBOBJ = $(LIBOBJ_NW) $(WARNOBJ)
120126
ALLOBJ_NW = $(PROGOBJ) $(LIBOBJ_NW)
121127
ALLOBJ = $(PROGOBJ) $(LIBOBJ)
122128

123-
SUBDIRS = stdlib nasmlib output asm disasm x86 common macros
129+
SUBDIRS = stdlib nasmlib output asm disasm x86 common macros win
124130
XSUBDIRS = test doc nsis
125131
DEPDIRS = . include config x86 $(SUBDIRS)
126132
#-- End File Lists --#
@@ -129,10 +135,10 @@ NASMLIB = libnasm.$(A)
129135

130136
all: nasm$(X) ndisasm$(X)
131137

132-
nasm$(X): $(NASM) $(NASMLIB)
138+
nasm$(X): $(NASM) $(MANIFEST) $(NASMLIB)
133139
$(CC) /Fe$@ $(NASM) $(LDFLAGS) $(NASMLIB) $(LIBS)
134140

135-
ndisasm$(X): $(NDISASM) $(NASMLIB)
141+
ndisasm$(X): $(NDISASM) $(MANIFEST) $(NASMLIB)
136142
$(CC) /Fe$@ $(NDISASM) $(LDFLAGS) $(NASMLIB) $(LIBS)
137143

138144
$(NASMLIB): $(LIBOBJ)

Mkfiles/openwcom.mak

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ X = .exe
4848
@set INCLUDE=
4949
$(CC) -c $(ALL_CFLAGS) -fo=$^@ $[@
5050

51+
MANIFEST =
52+
5153
#-- Begin File Lists --#
5254
# Edit in Makefile.in, not here!
5355
NASM = asm\nasm.$(O)
@@ -66,7 +68,8 @@ LIBOBJ_NW = stdlib\snprintf.$(O) stdlib\vsnprintf.$(O) stdlib\strlcpy.$(O) &
6668
nasmlib\file.$(O) nasmlib\mmap.$(O) nasmlib\ilog2.$(O) &
6769
nasmlib\realpath.$(O) nasmlib\path.$(O) &
6870
nasmlib\filename.$(O) nasmlib\rlimit.$(O) &
69-
nasmlib\zerobuf.$(O) nasmlib\readnum.$(O) nasmlib\bsi.$(O) &
71+
nasmlib\readnum.$(O) nasmlib\numstr.$(O) &
72+
nasmlib\zerobuf.$(O) nasmlib\bsi.$(O) &
7073
nasmlib\rbtree.$(O) nasmlib\hashtbl.$(O) &
7174
nasmlib\raa.$(O) nasmlib\saa.$(O) &
7275
nasmlib\strlist.$(O) &
@@ -109,7 +112,7 @@ LIBOBJ = $(LIBOBJ_NW) $(WARNOBJ)
109112
ALLOBJ_NW = $(PROGOBJ) $(LIBOBJ_NW)
110113
ALLOBJ = $(PROGOBJ) $(LIBOBJ)
111114

112-
SUBDIRS = stdlib nasmlib output asm disasm x86 common macros
115+
SUBDIRS = stdlib nasmlib output asm disasm x86 common macros win
113116
XSUBDIRS = test doc nsis
114117
DEPDIRS = . include config x86 $(SUBDIRS)
115118
#-- End File Lists --#

configure.ac

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@ dnl cross-compiling when in fact we are; running Wine here is at
1717
dnl the best very slow and doesn't buy us a single thing at all.
1818
PA_CROSS_COMPILE
1919

20-
dnl Get the canonical target system name
21-
AC_CANONICAL_HOST
22-
2320
dnl Enable any available C extensions
2421
AC_PROG_CC
2522
AC_USE_SYSTEM_EXTENSIONS
@@ -151,6 +148,13 @@ AC_CHECK_INCLUDES_DEFAULT
151148
dnl Check for variadic macro support
152149
PA_VARIADIC_MACROS
153150

151+
dnl Handle Windows embedded manifests
152+
AS_CASE([$host],
153+
[*-win* | *-mingw*],
154+
[AC_CHECK_TOOL(WINDRES, windres, false)
155+
AS_IF([test x"$WINDRES" != xfalse],
156+
[AC_SUBST(MANIFEST, ['win/manifest.$(O)'])])])
157+
154158
PA_ADD_HEADERS(string.h)
155159
PA_ADD_HEADERS(stdarg.h)
156160
PA_ADD_HEADERS(inttypes.h)

win/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
!*.xml

win/manifest.rc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
LANGUAGE 0,0
2+
1 24 MANIFEST_FILE

win/manifest.xml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2+
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
3+
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
4+
<security>
5+
<requestedPrivileges>
6+
<requestedExecutionLevel level="asInvoker" />
7+
</requestedPrivileges>
8+
</security>
9+
</trustInfo>
10+
<application xmlns="urn:schemas-microsoft-com:asm.v3">
11+
<windowsSettings xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">
12+
<longPathAware>true</longPathAware>
13+
</windowsSettings>
14+
</application>
15+
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
16+
<application>
17+
<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}" />
18+
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}" />
19+
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" />
20+
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}" />
21+
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />
22+
</application>
23+
</compatibility>
24+
</assembly>

0 commit comments

Comments
 (0)