# # Standard make variables and rules for all Win32 platforms. # Win32Platform = 1 # # Define macro for path of wrapper executables # ifndef EmbeddedSystem WRAPPER_FPATH = $(BINDIR) else WRAPPER_FPATH = $(HOSTBINDIR) endif # # Standard "unix" programs. Anything here not provided by the GNU-WIN32/OpenNT/UWIN # system is likely to need a wrapper around it to perform filename translation. # ifndef OpenNTBuildTree # GNU-WIN32 wrappers XLN = -gnuwin32 # There is a sort in %System32%/sort.exe and in GNU-WIN32. The shell of # GNU-WIN32 may pick either one depending on the PATH setup of the user. # To make sure that the GNU-WIN32 version is picked up, give the pathname # of sort. SORT = /bin/sort else # OpenNT or UWIN wrappers XLN = -opennt MKDEPOPT = -opennt SORT = sort endif AR = $(BASE_OMNI_TREE)/$(WRAPPER_FPATH)/libwrapper $(XLN) CXX = $(BASE_OMNI_TREE)/$(WRAPPER_FPATH)/clwrapper $(XLN) CXXLINK = $(BASE_OMNI_TREE)/$(WRAPPER_FPATH)/linkwrapper $(XLN) CXXMAKEDEPEND = $(BASE_OMNI_TREE)/$(WRAPPER_FPATH)/omkdepend $(MKDEPOPT) -D__cplusplus -D_MSC_VER CC = $(BASE_OMNI_TREE)/$(WRAPPER_FPATH)/clwrapper $(XLN) CLINK = $(BASE_OMNI_TREE)/$(WRAPPER_FPATH)/linkwrapper $(XLN) CMAKEDEPEND = $(BASE_OMNI_TREE)/$(WRAPPER_FPATH)/omkdepend $(MKDEPOPT) -D_MSC_VER RCTOOL = rc.exe MANIFESTTOOL = true MKDIRHIER = mkdir -p INSTALL = install -c INSTLIBFLAGS = INSTEXEFLAGS = CP = cp MV = mv -f ifdef BuildDebugBinary CXXLINKOPTIONS = $(MSVC_DLL_CXXLINKDEBUGOPTIONS) CXXDEBUGFLAGS = CXXOPTIONS = $(MSVC_DLL_CXXDEBUGFLAGS) CLINKOPTIONS = $(MSVC_DLL_CLINKDEBUGOPTIONS) CDEBUGFLAGS = $(MSVC_DLL_CDEBUGFLAGS) else CXXLINKOPTIONS = $(MSVC_DLL_CXXLINKNODEBUGOPTIONS) CXXDEBUGFLAGS = -O2 CXXOPTIONS = $(MSVC_DLL_CXXNODEBUGFLAGS) CLINKOPTIONS = $(MSVC_DLL_CLINKNODEBUGOPTIONS) CDEBUGFLAGS = -O2 COPTIONS = $(MSVC_DLL_CNODEBUGFLAGS) endif ifndef WINVER WINVER = 0x0400 endif IMPORT_CPPFLAGS += -D__WIN32__ -D_WIN32_WINNT=$(WINVER) SOCKET_LIB = ws2_32.lib mswsock.lib # # General rule for cleaning. # define CleanRule $(RM) *.o *.lib endef define VeryCleanRule $(RM) *.d $(RM) *.pyc $(RM) *.def *.pdb *.ilk *.exp *.manifest *.rc *.res $(RM) $(CORBA_STUB_FILES) endef # # Patterns for various file types # LibPathPattern = -libpath:% LibNoDebugPattern = %.lib LibDebugPattern = %d.lib DLLNoDebugPattern = %_rt.lib DLLDebugPattern = %_rtd.lib LibNoDebugSearchPattern = %.lib LibDebugSearchPattern = %d.lib DLLNoDebugSearchPattern = %_rt.lib DLLDebugSearchPattern = %_rtd.lib ifndef BuildDebugBinary LibPattern = $(LibNoDebugPattern) DLLPattern = $(DLLNoDebugPattern) LibSearchPattern = $(LibNoDebugSearchPattern) DLLSearchPattern = $(DLLNoDebugSearchPattern) else LibPattern = $(LibDebugPattern) DLLPattern = $(DLLDebugPattern) LibSearchPattern = $(LibDebugSearchPattern) DLLSearchPattern = $(DLLDebugSearchPattern) endif BinPattern = %.exe # # Stuff to generate statically-linked libraries. # define StaticLinkLibrary (set -x; \ $(RM) $@; \ $(AR) $@ $^; \ ) endef ifdef EXPORT_TREE define ExportLibrary (dir="$(EXPORT_TREE)/$(LIBDIR)"; \ files="$^"; \ for file in $$files; do \ $(ExportFileToDir); \ done; \ ) endef endif # # Stuff to generate executable binaries. # IMPORT_LIBRARY_FLAGS = $(patsubst %,$(LibPathPattern),$(IMPORT_LIBRARY_DIRS)) define CXXExecutable (set -x; \ $(RM) $@; \ $(CXXLINK) -out:$@ $(CXXLINKOPTIONS) -PDB:$@.pdb $(IMPORT_LIBRARY_FLAGS) \ $(filter-out $(LibPattern),$^) $$libs; \ $(MANIFESTTOOL) /outputresource:"$@;#2" /manifest $@.manifest; \ ) endef define CExecutable (set -x; \ $(RM) $@; \ $(CLINK) -out:$@ $(CLINKOPTIONS) -PDB:$@.pdb $(IMPORT_LIBRARY_FLAGS) $(filter-out $(LibPattern),$^) $$libs; \ $(MANIFESTTOOL) /outputresource:"$@;#2" /manifest $@.manifest; \ ) endef ifdef EXPORT_TREE define ExportExecutable (dir="$(EXPORT_TREE)/$(BINDIR)"; \ files="$^"; \ for file in $$files; do \ $(ExportExecutableFileToDir); \ done; \ ) endef endif ########################################################################### # # Shared library support stuff # ifndef EmbeddedSystem BuildSharedLibrary = 1 endif SharedLibraryFullNameTemplate = $(SharedLibraryLibNameTemplate).lib SharedLibraryLibNameTemplate = $$1$$2$$3$$4_rt$${extrasuffix:-} SharedLibraryShortLibName = $$1$$2_rt$${extrasuffix:-}.lib SharedLibraryDllNameTemplate = $$1$$2$$3$$4$(compiler_version_suffix)_rt$${extrasuffix:-} SharedLibraryExportSymbolFileNameTemplate = $$1$$2$${extrasuffix:-}.def SharedLibraryVersionStringTemplate = $$3.$$4 SharedLibrarySymbolRefLibraryTemplate = $${symrefdir:-static}/$$1$$2$${extrasuffix:-}.lib define SharedLibraryFullName fn() { \ if [ $$2 = "_" ] ; then set $$1 "" $$3 $$4 ; fi ; \ echo $(SharedLibraryFullNameTemplate); \ }; fn endef define SharedLibraryDebugFullName fn() { \ if [ $$2 = "_" ] ; then set $$1 "" $$3 $$4 ; fi ; \ extrasuffix="d"; \ echo $(SharedLibraryFullNameTemplate); \ }; fn endef define ParseNameSpec set $$namespec ; \ if [ $$2 = "_" ] ; then set $$1 "" $$3 $$4 ; fi endef # MakeCXXExportSymbolDefinitionFile # Internal canned command used by MakeCXXSharedLibrary # # - Create a .def file containing all the functions and static class # variables exported by the DLL. The symbols are extracted from the # output of dumpbin. # # The function symbols are extracted using the following template: # ... ........ SECT.. notype () External | ?.................. # # The static class variable symbols are extracted using the following # template: # ... ........ SECT.. notype External | ?[^?].............. # # Default destructors generated by the compiler and the symbols # inside an anonymous namespace are excluded. # # It looks like class variable and function symbols start with two ?? # and class static variable and static function symbols start with one ?. # - SLL # define MakeCXXExportSymbolDefinitionFile symrefdir=$${debug:+debug}; \ symreflib=$(SharedLibrarySymbolRefLibraryTemplate); \ if [ ! -f $$symreflib ]; then echo "Cannot find reference static library $$symreflib"; return 1; fi; \ set -x; \ echo "LIBRARY $$dllbase" > $$defname; \ echo "VERSION $$version" >> $$defname; \ echo "EXPORTS" >> $$defname; \ DUMPBIN.EXE /SYMBOLS $$symreflib | \ egrep '^[^ ]+ +[^ ]+ +SECT[^ ]+ +[^ ]+ +\(\) +External +\| +\?[^ ]*|^[^ ]+ +[^ ]+ +SECT[^ ]+ +[^ ]+ +External +\| +\?[^?][^ ]*'|\ egrep -v 'deleting destructor[^(]+\(unsigned int\)' | \ egrep -v 'anonymous namespace' | \ cut -d'|' -f2 | \ cut -d' ' -f2 | $(SORT) -u >> $$defname; \ set +x; endef # MakeResourceDefinitionFile # Internal canned command used by MakeCXXSharedLibrary define MakeResourceDefinitionFile if [ -n "$$2" ]; then \ commaver=$$2,$$3,$$4,0x$$nanovers; \ dotver=$$2.$$3.$$4.$$nanovers; \ else \ commaver=$$3,$$4,0x$$nanovers,0; \ dotver=$$3.$$4.$$nanovers; \ fi; \ set -x; \ echo "#include \"afxres.h\"" > $$rcname; \ echo "VS_VERSION_INFO VERSIONINFO" >> $$rcname; \ echo " FILEVERSION $$commaver" >> $$rcname; \ echo " PRODUCTVERSION $(OMNIORB_MAJOR_VERSION),$(OMNIORB_MINOR_VERSION),$(OMNIORB_MICRO_VERSION),0x$$nanovers" >> $$rcname; \ echo " FILEFLAGSMASK 0x3fL" >> $$rcname; \ if [ -n "$$debug" ]; then \ echo " FILEFLAGS VS_FF_DEBUG" >> $$rcname; \ else \ echo " FILEFLAGS 0x0L" >> $$rcname; \ fi; \ echo " FILEOS VOS_UNKNOWN" >> $$rcname; \ echo " FILETYPE VFT_UNKNOWN" >> $$rcname; \ echo " FILESUBTYPE 0x0L" >> $$rcname; \ echo "{ " >> $$rcname; \ echo " BLOCK \"StringFileInfo\"" >> $$rcname; \ echo " {" >> $$rcname; \ echo " BLOCK \"00000000\"" >> $$rcname; \ echo " {" >> $$rcname; \ echo " VALUE \"CompanyName\", \"omniORB open source project\0\"" >> $$rcname; \ echo " VALUE \"FileDescription\", \"omniORB\0\"" >> $$rcname; \ echo " VALUE \"FileVersion\", \"$$dotver\0\"" >> $$rcname; \ echo " VALUE \"InternalName\", \"$(SharedLibraryDllNameTemplate).dll\0\"" >> $$rcname; \ echo " VALUE \"OriginalFilename\", \"$(SharedLibraryDllNameTemplate).dll\0\"" >> $$rcname; \ echo " VALUE \"ProductName\", \"omniORB\"" >> $$rcname; \ echo " VALUE \"ProductVersion\", \"$(OMNIORB_MAJOR_VERSION).$(OMNIORB_MINOR_VERSION).$(OMNIORB_MICRO_VERSION).$$nanovers\0\"" >> $$rcname; \ echo " VALUE \"LegalCopyright\", \"Apasphere Ltd., AT&T Laboratories Cambridge, and others. Freely available under the terms of the GNU LGPL.\0\"" >> $$rcname; \ echo " }" >> $$rcname; \ echo " }" >> $$rcname; \ echo " BLOCK \"VarFileInfo\"" >> $$rcname; \ echo " {" >> $$rcname; \ echo " VALUE \"Translation\", 0x0, 0" >> $$rcname; \ echo " }" >> $$rcname; \ echo "}" >> $$rcname; \ echo "LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL" >> $$rcname; \ $(RCTOOL) $$rcname; endef # MakeCXXSharedLibrary- Build shared library # Expect shell variable: # namespec = # extralibs = # debug = 1 (build debug version). # # e.g. namespec="COS 3 0 0" --> COS300_rt.dll # extralibs="$(OMNIORB_LIB)" # define MakeCXXSharedLibrary $(ParseNameSpec); \ extrasuffix=$${debug:+d}; \ targetdir=$(@D); \ libname=$(SharedLibraryLibNameTemplate); \ slibname=$(SharedLibraryShortLibName); \ dllbase=$$targetdir/$(SharedLibraryDllNameTemplate); \ dllname=$$dllbase.dll; \ rcname=$$dllbase.rc; \ resname=$$targetdir/$(SharedLibraryDllNameTemplate).res; \ defname=$$targetdir/$(SharedLibraryExportSymbolFileNameTemplate); \ version=$(SharedLibraryVersionStringTemplate); \ nanovers=`echo $(OMNIORB_VERSION_HEX) | cut -c 9-`; \ if [ -n "$$debug" ]; then \ extralinkoption="$(MSVC_DLL_CXXLINKDEBUGOPTIONS)"; \ else \ extralinkoption="$(MSVC_DLL_CXXLINKNODEBUGOPTIONS)"; \ fi; \ if [ -z "$$nodeffile" ]; then \ $(MakeCXXExportSymbolDefinitionFile) \ defflag="-def:$$defname"; \ fi; \ $(MakeResourceDefinitionFile) \ set -x; \ $(RM) $@; \ $(CXXLINK) -out:$$dllname -DLL $$extralinkoption \ $$defflag -IMPLIB:$@ $(IMPORT_LIBRARY_FLAGS) \ $^ $$extralibs $$resname; \ $(CP) $@ $$slibname; endef # Export SharedLibrary # Expected shell variable: # namespec = # e.g. namespec = "COS 3 0 0" # # NT treats DLLs more like executables -- the .dll file needs to go in the # bin/x86... directory so that it's on your PATH: # define ExportSharedLibrary $(ParseNameSpec); \ extrasuffix=$${debug:+d}; \ targetdir=$(