Skip to content

Commit 628fd26

Browse files
fanc999-1kjellahl
authored andcommitted
Rework NMake Makefiles
Clean up the NMake Makefiles so that they will become easier to maintain and faster to run by: * Rename instances of 'libsigcpp' to 'sigc' * Just use 'md' directly to create all intermediate directories * "Generate" the rules to build the example and test programs, instead of using generic hand-written rules for all of them, as most of them share common rules. * Add a 'prep-git-build' rule to allow building directly from a GIT checkout
1 parent 9120803 commit 628fd26

File tree

5 files changed

+80
-65
lines changed

5 files changed

+80
-65
lines changed

MSVC_NMake/Makefile.vc

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,23 @@ VALID_MSC = TRUE
3030

3131
!if "$(VALID_MSC)" == "TRUE"
3232

33+
!ifdef GENERATE_VERSIONED_FILES
34+
!include pkg-ver.mak
35+
!endif
36+
37+
all: $(LIBSIGC_LIB) examples all-build-info
38+
3339
# Include the Makefile portion to convert the source and header lists
3440
# into the lists we need for compilation and introspection
3541
!include create-lists-msvc.mak
42+
!include generate-msvc.mak
3643

37-
all: $(LIBSIGC_LIB) $(libsigc_ex) all-build-info
38-
44+
examples: $(libsigc_examples)
3945
tests: $(libsigc_tests) all-build-info
4046

41-
benchmark: all $(libsigc_bench) all-build-info
47+
benchmark: all $(libsigc_benchmark) all-build-info
4248

4349
# Include the build rules for sources, DLLs and executables
44-
!include generate-msvc.mak
4550
!include build-rules-msvc.mak
4651

4752
!include install.mak

MSVC_NMake/build-rules-msvc.mak

Lines changed: 22 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -13,25 +13,24 @@
1313
# $(CC)|$(CXX) $(cflags) /Fo$(destdir) /c @<<
1414
# $<
1515
# <<
16-
{..\sigc++\}.cc{vs$(VSVER)\$(CFG)\$(PLAT)\libsigcpp\}.obj:
16+
{..\sigc++\}.cc{vs$(VSVER)\$(CFG)\$(PLAT)\sigc\}.obj:
17+
@if not exist $(@D)\ md $(@D)
1718
$(CXX) $(LIBSIGCPP_CFLAGS) /Fo$(@D)\ /Fd$(@D)\ /c @<<
1819
$<
1920
<<
2021

21-
{..\sigc++\functors\}.cc{vs$(VSVER)\$(CFG)\$(PLAT)\libsigcpp\}.obj:
22+
{..\sigc++\functors\}.cc{vs$(VSVER)\$(CFG)\$(PLAT)\sigc\}.obj:
23+
@if not exist $(@D)\ md $(@D)
2224
$(CXX) $(LIBSIGCPP_CFLAGS) /Fo$(@D)\ /Fd$(@D)\ /c @<<
2325
$<
2426
<<
2527

26-
vs$(VSVER)\$(CFG)\$(PLAT)\libsigcpp-tests\testutilities.obj: vs$(VSVER)\$(CFG)\$(PLAT)\libsigcpp-tests ..\tests\testutilities.cc
27-
$(CXX) $(SIGCPP_CFLAGS) /Fo$@ /Fd$(@D)\ /c ..\tests\testutilities.cc
28-
# Rules for building .lib files
29-
$(LIBSIGC_LIB): $(LIBSIGC_DLL)
30-
31-
{.}.rc{vs$(VSVER)\$(CFG)\$(PLAT)\libsigcpp\}.res:
28+
{.}.rc{vs$(VSVER)\$(CFG)\$(PLAT)\sigc\}.res:
29+
@if not exist $(@D)\ md $(@D)
3230
rc /fo$@ $<
3331

34-
{..\untracked\MSVC_NMake\}.rc{vs$(VSVER)\$(CFG)\$(PLAT)\libsigcpp\}.res:
32+
{..\untracked\MSVC_NMake\}.rc{vs$(VSVER)\$(CFG)\$(PLAT)\sigc\}.res:
33+
@if not exist $(@D)\ md $(@D)
3534
rc /fo$@ $<
3635

