Skip to content

Commit 8f4c969

Browse files
committed
Eliminate <win32.mak> dependency for Windows builds of Hercules
Closes #448.
1 parent 99b07a5 commit 8f4c969

File tree

6 files changed

+72
-113
lines changed

6 files changed

+72
-113
lines changed

makefile-dllmod.msvc

Lines changed: 44 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,52 @@ INCDIR = msvc.makefile.includes
2121
!INCLUDE $(INCDIR)\HQA_DIR.msvc
2222
# ---------------------------------------------------------------------
2323

24-
###################################################
25-
# NOTE! must set the 'NODEBUG' variable properly
26-
# BEFORE calling win32.mak since it uses it.
27-
###################################################
24+
cc = cl
25+
link = link
26+
implib = lib
27+
rc = Rc
2828

29-
# ---------------------------------------------------------------------
30-
!INCLUDE <win32.mak>
31-
# ---------------------------------------------------------------------
29+
# Settings common to all architectures and builds...
30+
31+
rcflags = /r
32+
conlflags = /INCREMENTAL:NO /NOLOGO -subsystem:console,$(APPVER)
33+
conlibsdll = kernel32.lib ws2_32.lib mswsock.lib advapi32.lib
34+
cflags = -c -DCRTAPI1=_cdecl -DCRTAPI2=_cdecl -nologo -GS -DWIN32 -D_WIN32 -W3 -D_WINNT -D_WIN32_WINNT=$(NMAKE_WINVER) -DNTDDI_VERSION=$(NMAKE_WINVER)0000 -D_WIN32_IE=$(_WIN32_IE) -DWINVER=$(NMAKE_WINVER)
35+
cvarsdll = -D_MT -D_DLL
36+
dlllflags = /INCREMENTAL:NO /NOLOGO -dll
37+
rcvars = -DWIN32 -D_WIN32 -DWINVER=$(NMAKE_WINVER)
38+
39+
# Now set values unique to architecture and/or build...
40+
41+
!IF "$(CFG)" == "DEBUG"
42+
43+
cdebug = -Zi -Od -DDEBUG
44+
ldebug = /DEBUG /DEBUGTYPE:cv
45+
rcvars = $(rcvars) -DDEBUG -D_DEBUG
46+
cvarsdll = $(cvarsdll) -MDd
47+
48+
!ELSE
49+
50+
cdebug = -Ox -DNDEBUG
51+
ldebug = /RELEASE
52+
rcvars = $(rcvars)
53+
cvarsdll = $(cvarsdll) -MD
3254

33-
###################################################
34-
# NOTE! must set our prefered 'cdebug' value(s)
35-
# AFTER calling win32.mak since it sets it.
36-
###################################################
55+
!ENDIF
56+
57+
!IF "$(CPU)" == "AMD64"
58+
59+
cflags = $(cflags) -D_AMD64_=1 -DWIN64 -D_WIN64
60+
dlllflags = $(dlllflags) -entry:_DllMainCRTStartup
61+
rcvars = $(rcvars) -DWIN64 -D_WIN64
62+
63+
!ELSE
64+
65+
cflags = $(cflags) -D_X86_=1
66+
dlllflags = $(dlllflags) -entry:_DllMainCRTStartup@12
67+
rcvars = $(rcvars)
68+
69+
!ENDIF
3770

3871
# ---------------------------------------------------------------------
3972
!INCLUDE $(INCDIR)\DEBUG_RETAIL.msvc

makefile.bat

Lines changed: 3 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -392,14 +392,6 @@
392392

393393
call :dump_env
394394

395-
echo.
396-
echo ------------------------------ WIN32.MAK -------------------------------
397-
echo.
398-
echo ^<win32.mak^> will be !INCLUDEd from "%win32_mak_dir%"...
399-
echo.
400-
echo --------------------------------- MAKE ---------------------------------
401-
echo.
402-
403395
:: Additional nmake arguments (for reference):
404396
::
405397
:: -nologo suppress copyright banner
@@ -571,60 +563,13 @@
571563
set "rc=0"
572564

