Skip to content

Commit eb152fd

Browse files
fanc999-1kjellahl
authored andcommitted
Add NMake Makefiles
This adds a set of NMake Makefiles that can be used to build libxml++, which will replace the Visual Studio 2010(!) projects that reside in the repository. To be consistent with the rest of the -mm stack that we build with Visual Studio, we will need to separate the output filenames for the resulting .lib and .dll files for Visual Studio 2017 and 2019. A NMake Makefile build option "USE_COMPAT_LIBS" is added if building 'xml++-vc150-x_y.[dll|lib] is still desired. Note that this branch does not rely on glibmm nor libsigc++, so linking against libxml2 built with an older Visual Studio version should work properly, if libxml2 is built with Visual Studio 2015 or later, but again, we are enforcing the Visual Studio toolset versioning policy by default for consistency's sake.
1 parent de6e815 commit eb152fd

File tree

10 files changed

+613
-1
lines changed

10 files changed

+613
-1
lines changed

MSVC_NMake/Makefile.vc

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# NMake Makefile for building libxml++ on Windows using Visual Studio
2+
3+
# The items below this line should not be changed, unless one is maintaining
4+
# the NMake Makefiles. Customizations can be done in the following NMake Makefile
5+
# portions (please see comments in the these files to see what can be customized):
6+
#
7+
# detectenv-msvc.mak
8+
# config-msvc.mak
9+
10+
!include detectenv-msvc.mak
11+
12+
# Include the Makefile portions with the source listings
13+
!include ..\libxml++\filelist.am
14+
15+
# Include the Makefile portion that enables features based on user input
16+
!include config-msvc.mak
17+
18+
!if "$(VALID_CFGSET)" == "TRUE"
19+
20+
# We need Visual Studio 2015 or later
21+
!if $(VSVER) < 14
22+
VALID_MSC = FALSE
23+
!else
24+
VALID_MSC = TRUE
25+
!endif
26+
27+
!if "$(VALID_MSC)" == "TRUE"
28+
29+
all: $(LIBXMLXX_LIB) libxmlxx_examples all-build-info
30+
31+
# Include the Makefile portion to convert the source and header lists
32+
# into the lists we need for compilation
33+
!include create-lists-msvc.mak
34+
35+
!ifdef GENERATE_VERSIONED_FILES
36+
!include pkg-ver.mak
37+
!endif
38+
39+
tests: $(libxmlxx_tests) all-build-info
40+
41+
libxmlxx_examples: $(libxmlxx_examples)
42+
43+
# Include the build rules for sources, DLLs and executables
44+
!include generate-msvc.mak
45+
!include build-rules-msvc.mak
46+
47+
!include install.mak
48+
49+
!else # "$(VALID_MSC)" == "TRUE"
50+
all:
51+
@echo You need Visual Studio 2015 or later.
52+
53+
!endif # "$(VALID_MSC)" == "TRUE"
54+
55+
!else # "$(VALID_CFGSET)" == "TRUE"
56+
all: help
57+
@echo You need to specify a valid configuration, via
58+
@echo CFG=release or CFG=debug
59+
!endif # "$(VALID_CFGSET)" == "TRUE"
60+
61+
!include info-msvc.mak