3736
# Rules for linking DLLs
@@ -41,9 +40,11 @@ $(LIBSIGC_LIB): $(LIBSIGC_DLL)
4140
# $(dependent_objects)
4241
# <<
4342
# @-if exist $@.manifest mt /manifest $@.manifest /outputresource:$@;2
44-
$(LIBSIGC_DLL): vs$(VSVER)\$(CFG)\$(PLAT)\libsigcpp $(libsigcpp_dll_OBJS)
43+
$(LIBSIGC_LIB): $(LIBSIGC_DLL)
44+
45+
$(LIBSIGC_DLL): $(sigc_dll_OBJS)
4546
link /DLL $(LDFLAGS) /implib:$(LIBSIGC_LIB) -out:$@ @<<
46-
$(libsigcpp_dll_OBJS)
47+
$(sigc_dll_OBJS)
4748
<<
4849
@-if exist $@.manifest mt /manifest $@.manifest /outputresource:$@;2
4950

@@ -55,38 +56,20 @@ $(libsigcpp_dll_OBJS)
5556
# <<
5657
# @-if exist $@.manifest mt /manifest $@.manifest /outputresource:$@;1
5758

58-
{..\examples\}.cc{vs$(VSVER)\$(CFG)\$(PLAT)\}.exe:
59-
@if not exist vs$(VSVER)\$(CFG)\$(PLAT)\libsigcpp-ex $(MAKE) -f Makefile.vc CFG=$(CFG) vs$(VSVER)\$(CFG)\$(PLAT)\libsigcpp-ex
60-
@if not exist $(LIBSIGC_LIB) $(MAKE) -f Makefile.vc CFG=$(CFG) $(LIBSIGC_LIB)
61-
$(CXX) $(SIGCPP_CFLAGS) /Fo$(@D)\libsigcpp-ex\ /Fd$(@D)\libsigcpp-ex\ $< /Fe$@ /link $(LDFLAGS) $(LIBSIGC_LIB)
62-
@-if exist $@.manifest mt /manifest $@.manifest /outputresource:$@;1
63-
64-
{..\tests\}.cc{vs$(VSVER)\$(CFG)\$(PLAT)\}.exe:
65-
@if not exist $(LIBSIGC_LIB) $(MAKE) -f Makefile.vc CFG=$(CFG) $(LIBSIGC_LIB)
66-
@if not exist vs$(VSVER)\$(CFG)\$(PLAT)\libsigcpp-tests\testutilities.obj $(MAKE) -f Makefile.vc CFG=$(CFG) vs$(VSVER)\$(CFG)\$(PLAT)\libsigcpp-tests\testutilities.obj
67-
$(CXX) $(SIGCPP_CFLAGS) /Fo$(@D)\libsigcpp-tests\ /Fd$(@D)\libsigcpp-tests\ $< /Fe$@ /link $(LDFLAGS) $(LIBSIGC_LIB) vs$(VSVER)\$(CFG)\$(PLAT)\libsigcpp-tests\testutilities.obj
68-
@-if exist $@.manifest mt /manifest $@.manifest /outputresource:$@;1
69-
70-
vs$(VSVER)\$(CFG)\$(PLAT)\libsigc++-benchmark.exe: ..\tests\benchmark.cc
71-
@if not exist $(LIBSIGC_LIB) $(MAKE) -f Makefile.vc CFG=$(CFG) $(LIBSIGC_LIB)
72-
@if not exist vs$(VSVER)\$(CFG)\$(PLAT)\libsigcpp-tests\testutilities.obj $(MAKE) -f Makefile.vc CFG=$(CFG) vs$(VSVER)\$(CFG)\$(PLAT)\libsigcpp-tests\testutilities.obj
73-
$(CXX) $(SIGCPP_BENCHMARK_CFLAGS) /Fo$(@D)\libsigcpp-tests\ /Fd$(@D)\libsigcpp-tests\ ..\tests\benchmark.cc /Fe$@ /link $(LDFLAGS) $(LIBSIGC_LIB) vs$(VSVER)\$(CFG)\$(PLAT)\libsigcpp-tests\testutilities.obj
74-
@-if exist $@.manifest mt /manifest $@.manifest /outputresource:$@;1
75-
7659
clean:
7760
@-del /f /q vs$(VSVER)\$(CFG)\$(PLAT)\*.exe
7861
@-del /f /q vs$(VSVER)\$(CFG)\$(PLAT)\*.dll
7962
@-del /f /q vs$(VSVER)\$(CFG)\$(PLAT)\*.pdb
8063
@-del /f /q vs$(VSVER)\$(CFG)\$(PLAT)\*.ilk
8164
@-del /f /q vs$(VSVER)\$(CFG)\$(PLAT)\*.exp
8265
@-del /f /q vs$(VSVER)\$(CFG)\$(PLAT)\*.lib
83-
@-if exist vs$(VSVER)\$(CFG)\$(PLAT)\libsigcpp-tests del /f /q vs$(VSVER)\$(CFG)\$(PLAT)\libsigcpp-tests\*.obj
84-
@-if exist vs$(VSVER)\$(CFG)\$(PLAT)\libsigcpp-tests del /f /q vs$(VSVER)\$(CFG)\$(PLAT)\libsigcpp-tests\*.pdb
85-
@-del /f /q vs$(VSVER)\$(CFG)\$(PLAT)\libsigcpp-ex\*.obj
86-
@-del /f /q vs$(VSVER)\$(CFG)\$(PLAT)\libsigcpp-ex\*.pdb
87-
@-del /f /q vs$(VSVER)\$(CFG)\$(PLAT)\libsigcpp\*.res
88-
@-del /f /q vs$(VSVER)\$(CFG)\$(PLAT)\libsigcpp\*.obj
89-
@-del /f /q vs$(VSVER)\$(CFG)\$(PLAT)\libsigcpp\*.pdb
90-
@-if exist vs$(VSVER)\$(CFG)\$(PLAT)\libsigcpp-tests rd vs$(VSVER)\$(CFG)\$(PLAT)\libsigcpp-tests
91-
@-rd vs$(VSVER)\$(CFG)\$(PLAT)\libsigcpp-ex
92-
@-rd vs$(VSVER)\$(CFG)\$(PLAT)\libsigcpp
66+
@-if exist vs$(VSVER)\$(CFG)\$(PLAT)\sigc-tests del /f /q vs$(VSVER)\$(CFG)\$(PLAT)\sigc-tests\*.obj
67+
@-if exist vs$(VSVER)\$(CFG)\$(PLAT)\sigc-tests del /f /q vs$(VSVER)\$(CFG)\$(PLAT)\sigc-tests\*.pdb
68+
@-del /f /q vs$(VSVER)\$(CFG)\$(PLAT)\sigc-examples\*.obj
69+
@-del /f /q vs$(VSVER)\$(CFG)\$(PLAT)\sigc-examples\*.pdb
70+
@-del /f /q vs$(VSVER)\$(CFG)\$(PLAT)\sigc\*.res
71+
@-del /f /q vs$(VSVER)\$(CFG)\$(PLAT)\sigc\*.obj
72+
@-del /f /q vs$(VSVER)\$(CFG)\$(PLAT)\sigc\*.pdb
73+
@-if exist vs$(VSVER)\$(CFG)\$(PLAT)\sigc-tests rd vs$(VSVER)\$(CFG)\$(PLAT)\sigc-tests
74+
@-rd vs$(VSVER)\$(CFG)\$(PLAT)\sigc-examples
75+
@-rd vs$(VSVER)\$(CFG)\$(PLAT)\sigc

