Skip to content

Commit 62eb2f9

Browse files
fanc999-1kjellahl
authored andcommitted
builds: Add NMake Makefiles
This adds a set of NMake Makefiles that can be used to build libsigc++-2.10.x (and the later C++11 versions of libsigc++) with Visual Studio 2013 or later. Building the example, the tests and the benchmarking programs are supported in addition to building the main libsigc++ DLL. Note that for the C++-11 releases, we name the DLLs and LIBs as sigc-vc140-2_0.[dll|lib] or sigc-vc140-d-2_0.[dll|lib] for Visual Studio 2015 and 2017 builds as these builds link to the msvcp140[d].dll and vcruntime140[d].dll C/C++ runtime DLLs. This set of NMake Makefiles are now dist'ed in place of the Visual Studio 2013 project files.
1 parent 371963b commit 62eb2f9

11 files changed

+533
-69
lines changed

MSVC_NMake/Makefile.vc

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# NMake Makefile for building libsigc++ 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 ..\sigc++\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 2013 or later
21+
!if $(VSVER) < 12
22+
VALID_MSC = FALSE
23+
!else
24+
VALID_MSC = TRUE
25+
!endif
26+
27+
!if "$(VALID_MSC)" == "TRUE"
28+
29+
# Include the Makefile portion to convert the source and header lists
30+
# into the lists we need for compilation and introspection
31+
!include create-lists-msvc.mak
32+
33+
all: $(LIBSIGC_LIB) $(libsigc_ex) all-build-info
34+
35+
tests: $(libsigc_tests) all-build-info
36+
37+
benchmark: all $(libsigc_bench) all-build-info
38+
39+
# Include the build rules for sources, DLLs and executables
40+
!include generate-msvc.mak
41+
!include build-rules-msvc.mak
42+
43+
!include install.mak
44+
45+
!else # "$(VALID_MSC)" == "TRUE"
46+
all:
47+
@echo You need Visual Studio 2013 or later.
48+
49+
!endif # "$(VALID_MSC)" == "TRUE"
50+
51+
!else # "$(VALID_CFGSET)" == "TRUE"
52+
all: help
53+
@echo You need to specify a valid configuration, via
54+
@echo CFG=release or CFG=debug
55+
!endif # "$(VALID_CFGSET)" == "TRUE"
56+
57+
!include info-msvc.mak

