1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
|
# Author: Fan, Chun-wei
# Common Autotools file used to generate Visual Studio 2008+
# Projects from their templates
# This autotools file, from GLib, can be used in other projects
# that have Visual Studio build support.
# * Input variables:
#
# MSVCPROJS - List of Projects that should be generated
#
# * Simple tutorial
#
# Add this to Makefile.am where your library/program is built:
# include <this Makefile.msvcproj>
# MSVCPROJS = YourProject (can be multiple projects in a single srcdir)
# YourProject_FILES = $(libyourlib_1_0_SOURCES)
# YourProject_EXCLUDES = ... # list of sources to exclude, separated by '|', wildcards allowed; use random unsed value if none
# (the following 3 lines if headers need to be installed)
# YourProject_HEADERS_DIR = $(libyourlibincludedir)
# YourProject_HEADERS_INST = $(libyourlib_1_0_HEADERS)
# YourProject_HEADERS_EXCLUDES = ... # <list of headers to exclude from installation, separated by '|', wildcards allowed; use random unsed value if none>
#
# dist-hook: \ # (or add to it if it is already there, note the vs9 items will also call the vs10 items in the process)
# $(top_builddir)/win32/vs9/YourProject.vcproj \
# $(top_builddir)/win32/vs9/YourProject.headers # if headers need to be installed
#
# --or, if Visual Studio 2013 or later is required--
# dist-hook: \ # (or add to it if it is already there, this does -not- call other vs items in the process)
# $(top_builddir)/win32/vs12/YourProject.vcxproj \
# $(top_builddir)/win32/vs12/YourProject.vs12.headers # if headers need to be installed
# Private functions
## Transform the MSVC project filename (no filename extensions) to something which can reference through a variable
## without automake/make complaining, eg Gtk-2.0 -> Gtk_2_0
_proj_name=$(subst /,_,$(subst -,_,$(subst .,_,$(1))))
_proj_path_raw:=$(subst $(abs_top_srcdir),,$(abs_srcdir))
_proj_path=$(subst /,\\,$(_proj_path_raw))
_proj_subdir_int=$(subst \\\\,\\,\\$(_proj_path)\\)
_proj_subdir=$(subst \\.\\,\\,$(_proj_subdir_int))
_proj_files_raw=$(subst /,\\,$($(_proj_name)_FILES))
_proj_files=$(subst $(srcdir)\\,,$(subst $(builddir)\\,,$(subst $(top_builddir)\\$(_proj_path)\\,\\,$(_proj_files_raw))))
_proj_filters=$($(_proj_name)_EXCLUDES)
_proj_headers_raw=$(subst /,\\,$($(_proj_name)_HEADERS_INST))
_proj_headers=$(subst $(srcdir)\\,,$(subst $(builddir)\\,,$(subst $(top_builddir)\\$(_proj_path)\\,\\,$(_proj_headers_raw))))
_proj_headers_excludes=$($(_proj_name)_HEADERS_EXCLUDES)
_headers_dest_posix=$(subst $(includedir),,$($(_proj_name)_HEADERS_DIR))
_headers_destdir=$(subst /,\\,$(_headers_dest_posix))
#
# Creates Visual Studio 2008/2010 projects from items passed in from autotools files
# $(1) - Base Name of the MSVC project files (outputs)
#
define msvcproj-builder
$(top_builddir)/win32/vs10/$(1).vcxproj: $(top_builddir)/win32/vs9/$(1).vcproj
$(top_builddir)/win32/vs10/$(1).vcxproj.filters: $(top_builddir)/win32/vs9/$(1).vcproj
$(1).sourcefiles: $(top_builddir)/win32/vs9/$(1).vcproj
$(1).vs10.sourcefiles: $(top_builddir)/win32/vs9/$(1).vcproj
$(1).vs10.sourcefiles.filters: $(top_builddir)/win32/vs9/$(1).vcproj
$(top_builddir)/win32/vs9/$(1).vcproj: Makefile
-$(RM) $(top_builddir)/win32/vs9/$(1).vcproj
-$(RM) $(top_builddir)/win32/vs10/$(1).vcxproj
-$(RM) $(top_builddir)/win32/vs10/$(1).vcxproj.filters
-$(RM) $(top_builddir)/win32/vs11/$(1).vcxproj
-$(RM) $(top_builddir)/win32/vs11/$(1).vcxproj.filters
-$(RM) $(top_builddir)/win32/vs12/$(1).vcxproj
-$(RM) $(top_builddir)/win32/vs12/$(1).vcxproj.filters
-$(RM) $(top_builddir)/win32/vs14/$(1).vcxproj
-$(RM) $(top_builddir)/win32/vs14/$(1).vcxproj.filters
for F in $(_proj_files); do \
case $$$$F in \
$(_proj_filters)) \
;; \
*.c|*.cpp|*.cc|*.cxx) \
echo ' <File RelativePath="..\..'$(_proj_subdir)$$$$F'" />' >>$(1).sourcefiles && \
echo ' <ClCompile Include="..\..'$(_proj_subdir)$$$$F'" />' >>$(1).vs10.sourcefiles && \
echo ' <ClCompile Include="..\..'$(_proj_subdir)$$$$F'"><Filter>Source Files</Filter></ClCompile>' >>$(1).vs10.sourcefiles.filters \
;; \
esac; \
done
$(CPP) -P - <$(top_srcdir)/win32/vs9/$(1).vcprojin >$(top_builddir)/win32/vs9/$(1).vcproj
$(CPP) -P - <$(top_srcdir)/win32/vs10/$(1).vcxprojin >$(top_builddir)/win32/vs10/$(1).vcxproj
$(CPP) -P - <$(top_srcdir)/win32/vs10/$(1).vcxproj.filtersin >$(top_builddir)/win32/vs10/$(1).vcxproj.filters
$(RM) $(1).sourcefiles
$(RM) $(1).vs10.sourcefiles
$(RM) $(1).vs10.sourcefiles.filters
$(top_builddir)/win32/vs10/$(1).vs10.headers: $(top_builddir)/win32/vs9/$(1).headers
$(top_builddir)/win32/vs9/$(1).headers: Makefile
-$(RM) $(top_builddir)/win32/vs9/$(1).headers
-$(RM) $(top_builddir)/win32/vs10/$(1).vs10.headers
for F in $(_proj_headers); do \
case $$$$F in \
$(_proj_headers_excludes)) \
;; \
*.h|*.hpp|*.hh|*.hxx) \
echo 'copy ..\..'$(_proj_subdir)$$$$F' $$$$(CopyDir)\include'$(_headers_destdir)'\'$$$$F'
' >>$(top_builddir)/win32/vs9/$(1).headers && \
echo 'copy ..\..'$(_proj_subdir)$$$$F' $$$$(CopyDir)\include'$(_headers_destdir)'\'$$$$F >>$(top_builddir)/win32/vs10/$(1).vs10.headers \
;; \
esac; \
done
$(top_builddir)/win32/vs12/$(1).vcxproj.filters: $(top_builddir)/win32/vs12/$(1).vcxproj
$(top_builddir)/win32/vs12/$(1).vcxproj: Makefile
-$(RM) $(top_builddir)/win32/vs14/$(1).vcxproj
-$(RM) $(top_builddir)/win32/vs14/$(1).vcxproj.filters
for F in $(_proj_files); do \
case $$$$F in \
$(_proj_filters)) \
;; \
*.c|*.cpp|*.cc|*.cxx) \
echo ' <ClCompile Include="..\..'$(_proj_subdir)$$$$F'" />' >>$(1).vs12.sourcefiles && \
echo ' <ClCompile Include="..\..'$(_proj_subdir)$$$$F'"><Filter>Source Files</Filter></ClCompile>' >>$(1).vs12.sourcefiles.filters \
;; \
esac; \
done
$(CPP) -P - <$(top_srcdir)/win32/vs12/$(1).vcxprojin >$(top_builddir)/win32/vs12/$(1).vcxproj
$(CPP) -P - <$(top_srcdir)/win32/vs12/$(1).vcxproj.filtersin >$(top_builddir)/win32/vs12/$(1).vcxproj.filters
$(RM) $(1).vs12.sourcefiles
$(RM) $(1).vs12.sourcefiles.filters
$(top_builddir)/win32/vs12/$(1).vs12.headers: Makefile
-$(RM) $(top_builddir)/win32/vs12/$(1).vs12.headers
for F in $(_proj_headers); do \
case $$$$F in \
$(_proj_headers_excludes)) \
;; \
*.h|*.hpp|*.hh|*.hxx) \
echo 'copy ..\..'$(_proj_subdir)$$$$F' $$$$(CopyDir)\include'$(_headers_destdir)'\'$$$$F >>$(top_builddir)/win32/vs12/$(1).vs12.headers \
;; \
esac; \
done
endef
$(foreach proj,$(MSVCPROJS),$(eval $(call msvcproj-builder,$(proj))))
|