summaryrefslogtreecommitdiff
path: root/MSVC_NMake
diff options
context:
space:
mode:
authorChun-wei Fan <fanchunwei@src.gnome.org>2020-04-24 15:07:47 +0800
committerKjell Ahlstedt <kjellahlstedt@gmail.com>2020-04-29 09:45:27 +0200
commitb04125a94f3d34288c044db368b9c178dbbdb94a (patch)
treeeb1a239173037e4a012b9b0c900f3ff9c16ce0d7 /MSVC_NMake
parent8af771f11f8f1896d6a1450a25e2b0cff62b2925 (diff)
NMake Makefiles: Add rule to generate versioned files
This will make building directly from a GIT checkout easier, by using PERL to read the configure.ac file to acquire the version info, and using this info to generate the full cairommconfig.h and cairomm.rc files that we need for our Visual Studio builds. This will also enable us to build from a Meson-generated source tarball, as we may well need to generate these files ourselves.
Diffstat (limited to 'MSVC_NMake')
-rw-r--r--MSVC_NMake/Makefile.vc4
-rw-r--r--MSVC_NMake/generate-msvc.mak36
2 files changed, 40 insertions, 0 deletions
diff --git a/MSVC_NMake/Makefile.vc b/MSVC_NMake/Makefile.vc
index 768f799..45e6ef3 100644
--- a/MSVC_NMake/Makefile.vc
+++ b/MSVC_NMake/Makefile.vc
@@ -30,6 +30,10 @@ VALID_MSC = TRUE
!if "$(VALID_MSC)" == "TRUE"
+!ifdef GENERATE_VERSIONED_FILES
+!include pkg-ver.mak
+!endif
+
# Include the Makefile portion to convert the source and header lists
# into the lists we need for compilation and introspection
!include create-lists-msvc.mak
diff --git a/MSVC_NMake/generate-msvc.mak b/MSVC_NMake/generate-msvc.mak
index 29f517d..3cd6f35 100644
--- a/MSVC_NMake/generate-msvc.mak
+++ b/MSVC_NMake/generate-msvc.mak
@@ -13,3 +13,39 @@ vs$(VSVER)\$(CFG)\$(PLAT)\cairomm-tests:
# Generate .def files
vs$(VSVER)\$(CFG)\$(PLAT)\cairomm\cairomm.def: $(GENDEF) vs$(VSVER)\$(CFG)\$(PLAT)\cairomm $(cairomm_OBJS)
vs$(VSVER)\$(CFG)\$(PLAT)\gendef.exe $@ $(CAIROMM_LIBNAME) vs$(VSVER)\$(CFG)\$(PLAT)\cairomm\*.obj
+
+# Generate pre-generated resources and configuration headers (builds from GIT)
+prep-git-build: pkg-ver.mak
+ $(MAKE) /f Makefile.vc CFG=$(CFG) GENERATE_VERSIONED_FILES=1 cairomm\cairomm.rc cairomm\cairommconfig.h
+
+cairomm\cairomm.rc: pkg-ver.mak cairomm\cairomm.rc.in
+ @echo Generating $@...
+ @copy $@.in $@
+ @$(PERL) -pi.bak -e "s/\@CAIROMM_MAJOR_VERSION\@/$(PKG_MAJOR_VERSION)/g" $@
+ @$(PERL) -pi.bak -e "s/\@CAIROMM_MINOR_VERSION\@/$(PKG_MINOR_VERSION)/g" $@
+ @$(PERL) -pi.bak -e "s/\@CAIROMM_MICRO_VERSION\@/$(PKG_MICRO_VERSION)/g" $@
+ @$(PERL) -pi.bak -e "s/\@VERSION\@/$(PKG_MAJOR_VERSION).$(PKG_MINOR_VERSION).$(PKG_MICRO_VERSION)/g" $@
+ @del $@.bak
+
+# You may change CAIROMM_EXCEPTIONS_ENABLED if you know what you are doing
+cairomm\cairommconfig.h: pkg-ver.mak ..\cairommconfig.h.in
+ @echo Generating $@...
+ @copy ..\$(@F).in $@
+ @$(PERL) -pi.bak -e "s/\#undef CAIROMM_EXCEPTIONS_ENABLED/\#define CAIROMM_EXCEPTIONS_ENABLED 1/g" $@
+ @$(PERL) -pi.bak -e "s/\#undef CAIROMM_MAJOR_VERSION/\#define CAIROMM_MAJOR_VERSION $(PKG_MAJOR_VERSION)/g" $@
+ @$(PERL) -pi.bak -e "s/\#undef CAIROMM_MINOR_VERSION/\#define CAIROMM_MINOR_VERSION $(PKG_MINOR_VERSION)/g" $@
+ @$(PERL) -pi.bak -e "s/\#undef CAIROMM_MICRO_VERSION/\#define CAIROMM_MICRO_VERSION $(PKG_MICRO_VERSION)/g" $@
+ @del $@.bak
+
+pkg-ver.mak: ..\configure.ac
+ @echo Generating version info Makefile Snippet...
+ @$(PERL) -00 -ne "print if /AC_INIT\(/" $** | \
+ $(PERL) -pe "tr/, /\n/s" | \
+ $(PERL) -ne "print if 2 .. 2" | \
+ $(PERL) -ne "print /\[(.*)\]/" > ver.txt
+ @echo @echo off>pkg-ver.bat
+ @echo.>>pkg-ver.bat
+ @echo set /p cairomm_ver=^<ver.txt>>pkg-ver.bat
+ @echo for /f "tokens=1,2,3 delims=." %%%%a IN ("%cairomm_ver%") do (echo PKG_MAJOR_VERSION=%%%%a^& echo PKG_MINOR_VERSION=%%%%b^& echo PKG_MICRO_VERSION=%%%%c)^>$@>>pkg-ver.bat
+ @pkg-ver.bat
+ @del ver.txt pkg-ver.bat