573565
if not exist "%makefile_name%" (
574-
goto :missing_herc_makefile
575-
)
576-
577-
set "opath=%path%"
578-
set "path=%opath%;%include%"
579-
call :fullpath "win32.mak"
580-
set "path=%opath%"
581-
set "opath="
582-
583-
if not defined fullpath (
584-
goto :missing_win32_makefile
585-
)
586-
587-
set "win32_mak_path=%fullpath%"
588-
for %%i in ("%win32_mak_path%") do (set "win32_mak_dir=%%~di%%~pi")
589-
%return%
590-
591-
:missing_herc_makefile
592-
593-
echo.
594-
echo %~nx0^(1^) : error C9999 : makefile "%makefile_name%" not found
595-
set "rc=1"
596-
%return%
597-
598-
:missing_win32_makefile
599-
600-
echo.
601-
echo %~nx0^(1^) : error C9999 : .
602-
echo %~nx0^(1^) : error C9999 : ^<win32.mak^> not found!
603-
604-
echo %~nx0^(1^) : warning C9999 : .
605-
echo %~nx0^(1^) : warning C9999 : You need to have the Windows 7.1 SDK installed which has ^<win32.mak^>.
606-
echo %~nx0^(1^) : warning C9999 : Neither the Windows 8 SDK nor the Windows 10 SDK has ^<win32.mak^>.
607-
echo %~nx0^(1^) : warning C9999 : Only the Windows 7.1 or older SDK will have ^<win32.mak^>.
608-
609-
if %vsver% GEQ %vs2015% (
610-
611-
echo %~nx0^(1^) : warning C9999 : .
612-
echo %~nx0^(1^) : warning C9999 : When you install Visual Studio %vsname% Community Edition, you
613-
echo %~nx0^(1^) : warning C9999 : must also select the "Windows XP Support for C++" option in the
614-
echo %~nx0^(1^) : warning C9999 : "Visual C++" section of the "Programming Languages" feature,
615-
echo %~nx0^(1^) : warning C9999 : which is the option that installs the Windows 7.1 SDK.
616-
566+
echo.
567+
echo %~nx0^(1^) : error C9999 : makefile "%makefile_name%" not found
568+
set "rc=1"
617569
)
618570

619-
echo %~nx0^(1^) : warning C9999 : .
620-
echo %~nx0^(1^) : warning C9999 : You need to add the 7.1A SDK "Include" directory to the "INCLUDE"
621-
echo %~nx0^(1^) : warning C9999 : environment variable and retry your build of Hercules.
622-
echo %~nx0^(1^) : warning C9999 : .
623-
624-
set "rc=1"
625571
%return%
626572

627-
628573
::-----------------------------------------------------------------------------
629574
:: validate_num_cpus
630575
::-----------------------------------------------------------------------------

msvc.makefile.includes/CONFIG.msvc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
# (C) Copyright Roger Bowler, 2005-2007
55
# --------------------------------------------------------------------------
66
#
7-
# Set NODEBUG flag appropriately before !INCLUDEing <win32.mak>
8-
# and determine target processor type.
7+
# Determine target processor and build type.
98
#
109
# ***************************************************************************
1110

msvc.makefile.includes/DEBUG_RETAIL.msvc

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,14 @@
1010
#
1111
# ***************************************************************************
1212

13-
# -------------------------------------------------
14-
# NOTE! must set our prefered 'cdebug' value(s)
15-
# AFTER calling win32.mak since it sets it.
16-
# -------------------------------------------------
17-
1813
MAPFILE = /map:$(MAPDIR)\$(@B).map
1914

2015
!IFDEF NODEBUG
2116
# -------------------------------
2217
# RETAIL: full optimization
2318
# -------------------------------
2419

25-
# PROGRAMMING NOTE: we're purposely discarding win32.mak's $(cdebug) settings
20+
# PROGRAMMING NOTE: we're purposely discarding the existing $(cdebug) setting
2621
# and replacing them with our own by leaving "$(cdebug)" out of the statement
2722

2823
cdebug = /O2 /GL /D NDEBUG
@@ -39,7 +34,7 @@ ldebug = $(ldebug) /DEBUG /PDB:$(PDBDIR)\$(@B).pdb
3934
# DEBUG: no optimizations at all
4035
# -------------------------------
4136

42-
# PROGRAMMING NOTE: we're purposely discarding win32.mak's $(cdebug) settings
37+
# PROGRAMMING NOTE: we're purposely discarding the existing $(cdebug) setting
4338
# and replacing them with our own by leaving "$(cdebug)" out of the statement
4439