MSVC_NMake/build-rules-msvc.mak

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
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+
{..\sigc++\}.cc{$(CFG)\$(PLAT)\libsigcpp\}.obj::
17+
$(CXX) $(LIBSIGCPP_CFLAGS) /Fo$(CFG)\$(PLAT)\libsigcpp\ /c @<<
18+
$<
19+
<<
20+
21+
{..\sigc++\adaptors\lambda\}.cc{$(CFG)\$(PLAT)\libsigcpp\}.obj::
22+
$(CXX) $(LIBSIGCPP_CFLAGS) /Fo$(CFG)\$(PLAT)\libsigcpp\ /c @<<
23+
$<
24+
<<
25+
26+
{..\sigc++\functors\}.cc{$(CFG)\$(PLAT)\libsigcpp\}.obj::
27+
$(CXX) $(LIBSIGCPP_CFLAGS) /Fo$(CFG)\$(PLAT)\libsigcpp\ /c @<<
28+
$<
29+
<<
30+
31+
$(CFG)\$(PLAT)\libsigcpp-tests\testutilities.obj: $(CFG)\$(PLAT)\libsigcpp-tests ..\tests\testutilities.cc
32+
$(CXX) $(SIGCPP_CFLAGS) /Fo$@ /c ..\tests\testutilities.cc
33+
# Rules for building .lib files
34+
$(LIBSIGC_LIB): $(LIBSIGC_DLL)
35+
36+
{.}.rc{$(CFG)\$(PLAT)\libsigcpp\}.res:
37+
rc /fo$@ $<
38+
39+
# Rules for linking DLLs
40+
# Format is as follows (the mt command is needed for MSVC 2005/2008 builds):
41+
# $(dll_name_with_path): $(dependent_libs_files_objects_and_items)
42+
# link /DLL [$(linker_flags)] [$(dependent_libs)] [/def:$(def_file_if_used)] [/implib:$(lib_name_if_needed)] -out:$@ @<<
43+
# $(dependent_objects)
44+
# <<
45+
# @-if exist $@.manifest mt /manifest $@.manifest /outputresource:$@;2
46+
$(LIBSIGC_DLL): $(CFG)\$(PLAT)\libsigcpp $(libsigcpp_dll_OBJS)
47+
link /DLL $(LDFLAGS) /implib:$(LIBSIGC_LIB) -out:$@ @<<
48+
$(libsigcpp_dll_OBJS)
49+
<<
50+
@-if exist $@.manifest mt /manifest $@.manifest /outputresource:$@;2
51+
52+
# Rules for linking Executables
53+
# Format is as follows (the mt command is needed for MSVC 2005/2008 builds):
54+
# $(dll_name_with_path): $(dependent_libs_files_objects_and_items)
55+
# link [$(linker_flags)] [$(dependent_libs)] -out:$@ @<<
56+
# $(dependent_objects)
57+
# <<
58+
# @-if exist $@.manifest mt /manifest $@.manifest /outputresource:$@;1
59+
60+
{..\examples\}.cc{$(CFG)\$(PLAT)\}.exe:
61+
@if not exist $(CFG)\$(PLAT)\libsigcpp-ex $(MAKE) -f Makefile.vc CFG=$(CFG) $(CFG)\$(PLAT)\libsigcpp-ex
62+
@if not exist $(LIBSIGC_LIB) $(MAKE) -f Makefile.vc CFG=$(CFG) $(LIBSIGC_LIB)
63+
$(CXX) $(SIGCPP_CFLAGS) /Fo$(CFG)\$(PLAT)\libsigcpp-ex\ $< /Fe$@ /link $(LDFLAGS) $(LIBSIGC_LIB)
64+
@-if exist $@.manifest mt /manifest $@.manifest /outputresource:$@;1
65+
66+
{..\tests\}.cc{$(CFG)\$(PLAT)\}.exe:
67+
@if not exist $(LIBSIGC_LIB) $(MAKE) -f Makefile.vc CFG=$(CFG) $(LIBSIGC_LIB)
68+
@if not exist $(CFG)\$(PLAT)\libsigcpp-tests\testutilities.obj $(MAKE) -f Makefile.vc CFG=$(CFG) $(CFG)\$(PLAT)\libsigcpp-tests\testutilities.obj
69+
$(CXX) $(SIGCPP_CFLAGS) /Fo$(CFG)\$(PLAT)\libsigcpp-tests\ $< /Fe$@ /link $(LDFLAGS) $(LIBSIGC_LIB) $(CFG)\$(PLAT)\libsigcpp-tests\testutilities.obj
70+
@-if exist $@.manifest mt /manifest $@.manifest /outputresource:$@;1
71+
72+
$(CFG)\$(PLAT)\libsigc++-benchmark.exe: ..\tests\benchmark.cc
73+
@if not exist $(LIBSIGC_LIB) $(MAKE) -f Makefile.vc CFG=$(CFG) $(LIBSIGC_LIB)
74+
@if not exist $(CFG)\$(PLAT)\libsigcpp-tests\testutilities.obj $(MAKE) -f Makefile.vc CFG=$(CFG) $(CFG)\$(PLAT)\libsigcpp-tests\testutilities.obj
75+
$(CXX) $(SIGCPP_BENCHMARK_CFLAGS) /Fo$(CFG)\$(PLAT)\libsigcpp-tests\ ..\tests\benchmark.cc /Fe$@ /link $(LDFLAGS) $(LIBSIGC_LIB) $(CFG)\$(PLAT)\libsigcpp-tests\testutilities.obj
76+
@-if exist $@.manifest mt /manifest $@.manifest /outputresource:$@;1
77+
78+
clean:
79+
@-del /f /q $(CFG)\$(PLAT)\*.exe
80+
@-del /f /q $(CFG)\$(PLAT)\*.dll
81+
@-del /f /q $(CFG)\$(PLAT)\*.pdb
82+
@-del /f /q $(CFG)\$(PLAT)\*.ilk
83+
@-del /f /q $(CFG)\$(PLAT)\*.exp
84+
@-del /f /q $(CFG)\$(PLAT)\*.lib
85+
@-if exist $(CFG)\$(PLAT)\libsigcpp-tests del /f /q $(CFG)\$(PLAT)\libsigcpp-tests\*.obj
86+
@-del /f /q $(CFG)\$(PLAT)\libsigcpp-ex\*.obj
87+
@-del /f /q $(CFG)\$(PLAT)\libsigcpp\*.res
88+
@-del /f /q $(CFG)\$(PLAT)\libsigcpp\*.obj
89+
@-if exist $(CFG)\$(PLAT)\libsigcpp-tests rd $(CFG)\$(PLAT)\libsigcpp-tests
90+
@-rd $(CFG)\$(PLAT)\libsigcpp-ex
91+
@-rd $(CFG)\$(PLAT)\libsigcpp
92+
@-del /f /q vc$(PDBVER)0.pdb