MSVC_NMake/build-rules-msvc.mak

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
# NMake Makefile portion for compilation rules
2+
# Items in here should not need to be edited unless
3+
# one is maintaining the NMake build files. The format
4+
# of NMake Makefiles here are different from the GNU
5+
# Makefiles. Please see the comments about these formats.
6+
7+
# Inference rules for compiling the .obj files.
8+
# Used for libs and programs with more than a single source file.
9+
# Format is as follows
10+
# (all dirs must have a trailing '\'):
11+
#
12+
# {$(srcdir)}.$(srcext){$(destdir)}.obj::
13+
# $(CC)|$(CXX) $(cflags) /Fo$(destdir) /c @<<
14+
# $<
15+
# <<
16+
17+
{..\libxml++\}.cc{vs$(VSVER)\$(CFG)\$(PLAT)\libxmlxx\}.obj::
18+
@if not exist vs$(VSVER)\$(CFG)\$(PLAT)\libxmlxx\ md vs$(VSVER)\$(CFG)\$(PLAT)\libxmlxx
19+
$(CXX) $(LIBXMLXX_CFLAGS) $(CFLAGS_NOGL) /Fovs$(VSVER)\$(CFG)\$(PLAT)\libxmlxx\ /Fdvs$(VSVER)\$(CFG)\$(PLAT)\libxmlxx\ /c @<<
20+
$<
21+
<<
22+
23+
{..\libxml++\exceptions\}.cc{vs$(VSVER)\$(CFG)\$(PLAT)\libxmlxx\}.obj::
24+
@if not exist vs$(VSVER)\$(CFG)\$(PLAT)\libxmlxx\ md vs$(VSVER)\$(CFG)\$(PLAT)\libxmlxx
25+
$(CXX) $(LIBXMLXX_CFLAGS) $(CFLAGS_NOGL) /Fovs$(VSVER)\$(CFG)\$(PLAT)\libxmlxx\ /Fdvs$(VSVER)\$(CFG)\$(PLAT)\libxmlxx\ /c @<<
26+
$<
27+
<<
28+
29+
{..\libxml++\io\}.cc{vs$(VSVER)\$(CFG)\$(PLAT)\libxmlxx\}.obj::
30+
@if not exist vs$(VSVER)\$(CFG)\$(PLAT)\libxmlxx\ md vs$(VSVER)\$(CFG)\$(PLAT)\libxmlxx
31+
$(CXX) $(LIBXMLXX_CFLAGS) $(CFLAGS_NOGL) /Fovs$(VSVER)\$(CFG)\$(PLAT)\libxmlxx\ /Fdvs$(VSVER)\$(CFG)\$(PLAT)\libxmlxx\ /c @<<
32+
$<
33+
<<
34+
35+
{..\libxml++\nodes\}.cc{vs$(VSVER)\$(CFG)\$(PLAT)\libxmlxx\}.obj::
36+
@if not exist vs$(VSVER)\$(CFG)\$(PLAT)\libxmlxx\ md vs$(VSVER)\$(CFG)\$(PLAT)\libxmlxx
37+
$(CXX) $(LIBXMLXX_CFLAGS) $(CFLAGS_NOGL) /Fovs$(VSVER)\$(CFG)\$(PLAT)\libxmlxx\ /Fdvs$(VSVER)\$(CFG)\$(PLAT)\libxmlxx\ /c @<<
38+
$<
39+
<<
40+
41+
{..\libxml++\parsers\}.cc{vs$(VSVER)\$(CFG)\$(PLAT)\libxmlxx\}.obj::
42+
@if not exist vs$(VSVER)\$(CFG)\$(PLAT)\libxmlxx\ md vs$(VSVER)\$(CFG)\$(PLAT)\libxmlxx
43+
$(CXX) $(LIBXMLXX_CFLAGS) $(CFLAGS_NOGL) /Fovs$(VSVER)\$(CFG)\$(PLAT)\libxmlxx\ /Fdvs$(VSVER)\$(CFG)\$(PLAT)\libxmlxx\ /c @<<
44+
$<
45+
<<
46+
47+
{..\libxml++\validators\}.cc{vs$(VSVER)\$(CFG)\$(PLAT)\libxmlxx\}.obj::
48+
@if not exist vs$(VSVER)\$(CFG)\$(PLAT)\libxmlxx\ md vs$(VSVER)\$(CFG)\$(PLAT)\libxmlxx
49+
$(CXX) $(LIBXMLXX_CFLAGS) $(CFLAGS_NOGL) /Fovs$(VSVER)\$(CFG)\$(PLAT)\libxmlxx\ /Fdvs$(VSVER)\$(CFG)\$(PLAT)\libxmlxx\ /c @<<
50+
$<
51+
<<
52+
53+
{.\libxml++\}.rc{vs$(VSVER)\$(CFG)\$(PLAT)\libxmlxx\}.res:
54+
@if not exist $(@D)\ md $(@D)
55+
rc /fo$@ $<
56+
57+
# Rules for building .lib files
58+
$(LIBXMLXX_LIB): $(LIBXMLXX_DLL)
59+
60+
# Rules for linking DLLs
61+
# Format is as follows (the mt command is needed for MSVC 2005/2008 builds):
62+
# $(dll_name_with_path): $(dependent_libs_files_objects_and_items)
63+
# link /DLL [$(linker_flags)] [$(dependent_libs)] [/def:$(def_file_if_used)] [/implib:$(lib_name_if_needed)] -out:$@ @<<
64+
# $(dependent_objects)
65+
# <<
66+
# @-if exist $@.manifest mt /manifest $@.manifest /outputresource:$@;2
67+
$(LIBXMLXX_DLL): $(libxmlxx_OBJS) vs$(VSVER)\$(CFG)\$(PLAT)\libxmlxx\libxml++.def
68+
link /DLL $(LDFLAGS_NOLTCG) $(LIBXML2_LIBS) /implib:$(LIBXMLXX_LIB) /def:vs$(VSVER)\$(CFG)\$(PLAT)\libxmlxx\libxml++.def -out:$@ @<<
69+
$(libxmlxx_OBJS)
70+
<<
71+
@-if exist $@.manifest mt /manifest $@.manifest /outputresource:$@;2
72+
73+
# Rules for linking Executables
74+
# Format is as follows (the mt command is needed for MSVC 2005/2008 builds):
75+
# $(dll_name_with_path): $(dependent_libs_files_objects_and_items)
76+
# link [$(linker_flags)] [$(dependent_libs)] -out:$@ @<<
77+
# $(dependent_objects)
78+
# <<
79+
# @-if exist $@.manifest mt /manifest $@.manifest /outputresource:$@;1
80+
$(GENDEF): gendef\gendef.cc
81+
@if not exist $(@D)\gendef\ md $(@D)\gendef
82+
$(CXX) $(CFLAGS) /Fo$(@D)\gendef\ /Fd$(@D)\gendef\ $** /Fe:$@ /link $(LDFLAGS) -out:$@
83+
@-if exist $@.manifest mt /manifest $@.manifest /outputresource:$@;1
84+
85+
clean:
86+
@-del /f /q vs$(VSVER)\$(CFG)\$(PLAT)\*.exe
87+
@-del /f /q vs$(VSVER)\$(CFG)\$(PLAT)\*.dll
88+
@-del /f /q vs$(VSVER)\$(CFG)\$(PLAT)\*.pdb
89+
@-del /f /q vs$(VSVER)\$(CFG)\$(PLAT)\*.ilk
90+
@-del /f /q vs$(VSVER)\$(CFG)\$(PLAT)\*.exp
91+
@-del /f /q vs$(VSVER)\$(CFG)\$(PLAT)\*.lib
92+
@-del /f /q vs$(VSVER)\$(CFG)\$(PLAT)\libxmlxx-tests\*.obj
93+
@-del /f /q vs$(VSVER)\$(CFG)\$(PLAT)\libxmlxx-tests\*.pdb
94+
@-del /f /q vs$(VSVER)\$(CFG)\$(PLAT)\libxmlxx-examples\*.obj
95+
@-del /f /q vs$(VSVER)\$(CFG)\$(PLAT)\libxmlxx-examples\*.pdb
96+
@-del /f /q vs$(VSVER)\$(CFG)\$(PLAT)\libxmlxx\*.def
97+
@-del /f /q vs$(VSVER)\$(CFG)\$(PLAT)\libxmlxx\*.res
98+
@-del /f /q vs$(VSVER)\$(CFG)\$(PLAT)\libxmlxx\*.obj
99+
@-del /f /q vs$(VSVER)\$(CFG)\$(PLAT)\libxmlxx\*.pdb
100+
@-del /f /q vs$(VSVER)\$(CFG)\$(PLAT)\gendef\*.obj
101+
@-del /f /q vs$(VSVER)\$(CFG)\$(PLAT)\gendef\*.pdb
102+
@-rd vs$(VSVER)\$(CFG)\$(PLAT)\libxmlxx-tests
103+
@-rd vs$(VSVER)\$(CFG)\$(PLAT)\libxmlxx-examples
104+
@-rd vs$(VSVER)\$(CFG)\$(PLAT)\libxmlxx
105+
@-rd vs$(VSVER)\$(CFG)\$(PLAT)\gendef