MSVC_NMake/config-msvc.mak

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,6 @@ LIBSIGC_LIBNAME = sigc-vc$(VSVER)0$(LIBSIGC_DEBUG_SUFFIX)-$(LIBSIGC_MAJOR_VERSIO
3232
LIBSIGC_DLL = vs$(VSVER)\$(CFG)\$(PLAT)\$(LIBSIGC_LIBNAME).dll
3333
LIBSIGC_LIB = vs$(VSVER)\$(CFG)\$(PLAT)\$(LIBSIGC_LIBNAME).lib
3434

35-
# Note that building the benchmark requires Boost!
36-
libsigc_bench = vs$(VSVER)\$(CFG)\$(PLAT)\libsigc++-benchmark.exe
37-
3835
# If your Boost libraries are built as DLLs, use BOOST_DLL=1 in your NMake command line
3936
!ifdef BOOST_DLL
4037
SIGCPP_BENCHMARK_CFLAGS = $(SIGCPP_BASE_CFLAGS) /DBOOST_ALL_DYN_LINK

MSVC_NMake/create-lists-msvc.mak

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -35,39 +35,37 @@ NULL=
3535

3636
# For libsigc++
3737

38-
!if [call create-lists.bat header libsigcpp.mak libsigcpp_dll_OBJS]
38+
!if [call create-lists.bat header sigc.mak sigc_dll_OBJS]
3939
!endif
4040

41-
!if [for %c in ($(sigc_sources_cc)) do @if "%~xc" == ".cc" @call create-lists.bat file libsigcpp.mak vs^$(VSVER)\^$(CFG)\^$(PLAT)\libsigcpp\%~nc.obj]
41+
!if [for %c in ($(sigc_sources_cc)) do @if "%~xc" == ".cc" @call create-lists.bat file sigc.mak vs^$(VSVER)\^$(CFG)\^$(PLAT)\sigc\%~nc.obj]
4242
!endif
4343

44-
!if [@call create-lists.bat file libsigcpp.mak vs^$(VSVER)\^$(CFG)\^$(PLAT)\libsigcpp\sigc.res]
44+
!if [@call create-lists.bat file sigc.mak vs^$(VSVER)\^$(CFG)\^$(PLAT)\sigc\sigc.res]
4545
!endif
4646

47-
!if [call create-lists.bat footer libsigcpp.mak]
47+
!if [call create-lists.bat footer sigc.mak]
4848
!endif
4949

50-
!if [call create-lists.bat header libsigcpp.mak libsigc_ex]
50+
!if [for %d in (examples tests) do @call create-lists.bat header sigc.mak libsigc_%d & @(for %s in (..\%d\*.cc) do @if not "%~ns" == "testutilities" if not "%~ns" == "benchmark" call create-lists.bat file sigc.mak vs$(VSVER)\$(CFG)\$(PLAT)\%~ns.exe) & @call create-lists.bat footer sigc.mak]
5151
!endif
5252

53-
!if [for %s in (..\examples\*.cc) do @call create-lists.bat file libsigcpp.mak vs^$(VSVER)\^$(CFG)\^$(PLAT)\%~ns.exe]
53+
!if [call create-lists.bat header sigc.mak libsigc_benchmark & @for %s in (..\tests\benchmark.cc) do @(call create-lists.bat file sigc.mak vs$(VSVER)\$(CFG)\$(PLAT)\%~ns.exe) & @call create-lists.bat footer sigc.mak]
5454
!endif
5555

56-
!if [call create-lists.bat footer libsigcpp.mak]
56+
!if [for %d in (examples tests) do @for %s in (..\%d\*.cc) do @if not "%~ns" == "benchmark" echo vs^$(VSVER)\^$(CFG)\^$(PLAT)\sigc-%d\%~ns.obj: %s>>sigc.mak & @echo. @if not exist ^$(@D)\ md ^$(@D)>>sigc.mak & @echo. ^$(CXX) ^$(SIGCPP_CFLAGS) /Fo^$(@D)\ /Fd^$(@D)\ ^$** /c>>sigc.mak & @echo.>>sigc.mak]
5757
!endif
5858

59-
!if [call create-lists.bat header libsigcpp.mak libsigc_tests]
59+
!if [for %s in (..\tests\benchmark.cc) do @echo vs^$(VSVER)\^$(CFG)\^$(PLAT)\sigc-tests\%~ns.obj: %s>>sigc.mak & @echo. @if not exist ^$(@D)\ md ^$(@D)>>sigc.mak & @echo. ^$(CXX) ^$(SIGCPP_BENCHMARK_CFLAGS) /Fo^$(@D)\ /Fd^$(@D)\ ^$** /c>>sigc.mak & @echo.>>sigc.mak]
6060
!endif
6161

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 vs^$(VSVER)\^$(CFG)\^$(PLAT)\%~ns.exe]
62+
!if [for %s in (..\examples\*.cc) do @echo vs^$(VSVER)\^$(CFG)\^$(PLAT)\%~ns.exe: ^$(LIBSIGC_LIB) vs^$(VSVER)\^$(CFG)\^$(PLAT)\sigc-examples\%~ns.obj>>sigc.mak & @echo. link ^$(LDFLAGS) ^$** /out:^$@>>sigc.mak & @echo.>>sigc.mak]
6563
!endif
6664