4540
cdebug = -Zi -Od -D DEBUG -D _DEBUG -Gm

msvc.makefile.includes/HERC_FLAGS.msvc

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -65,24 +65,9 @@ cflags = $(cflags) /wd4996
6565

6666
ldebug = $(ldebug) /MANIFEST
6767

68-
# Because Level 4 warnings will be disabled (see immediately below), we need
69-
# to specifically request the following (IMHO) important warning be treated
68+
# Specifically request the following (IMHO) important warning be treated
7069
# as a Level 1 warning instead of a Level 4 warning (which is its default):
71-
# "C4296: warning: expression is always false". (We do it both before/after
72-
# disabling Level 4 warnings just to be safe)
73-
cflags = $(cflags) /w14296
74-
75-
# WIN64 builds set level-4 diagnostics which are too intense for our liking,
76-
# resulting in far too many uninteresting warning messages. Thus we override
77-
# win32.mak's options for WIN64 to reinstate the default level-3 diagnostics
78-
cflags = $(cflags:-W4=-W3)
79-
cflags = $(cflags:/W4=/W3)
80-
81-
# Because Level-4 warnings are now disabled (see immediately above), we need
82-
# to specifically re-enable the following (IMHO) important warning:
83-
# "C4296: warning: expression is always false". Note the /w option being used
84-
# requests warning 4296 be treated as a Level 1 warning instead of Level 4.
85-
# (We do it both before/after disabling Level 4 warnings just to be safe)
70+
# "C4296: warning: expression is always false".
8671
cflags = $(cflags) /w14296
8772

8873
# Convert the following warnings into errors

msvc.makefile.includes/TARGETVER.msvc

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,33 +4,35 @@
44
# (c) "Fish" (David B. Trout), 2017
55
# --------------------------------------------------------------------------
66
#
7-
# Set APPVER and TARGETOS makefile target variables for <win32.mak>
8-
# VSVERS.msvc must be !INCLUDE beforehand by makefile-dllmod.msvc
9-
#
10-
# ***************************************************************************
11-
#
127
# TargetVer for makefile projects
138
#
14-
# The following defines determines the minimum Windows platform on which
15-
# the application can run. Set APPVER and TARGETOS as needed and win32.mak
16-
# will then define '_WIN32_WINNT' and other associated values accordingly.
9+
# Set the APPVER, TARGETOS, _WIN32_IE and NMAKE_WINVER variables
10+
# defining the minimum Windows platform on which the application can run.
1711
#
1812
# ***************************************************************************
1913

20-
2114
# First, define some handy descriptive constants we can use
2215

23-
24-
APPVER_XP_2003 = 5.02 # Windows XP, Server 2003
25-
APPVER_VISTA = 6.0 # Windows Vista
26-
APPVER_WIN7 = 6.1 # Windows 7
16+
APPVER_VISTA = 6.0 # Windows Vista
17+
APPVER_WIN7 = 6.1 # Windows 7
2718

2819

2920
# Now use those constants to set our Windows build target.
30-
# <win32.mak> will then define _WIN32_WINNT, NTDDI_VERSION,
31-
# _WIN32_IE and WINVER on the command line (-D xxxx=nnnn)
32-
# based on our chosen APPVER value.
3321

22+
APPVER = $(APPVER_VISTA) # Minimum Windows Platform
23+
TARGETOS = WINNT # ALWAYS! (Win9x is dead!)
24+
25+
26+
#-------------------------------------------------------------
27+
28+
!IF "$(APPVER)" == "$(APPVER_VISTA)"
29+
NMAKE_WINVER = 0x0600 # (same thing as a hex value)
30+
_WIN32_IE = 0x0700 # Internet Explorer 7.0
31+
!ENDIF
32+
33+
!IF "$(APPVER)" == "$(APPVER_WIN7)"
34+
NMAKE_WINVER = 0x0601 # (same thing as a hex value)
35+
_WIN32_IE = 0x0800 # Internet Explorer 8.0
36+
!ENDIF
3437

35-
TARGETOS = WINNT # ALWAYS! (Win9x is dead!)
36-
APPVER = $(APPVER_VISTA) # Minimum Windows Platform
38+
#-------------------------------------------------------------

0 commit comments

Comments
 (0)