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