MSVC_NMake/config-msvc.mak

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# NMake Makefile portion for enabling features for Windows builds
2+
3+
# These are the base minimum libraries required for building glibmm.
4+
BASE_INCLUDES = /I$(PREFIX)\include
5+
6+
# Please do not change anything beneath this line unless maintaining the NMake Makefiles
7+
LIBXMLXX_MAJOR_VERSION = 5
8+
LIBXMLXX_MINOR_VERSION = 0
9+
10+
!if "$(CFG)" == "debug" || "$(CFG)" == "Debug"
11+
DEBUG_SUFFIX = -d
12+
!else
13+
DEBUG_SUFFIX =
14+
!endif
15+
16+
LIBXMLXX_BASE_CFLAGS = \
17+
/I.\libxml++ /I.. \
18+
/wd4530 /wd4251 /wd4275 /EHsc \
19+
/FImsvc_recommended_pragmas.h \
20+
/std:c++17
21+
22+
LIBXMLXX_EXTRA_INCLUDES = /I$(PREFIX)\include\libxml2
23+
24+
LIBXMLXX_CFLAGS = /DLIBXMLPP_BUILD $(LIBXMLXX_BASE_CFLAGS) $(LIBXMLXX_EXTRA_INCLUDES)
25+
LIBXMLXX_EX_CFLAGS = $(LIBXMLXX_BASE_CFLAGS) $(LIBXMLXX_EXTRA_INCLUDES)
26+
27+
# We build xml++-vc$(VSVER_LIB)-$(LIBXMLXX_MAJOR_VERSION)_$(LIBXMLXX_MINOR_VERSION).dll or
28+
# xml++-vc$(VSVER_LIB)-d-$(LIBXMLXX_MAJOR_VERSION)_$(LIBXMLXX_MINOR_VERSION).dll at least
29+
30+
LIBXMLXX_DLL = vs$(VSVER)\$(CFG)\$(PLAT)\xml++-vc$(VSVER_LIB)$(DEBUG_SUFFIX)-$(LIBXMLXX_MAJOR_VERSION)_$(LIBXMLXX_MINOR_VERSION).dll
31+
LIBXMLXX_LIB = vs$(VSVER)\$(CFG)\$(PLAT)\xml++-vc$(VSVER_LIB)$(DEBUG_SUFFIX)-$(LIBXMLXX_MAJOR_VERSION)_$(LIBXMLXX_MINOR_VERSION).lib
32+
GENDEF = vs$(VSVER)\$(CFG)\$(PLAT)\gendef.exe
33+
34+
LIBXML2_LIBS = libxml2.lib