MSVC_NMake/config-msvc.mak

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# NMake Makefile portion for enabling features for Windows builds
2+
3+
# These are the base minimum libraries required for building gjs.
4+
BASE_INCLUDES = /I$(PREFIX)\include
5+
6+
# Please do not change anything beneath this line unless maintaining the NMake Makefiles
7+
8+
LIBSIGC_MAJOR_VERSION = 2
9+
LIBSIGC_MINOR_VERSION = 0
10+
11+
!if "$(CFG)" == "debug" || "$(CFG)" == "Debug"
12+
LIBSIGC_DEBUG_SUFFIX = -d
13+
!else
14+
LIBSIGC_DEBUG_SUFFIX =
15+
!endif
16+
17+
LIBSIGCPP_DEFINES = /DSIGC_BUILD /D_WINDLL
18+
19+
SIGCPP_BASE_CFLAGS = /I.. /I. /wd4530 $(CFLAGS)
20+
21+
LIBSIGC_INT_SOURCES = $(sigc_sources_cc:/=\)
22+
LIBSIGC_INT_HDRS = $(sigc_public_h:/=\)
23+
24+
SIGCPP_CFLAGS = $(SIGCPP_BASE_CFLAGS) $(CFLAGS)
25+
LIBSIGCPP_CFLAGS = $(SIGCPP_CFLAGS) $(LIBSIGCPP_DEFINES)
26+
27+
# We build sigc-vc$(PDBVER)0-$(LIBSIGC_MAJOR_VERSION)_$(LIBSIGC_MINOR_VERSION).dll or
28+
# sigc-vc$(PDBVER)0d-$(LIBSIGC_MAJOR_VERSION)_$(LIBSIGC_MINOR_VERSION).dll at least
29+
30+
LIBSIGC_LIBNAME = sigc-vc$(PDBVER)0$(LIBSIGC_DEBUG_SUFFIX)-$(LIBSIGC_MAJOR_VERSION)_$(LIBSIGC_MINOR_VERSION)
31+
32+
LIBSIGC_DLL = $(CFG)\$(PLAT)\$(LIBSIGC_LIBNAME).dll
33+
LIBSIGC_LIB = $(CFG)\$(PLAT)\$(LIBSIGC_LIBNAME).lib
34+
35+
# Note that building the benchmark requires Boost!
36+
libsigc_bench = $(CFG)\$(PLAT)\libsigc++-benchmark.exe
37+
38+
# If your Boost libraries are built as DLLs, use BOOST_DLL=1 in your NMake command line
39+
!ifdef BOOST_DLL
40+
SIGCPP_BENCHMARK_CFLAGS = $(SIGCPP_BASE_CFLAGS) /DBOOST_ALL_DYN_LINK
41+
!else
42+
SIGCPP_BENCHMARK_CFLAGS = $(SIGCPP_BASE_CFLAGS)
43+
!endif

MSVC_NMake/create-lists-msvc.mak

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
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 libsigc++
37+
38+
!if [call create-lists.bat header libsigcpp.mak libsigcpp_dll_OBJS]
39+
!endif
40+
41+
!if [for %c in ($(sigc_sources_cc)) do @if "%~xc" == ".cc" @call create-lists.bat file libsigcpp.mak ^$(CFG)\^$(PLAT)\libsigcpp\%~nc.obj]
42+
!endif
43+
44+
!if [@call create-lists.bat file libsigcpp.mak ^$(CFG)\^$(PLAT)\libsigcpp\sigc.res]
45+
!endif
46+
47+
!if [call create-lists.bat footer libsigcpp.mak]
48+
!endif
49+
50+
!if [call create-lists.bat header libsigcpp.mak libsigc_ex]
51+
!endif
52+
53+
!if [for %s in (..\examples\*.cc) do @call create-lists.bat file libsigcpp.mak ^$(CFG)\^$(PLAT)\%~ns.exe]
54+
!endif
55+
56+
!if [call create-lists.bat footer libsigcpp.mak]
57+
!endif
58+
59+
!if [call create-lists.bat header libsigcpp.mak libsigc_tests]
60+
!endif
61+
62+
# Skipping testutilities.cc: Not to be built as a .exe, but is a common dependency for the tests
63+
# benchmark: Not built on default; requires Boost
64+
!if [for %s in (..\tests\*.cc) do @if not "%~ns" == "testutilities" if not "%~ns" == "benchmark" @call create-lists.bat file libsigcpp.mak ^$(CFG)\^$(PLAT)\%~ns.exe]
65+
!endif
66+
67+
!if [call create-lists.bat footer libsigcpp.mak]
68+
!endif
69+
70+
!include libsigcpp.mak
71+
72+
!if [del /f /q libsigcpp.mak]
73+
!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)