67-
!if [call create-lists.bat footer libsigcpp.mak]
65+
!if [for %s in (..\tests\*.cc) do @if not "%~ns" == "testutilities" echo vs^$(VSVER)\^$(CFG)\^$(PLAT)\%~ns.exe: ^$(LIBSIGC_LIB) vs^$(VSVER)\^$(CFG)\^$(PLAT)\sigc-tests\%~ns.obj vs^$(VSVER)\^$(CFG)\^$(PLAT)\sigc-tests\testutilities.obj>>sigc.mak & @echo. link ^$(LDFLAGS) ^$** /out:^$@>>sigc.mak & @echo.>>sigc.mak]
6866
!endif
6967

70-
!include libsigcpp.mak
68+
!include sigc.mak
7169

72-
!if [del /f /q libsigcpp.mak]
70+
!if [del /f /q sigc.mak]
7371
!endif

MSVC_NMake/generate-msvc.mak

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,40 @@
33
# Items in here should not need to be edited unless
44
# one is maintaining the NMake build files.
55

6-
# Create the build directories
7-
vs$(VSVER)\$(CFG)\$(PLAT)\libsigcpp \
8-
vs$(VSVER)\$(CFG)\$(PLAT)\libsigcpp-ex \
9-
vs$(VSVER)\$(CFG)\$(PLAT)\libsigcpp-tests:
10-
@-md $@
6+
# Create the versioned files
7+
8+
prep-git-build: pkg-ver.mak
9+
10+
sigc.rc: pkg-ver.mak sigc.rc.in
11+
@echo Generating $@...
12+
@copy $@.in $@
13+
@$(PERL) -pi.bak -e "s/\@SIGCXX_MAJOR_VERSION\@/$(PKG_MAJOR_VERSION)/g" $@
14+
@$(PERL) -pi.bak -e "s/\@SIGCXX_MINOR_VERSION\@/$(PKG_MINOR_VERSION)/g" $@
15+
@$(PERL) -pi.bak -e "s/\@SIGCXX_MICRO_VERSION\@/$(PKG_MICRO_VERSION)/g" $@
16+
@$(PERL) -pi.bak -e "s/\@PACKAGE_VERSION\@/$(PKG_MAJOR_VERSION).$(PKG_MINOR_VERSION).$(PKG_MICRO_VERSION)/g" $@
17+
@$(PERL) -pi.bak -e "s/\@SIGCXX_API_VERSION\@/$(LIBSIGC_MAJOR_VERSION).$(LIBSIGC_MINOR_VERSION)/g" $@
18+
@del $@.bak
19+
20+
# You may change SIGCXX_DISABLE_DEPRECATED if you know what you are doing
21+
sigc++config.h: pkg-ver.mak ..\sigc++config.h.in
22+
@echo Generating $@...
23+
@copy "..\$(@F).in" "$@"
24+
@$(PERL) -pi.bak -e "s/\#undef SIGCXX_DISABLE_DEPRECATED/\/\* \#undef SIGCXX_DISABLE_DEPRECATED \*\//g" $@
25+
@$(PERL) -pi.bak -e "s/\#undef SIGCXX_MAJOR_VERSION/\#define SIGCXX_MAJOR_VERSION $(PKG_MAJOR_VERSION)/g" $@
26+
@$(PERL) -pi.bak -e "s/\#undef SIGCXX_MINOR_VERSION/\#define SIGCXX_MINOR_VERSION $(PKG_MINOR_VERSION)/g" $@
27+
@$(PERL) -pi.bak -e "s/\#undef SIGCXX_MICRO_VERSION/\#define SIGCXX_MICRO_VERSION $(PKG_MICRO_VERSION)/g" $@
28+
@del $@.bak
29+
30+
pkg-ver.mak: ..\configure.ac
31+
@echo Generating version info Makefile Snippet...
32+
@$(PERL) -00 -ne "print if /AC_INIT\(/" $** | \
33+
$(PERL) -pe "tr/, /\n/s" | \
34+
$(PERL) -ne "print if 2 .. 2" | \
35+
$(PERL) -ne "print /\[(.*)\]/" > ver.txt
36+
@echo @echo off>pkg-ver.bat
37+
@echo.>>pkg-ver.bat
38+
@echo set /p sigc_ver=^<ver.txt>>pkg-ver.bat
39+
@echo for /f "tokens=1,2,3 delims=." %%%%a IN ("%%sigc_ver%%") do (echo PKG_MAJOR_VERSION=%%%%a^& echo PKG_MINOR_VERSION=%%%%b^& echo PKG_MICRO_VERSION=%%%%c)^>$@>>pkg-ver.bat
40+
@pkg-ver.bat
41+
@del ver.txt pkg-ver.bat
42+
$(MAKE) /f Makefile.vc CFG=$(CFG) GENERATE_VERSIONED_FILES=1 sigc.rc sigc++config.h

0 commit comments

Comments
 (0)