MSVC_NMake/create-lists-msvc.mak

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# Convert the source listing to object (.obj) listing in
2+
# another NMake Makefile module, include it, and clean it up.
3+
# This is a "fact-of-life" regarding NMake Makefiles...
4+
# This file does not need to be changed unless one is maintaining the NMake Makefiles
5+
6+
# For those wanting to add things here:
7+
# To add a list, do the following:
8+
# # $(description_of_list)
9+
# if [call create-lists.bat header $(makefile_snippet_file) $(variable_name)]
10+
# endif
11+
#
12+
# if [call create-lists.bat file $(makefile_snippet_file) $(file_name)]
13+
# endif
14+
#
15+
# if [call create-lists.bat footer $(makefile_snippet_file)]
16+
# endif
17+
# ... (repeat the if [call ...] lines in the above order if needed)
18+
# !include $(makefile_snippet_file)
19+
#
20+
# (add the following after checking the entries in $(makefile_snippet_file) is correct)
21+
# (the batch script appends to $(makefile_snippet_file), you will need to clear the file unless the following line is added)
22+
#!if [del /f /q $(makefile_snippet_file)]
23+
#!endif
24+
25+
# In order to obtain the .obj filename that is needed for NMake Makefiles to build DLLs/static LIBs or EXEs, do the following
26+
# instead when doing 'if [call create-lists.bat file $(makefile_snippet_file) $(file_name)]'
27+
# (repeat if there are multiple $(srcext)'s in $(source_list), ignore any headers):
28+
# !if [for %c in ($(source_list)) do @if "%~xc" == ".$(srcext)" @call create-lists.bat file $(makefile_snippet_file) $(intdir)\%~nc.obj]
29+
#
30+
# $(intdir)\%~nc.obj needs to correspond to the rules added in build-rules-msvc.mak
31+
# %~xc gives the file extension of a given file, %c in this case, so if %c is a.cc, %~xc means .cc
32+
# %~nc gives the file name of a given file without extension, %c in this case, so if %c is a.cc, %~nc means a
33+
34+
NULL=
35+
36+
# For libxml++
37+
38+
!if [call create-lists.bat header libxmlxx.mak libxmlxx_OBJS]
39+
!endif
40+
41+
!if [for %c in ($(cc_sources)) do @if "%~xc" == ".cc" @call create-lists.bat file libxmlxx.mak vs^$(VSVER)\^$(CFG)\^$(PLAT)\libxmlxx\%~nc.obj]
42+
!endif
43+
44+
!if [@call create-lists.bat file libxmlxx.mak vs^$(VSVER)\^$(CFG)\^$(PLAT)\libxmlxx\libxml++.res]
45+
!endif
46+
47+
!if [call create-lists.bat footer libxmlxx.mak]
48+
!endif
49+
50+
!if [call create-lists.bat header libxmlxx.mak libxmlxx_real_hdrs]
51+
!endif
52+
53+
!if [for %c in ($(h_sources_public:/=\)) do @call create-lists.bat file libxmlxx.mak ..\libxml++\%c]
54+
!endif
55+
56+
!if [call create-lists.bat footer libxmlxx.mak]
57+
!endif
58+
59+
!if [for %d in (examples tests) do @call create-lists.bat header libxmlxx.mak libxmlxx_%d & @(for /f %t in ('dir /ad /b ..\%d') do @call create-lists.bat file libxmlxx.mak vs$(VSVER)\$(CFG)\$(PLAT)\%t.exe) & @call create-lists.bat footer libxmlxx.mak]
60+
!endif
61+
62+
!if [for %d in (examples tests) do @for /f %t in ('dir /ad /b ..\%d') do @call create-lists.bat header libxmlxx.mak %t_OBJS & @(for %s in (..\%d\%t\*.cc) do @call create-lists.bat file libxmlxx.mak vs$(VSVER)\$(CFG)\$(PLAT)\libxmlxx-%d\%t-%~ns.obj) & @call create-lists.bat footer libxmlxx.mak]
63+
!endif
64+
65+
!if [echo.>>libxmlxx.mak]
66+
!endif
67+
68+
!if [for %d in (examples tests) do @for /f %t in ('dir /ad /b ..\%d') do @for %s in (..\%d\%t\*.cc) do @echo vs^$(VSVER)\^$(CFG)\^$(PLAT)\libxmlxx-%d\%t-%~ns.obj: %s>>libxmlxx.mak & @echo. if not exist ^$(@D)\ md ^$(@D)>>libxmlxx.mak & @echo. ^$(CXX) ^$(LIBXMLXX_EX_CFLAGS) ^$(CFLAGS) /Fo^$(@D)\%t-%~ns.obj /Fd^$(@D)\ ^$** /c>>libxmlxx.mak & @echo.>>libxmlxx.mak]
69+
!endif
70+
71+
!if [for %d in (examples tests) do @for /f %t in ('dir /ad /b ..\%d') do @echo vs^$(VSVER)\^$(CFG)\^$(PLAT)\%t.exe: ^$(LIBXMLXX_LIB) ^$(%t_OBJS)>>libxmlxx.mak & @echo. link ^$(LDFLAGS) ^$** ^$(LIBXML2_LIBS) /out:^$@>>libxmlxx.mak & @echo.>>libxmlxx.mak]
72+
!endif
73+
74+
!if [echo.>>libxmlxx.mak]
75+
!endif
76+
77+
!include libxmlxx.mak
78+
79+
!if [del /f /q libxmlxx.mak]
80+
!endif

MSVC_NMake/create-lists.bat

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
@echo off
2+
rem Simple .bat script for creating the NMake Makefile snippets.
3+
4+
if not "%1" == "header" if not "%1" == "file" if not "%1" == "footer" goto :error_cmd
5+
if "%2" == "" goto error_no_destfile
6+
7+
if "%1" == "header" goto :header
8+
if "%1" == "file" goto :addfile
9+
if "%1" == "footer" goto :footer
10+
11+
:header
12+
if "%3" == "" goto error_var
13+
echo %3 = \>>%2
14+
goto done
15+
16+
:addfile
17+
if "%3" == "" goto error_file
18+
echo. %3 \>>%2
19+
goto done
20+
21+
:footer
22+
echo. $(NULL)>>%2
23+
echo.>>%2
24+
goto done
25+
26+
:error_cmd
27+
echo Specified command '%1' was invalid. Valid commands are: header file footer.
28+
goto done
29+
30+
:error_no_destfile
31+
echo Destination NMake snippet file must be specified
32+
goto done
33+
34+
:error_var
35+
echo A name must be specified for using '%1'.
36+
goto done
37+
38+
:error_file
39+
echo A file must be specified for using '%1'.
40+
goto done
41+
42+
:done

0 commit comments

Comments
 (0)