Skip to content

Commit fbcc448

Browse files
fanc999-1kjellahl
authored andcommitted
Build: Use NMake Makefiles for MSVC Builds
Since the MSVC projects are not created upon 'make dist' but is manually updated, use a set of NMake Makefiles that consumes sigc++/filelist.am as needed, so that whenever the list of sources is updated, we do not have to worry that the generated release tarballs have broken Visual Studio build files. The next commit will remove the Visual Studio project files. This should make maintenance of the Visual Studio build files easier.
1 parent 491728c commit fbcc448

13 files changed

+471
-67
lines changed

MSVC_NMake/Makefile.vc

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

MSVC_NMake/build-rules-msvc.mak

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
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++\functors\}.cc{$(CFG)\$(PLAT)\libsigcpp\}.obj::
22+
$(CXX) $(LIBSIGCPP_CFLAGS) /Fo$(CFG)\$(PLAT)\libsigcpp\ /c @<<
23+
$<
24+
<<
25+
26+
# Rules for building .lib files
27+
$(LIBSIGC_LIB): $(LIBSIGC_DLL)
28+
29+
{.}.rc{$(CFG)\$(PLAT)\libsigcpp\}.res:
30+
rc /fo$@ $<
31+
32+
# Rules for linking DLLs
33+
# Format is as follows (the mt command is needed for MSVC 2005/2008 builds):
34+
# $(dll_name_with_path): $(dependent_libs_files_objects_and_items)
35+
# link /DLL [$(linker_flags)] [$(dependent_libs)] [/def:$(def_file_if_used)] [/implib:$(lib_name_if_needed)] -out:$@ @<<
36+
# $(dependent_objects)
37+
# <<
38+
# @-if exist $@.manifest mt /manifest $@.manifest /outputresource:$@;2
39+
$(LIBSIGC_DLL): $(CFG)\$(PLAT)\libsigcpp $(libsigcpp_dll_OBJS)
40+
link /DLL $(LDFLAGS) /implib:$(LIBSIGC_LIB) -out:$@ @<<
41+
$(libsigcpp_dll_OBJS)
42+
<<
43+
@-if exist $@.manifest mt /manifest $@.manifest /outputresource:$@;2
44+
45+
# Rules for linking Executables
46+
# Format is as follows (the mt command is needed for MSVC 2005/2008 builds):
47+
# $(dll_name_with_path): $(dependent_libs_files_objects_and_items)
48+
# link [$(linker_flags)] [$(dependent_libs)] -out:$@ @<<
49+
# $(dependent_objects)
50+
# <<
51+
# @-if exist $@.manifest mt /manifest $@.manifest /outputresource:$@;1
52+
53+
$(CFG)\$(PLAT)\gjs-console.exe: $(CFG)\$(PLAT)\gjs.lib $(CFG)\$(PLAT)\gjs-console $(gjs_OBJS)
54+
link $(LDFLAGS) $(CFG)\$(PLAT)\gjs.lib $(GJS_BASE_LIBS) -out:$@ $(gjs_OBJS)
55+
@-if exist $@.manifest mt /manifest $@.manifest /outputresource:$@;1
56+
57+
clean:
58+
@-del /f /q $(CFG)\$(PLAT)\*.pdb
59+
@-del /f /q $(CFG)\$(PLAT)\*.dll
60+
@-del /f /q $(CFG)\$(PLAT)\*.ilk
61+
@-del /f /q $(CFG)\$(PLAT)\*.exp
62+
@-del /f /q $(CFG)\$(PLAT)\*.lib
63+
@-del /f /q $(CFG)\$(PLAT)\libsigcpp\*.res
64+
@-del /f /q $(CFG)\$(PLAT)\libsigcpp\*.obj
65+
@-rd $(CFG)\$(PLAT)\libsigcpp
66+
@-del /f /q vc$(PDBVER)0.pdb

MSVC_NMake/config-msvc.mak

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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 = 3
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 /std:c++17
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$(VSVER)0-$(LIBSIGC_MAJOR_VERSION)_$(LIBSIGC_MINOR_VERSION).dll or
28+
# sigc-vc$(VSVER)0d-$(LIBSIGC_MAJOR_VERSION)_$(LIBSIGC_MINOR_VERSION).dll at least
29+
30+
LIBSIGC_LIBNAME = sigc-vc$(VSVER)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

MSVC_NMake/create-lists-msvc.mak

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
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+
!include libsigcpp.mak
51+
52+
!if [del /f /q libsigcpp.mak]
53+
!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)