Update recipes for Nmake file
parent
72ce467f23
commit
1709d5dc65
|
|
@ -1,8 +1,37 @@
|
||||||
// dump2def.cxx - Written and placed in public domain by Jeffrey Walton
|
// dump2def.cxx - Written and placed in public domain by Jeffrey Walton
|
||||||
// Create a module definitions file from a dumpbin file/
|
// Create a module definitions file from a dumpbin file.
|
||||||
// dump2def can be used to create a list of exports from
|
// dump2def can be used to create a list of exports from
|
||||||
// a static library. Then, the exports can used to build
|
// a static library. Then, the exports can used to build
|
||||||
// a dynamic link library with the same exports.
|
// a dynamic link library with the same exports.
|
||||||
|
//
|
||||||
|
// The workflow for Crypto++ is:
|
||||||
|
//
|
||||||
|
// 1. Open a Developer Prompt
|
||||||
|
// 2. CD to cryptopp/ directory
|
||||||
|
// 3. nmake /f cryptest.nmake cryptopp.dll
|
||||||
|
//
|
||||||
|
// The cryptopp.dll recipe first builds cryptlib.lib. Then it calls
|
||||||
|
// dumpbin.exe to export all symbols from cryptlib.lib and writes them
|
||||||
|
// to cryptopp.dump. The recipe then calls dump2def.exe to create a
|
||||||
|
// module definition file. Finally, the recipe builds cryptopp.dll
|
||||||
|
// using the module definition file cryptopp.def. The linker creates
|
||||||
|
// the import lib cryptopp.lib and export cryptopp.exp automatically.
|
||||||
|
//
|
||||||
|
// This is only "half the problem solved" for those who wish to use
|
||||||
|
// a DLL. The program must import the import lib cryptopp.lib. Then
|
||||||
|
// the program must ensure the library headers export the symbol or
|
||||||
|
// class with CRYPTOPP_DLL. CRYPTOPP_DLL is only present on some classes
|
||||||
|
// because the FIPS module only allowed approved algorithms like AES and
|
||||||
|
// SHA. Other classes like Base64Encoder and HexEncoder lack CRYPTOPP_DLL.
|
||||||
|
//
|
||||||
|
// CRYPTOPP_DLL simply adds declspec(dllimport) when CRYPTOPP_IMPORTS is
|
||||||
|
// defined. The limitation of requiring declspec(dllimport) is imposed by
|
||||||
|
// Microsoft. Microsoft does not allow a program to "import everything".
|
||||||
|
//
|
||||||
|
// If you would like to read more about the FIPS module and the pain it
|
||||||
|
// causes then see https://www.cryptopp.com/wiki/FIPS_DLL. In fact we
|
||||||
|
// recommend you delete the CryptDll and DllTest projects from the
|
||||||
|
// Visual Studio solution file.
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
@ -27,14 +56,14 @@ void PrintHelpAndExit(int code)
|
||||||
|
|
||||||
std::cout << " dump2def <infile> <outfile>" << std::endl;
|
std::cout << " dump2def <infile> <outfile>" << std::endl;
|
||||||
std::cout << " - Create a def file from <infile> and write it to <outfile>" << std::endl;
|
std::cout << " - Create a def file from <infile> and write it to <outfile>" << std::endl;
|
||||||
|
|
||||||
std::exit(code);
|
std::exit(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
// ******************** Handle Options ******************** //
|
// ******************** Handle Options ******************** //
|
||||||
|
|
||||||
// Convenience item
|
// Convenience item
|
||||||
std::vector<std::string> opts;
|
std::vector<std::string> opts;
|
||||||
for (size_t i=0; i<argc; ++i)
|
for (size_t i=0; i<argc; ++i)
|
||||||
|
|
@ -44,7 +73,7 @@ int main(int argc, char* argv[])
|
||||||
std::string opt = opts.size() < 3 ? "" : opts[1].substr(0,2);
|
std::string opt = opts.size() < 3 ? "" : opts[1].substr(0,2);
|
||||||
if (opt == "/h" || opt == "-h" || opt == "/?" || opt == "-?")
|
if (opt == "/h" || opt == "-h" || opt == "/?" || opt == "-?")
|
||||||
PrintHelpAndExit(0);
|
PrintHelpAndExit(0);
|
||||||
|
|
||||||
// Add <outfile> as needed
|
// Add <outfile> as needed
|
||||||
if (opts.size() == 2)
|
if (opts.size() == 2)
|
||||||
{
|
{
|
||||||
|
|
@ -52,7 +81,7 @@ int main(int argc, char* argv[])
|
||||||
std::string::size_type pos = outfile.length() < 5 ? std::string::npos : outfile.length() - 5;
|
std::string::size_type pos = outfile.length() < 5 ? std::string::npos : outfile.length() - 5;
|
||||||
if (pos == std::string::npos || outfile.substr(pos) != ".dump")
|
if (pos == std::string::npos || outfile.substr(pos) != ".dump")
|
||||||
PrintHelpAndExit(1);
|
PrintHelpAndExit(1);
|
||||||
|
|
||||||
outfile.replace(pos, 5, ".def");
|
outfile.replace(pos, 5, ".def");
|
||||||
opts.push_back(outfile);
|
opts.push_back(outfile);
|
||||||
}
|
}
|
||||||
|
|
@ -75,7 +104,7 @@ int main(int argc, char* argv[])
|
||||||
while (std::getline(infile, line))
|
while (std::getline(infile, line))
|
||||||
{
|
{
|
||||||
pos = line.find("public symbols");
|
pos = line.find("public symbols");
|
||||||
if (pos == std::string::npos) { continue; }
|
if (pos == std::string::npos) { continue; }
|
||||||
|
|
||||||
// Eat the whitespace after the table heading
|
// Eat the whitespace after the table heading
|
||||||
infile >> std::ws;
|
infile >> std::ws;
|
||||||
|
|
@ -117,7 +146,7 @@ int main(int argc, char* argv[])
|
||||||
name.erase(pos);
|
name.erase(pos);
|
||||||
|
|
||||||
outfile << "LIBRARY " << name << std::endl;
|
outfile << "LIBRARY " << name << std::endl;
|
||||||
outfile << "DESCRIPTION \"Crypto++ Library\"" << std::endl;
|
outfile << "DESCRIPTION \"Crypto++ Library\"" << std::endl;
|
||||||
outfile << "EXPORTS" << std::endl;
|
outfile << "EXPORTS" << std::endl;
|
||||||
outfile << std::endl;
|
outfile << std::endl;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -218,6 +218,26 @@ cryptest.exe: pch.pch cryptlib.lib $(TEST_OBJS)
|
||||||
cryptlib.lib: $(LIB_OBJS)
|
cryptlib.lib: $(LIB_OBJS)
|
||||||
$(AR) $(ARFLAGS) $(LIB_OBJS) /out:$@
|
$(AR) $(ARFLAGS) $(LIB_OBJS) /out:$@
|
||||||
|
|
||||||
|
#map2def source code available in TestPrograms/
|
||||||
|
# map2def.exe: map2def.obj
|
||||||
|
# $(LD) map2def.obj kernel32.lib /out:$@
|
||||||
|
|
||||||
|
#dump2def source code available in TestPrograms/
|
||||||
|
#dump2def.exe: dump2def.obj
|
||||||
|
# $(LD) dump2def.obj kernel32.lib /out:$@
|
||||||
|
|
||||||
|
cryptopp.map:
|
||||||
|
$(LD) $(LDFLAGS) /DLL /MAP /MAPINFO:EXPORTS $(LIB_OBJS) $(LDLIBS) /out:cryptopp.dll
|
||||||
|
|
||||||
|
cryptopp.dump: cryptlib.lib
|
||||||
|
dumpbin /LINKERMEMBER cryptlib.lib > cryptopp.dump
|
||||||
|
|
||||||
|
cryptopp.def: cryptlib.lib cryptopp.dump
|
||||||
|
dump2def.exe cryptopp.dump cryptopp.def
|
||||||
|
|
||||||
|
cryptopp.dll: $(LIB_OBJS) cryptopp.def
|
||||||
|
$(LD) $(LDFLAGS) /DLL /DEF:cryptopp.def /IGNORE:4102 $(LIB_OBJS) $(LDLIBS) /out:$@
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
$(RM) /F /Q pch.pch $(LIB_OBJS) pch.obj rdrand-x86.obj rdrand-x64.obj x64masm.obj x64dll.obj cryptlib.lib $(TEST_OBJS) cryptest.exe *.pdb
|
$(RM) /F /Q pch.pch $(LIB_OBJS) pch.obj rdrand-x86.obj rdrand-x64.obj x64masm.obj x64dll.obj cryptlib.lib $(TEST_OBJS) cryptest.exe *.pdb
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue