|
| 1 | +############################################################################### |
| 2 | +# # |
| 3 | +# File name NMakefile # |
| 4 | +# # |
| 5 | +# Description An NMake file for making ag libs, ag, and its releases # |
| 6 | +# # |
| 7 | +# Notes make.bat looks for a default nmake file called NMakeFile. # |
| 8 | +# # |
| 9 | +# History # |
| 10 | +# 2017-09-01 JFL [email protected] created this file. # |
| 11 | +# # |
| 12 | +############################################################################### |
| 13 | + |
| 14 | +default: all |
| 15 | + |
| 16 | +# This help definition overrides the second one included in All.mak below. |
| 17 | +help: |
| 18 | + type << |
| 19 | +Usage: make.bat [options] [nmake_options] [macro_definitions] [targets] ... |
| 20 | + |
| 21 | +Macro definitions: (They must be quoted, else the = sign will be lost) |
| 22 | + "DEBUG=1" Generate the debug version. <==> Target in a Debug\ dir. |
| 23 | + "OS=WIN32 WIN64" List of target OSs to build for |
| 24 | + "WINVER=5.1" Minimum target OS version. 5.1=WinXP, 6.1=Win7 |
| 25 | + |
| 26 | +Targets: |
| 27 | + all Build all available sources (default) |
| 28 | + clean Erase all output files |
| 29 | + distclean Erase all output files and all configuration files |
| 30 | + release Generate a bin/ag.zip release |
| 31 | +<< |
| 32 | + |
| 33 | +# Include common definitions |
| 34 | +!INCLUDE <All.mak> |
| 35 | + |
| 36 | +# Build just the libraries |
| 37 | +libs msc_libs: |
| 38 | + $(BMAKE) -C msc_libs $@ |
| 39 | + |
| 40 | +# Build just the executables |
| 41 | +exes src: |
| 42 | + $(BMAKE) -C src $@ |
| 43 | + |
| 44 | +# Create a binary release (bin\ag.zip) |
| 45 | +release: |
| 46 | + call <<"$(TMP)\ag-release-$(PID).bat" |
| 47 | + setlocal EnableExtensions EnableDelayedExpansion |
| 48 | + |
| 49 | + :# Prepare running 7-zip |
| 50 | + if not defined ProgramFiles set "ProgramFiles=C:\Program Files" |
| 51 | + if not exist "%ProgramFiles%\7-zip\7z.exe" ( |
| 52 | + $(MSG) Error: This requires installing 7-zip |
| 53 | + exit /b 1 |
| 54 | + ) |
| 55 | + set PATH=%PATH%;%ProgramFiles%\7-zip |
| 56 | + set "7ZIP=call :7zip" |
| 57 | + goto :start |
| 58 | + |
| 59 | + :# Subroutine that runs 7zip, and abort the script in case of a zipping error |
| 60 | + :7zip |
| 61 | + "%ProgramFiles%\7-zip\7z.exe" %* |
| 62 | + if errorlevel 1 exit 1 |
| 63 | + exit /b 0 |
| 64 | + |
| 65 | + :# Recreate the zip from scratch |
| 66 | + :start |
| 67 | + cd bin |
| 68 | + set "ZIP=!CD!\ag.zip" &:# Output file name |
| 69 | + $(MSG) Creating !ZIP! ... |
| 70 | + if exist "!ZIP!" del "!ZIP!" |
| 71 | + |
| 72 | + :# Add the various versions of ag.exe |
| 73 | + for %%d in (DOS WIN95 WINXP WIN32 IA64 WIN64 ARM ARM64) do ( |
| 74 | + if exist "%%d\ag.exe" ( |
| 75 | + set "AG=%%d\ag.exe" |
| 76 | + $(MSG) Adding !AG! |
| 77 | + !7ZIP! -- a "!ZIP!" "!AG!" |
| 78 | + ) |
| 79 | + ) |
| 80 | + |
| 81 | + :# Add the doc files |
| 82 | + cd .. |
| 83 | + $(MSG) Adding README |
| 84 | + type README.md | FIND "" /V > README.txt &:# Converts LF to CRLF |
| 85 | + dump README.txt | head -10 |
| 86 | + !7ZIP! -- a "!ZIP!" README.txt |
| 87 | + del README.txt |
| 88 | + $(MSG) Adding LICENSE |
| 89 | + type LICENSE | FIND "" /V > LICENSE.txt &:# Converts LF to CRLF |
| 90 | + dump LICENSE.txt | head -10 |
| 91 | + !7ZIP! -- a "!ZIP!" LICENSE.txt |
| 92 | + del LICENSE.txt |
| 93 | + |
| 94 | + $(MSG) ... done |
| 95 | +<< |
| 96 | + |
0 commit comments