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.
10 # MSVCPROJS - List of Projects that should be generated
14 # Add this to Makefile.am where your library/program is built:
15 # include <this Makefile.msvcproj>
16 # MSVCPROJS = YourProject (can be multiple projects in a single srcdir)
17 # YourProject_FILES = $(libyourlib_1_0_SOURCES)
18 # YourProject_EXCLUDES = ... # list of sources to exclude, separated by '|', wildcards allowed; use random unsed value if none
19 # (the following 3 lines if headers need to be installed)
20 # YourProject_HEADERS_DIR = $(libyourlibincludedir)
21 # YourProject_HEADERS_INST = $(libyourlib_1_0_HEADERS)
22 # YourProject_HEADERS_EXCLUDES = ... # <list of headers to exclude from installation, separated by '|', wildcards allowed; use random unsed value if none>
24 # dist-hook: \ # (or add to it if it is already there, note the vs9 items will also call the vs10 items in the process)
25 # $(top_builddir)/win32/vs9/YourProject.vcproj \
26 # $(top_builddir)/win32/vs9/YourProject.headers # if headers need to be installed
28 # --or, if Visual Studio 2013 or later is required--
29 # dist-hook: \ # (or add to it if it is already there, this does -not- call other vs items in the process)
30 # $(top_builddir)/win32/vs12/YourProject.vcxproj \
31 # $(top_builddir)/win32/vs12/YourProject.vs12.headers # if headers need to be installed
35 ## Transform the MSVC project filename (no filename extensions) to something which can reference through a variable
36 ## without automake/make complaining, eg Gtk-2.0 -> Gtk_2_0
37 _proj_name=$(subst /,_,$(subst -,_,$(subst .,_,$(1))))
38 _proj_path_raw:=$(subst $(abs_top_srcdir),,$(abs_srcdir))
39 _proj_path=$(subst /,\\,$(_proj_path_raw))
40 _proj_subdir_int=$(subst \\\\,\\,\\$(_proj_path)\\)
41 _proj_subdir=$(subst \\.\\,\\,$(_proj_subdir_int))
43 _proj_files_raw=$(subst /,\\,$($(_proj_name)_FILES))
44 _proj_files=$(subst $(srcdir)\\,,$(subst $(builddir)\\,,$(subst $(top_builddir)\\$(_proj_path)\\,\\,$(_proj_files_raw))))
45 _proj_filters=$($(_proj_name)_EXCLUDES)
47 _proj_headers_raw=$(subst /,\\,$($(_proj_name)_HEADERS_INST))
48 _proj_headers=$(subst $(srcdir)\\,,$(subst $(builddir)\\,,$(subst $(top_builddir)\\$(_proj_path)\\,\\,$(_proj_headers_raw))))
49 _proj_headers_excludes=$($(_proj_name)_HEADERS_EXCLUDES)
51 _headers_dest_posix=$(subst $(includedir),,$($(_proj_name)_HEADERS_DIR))
52 _headers_destdir=$(subst /,\\,$(_headers_dest_posix))
55 # Creates Visual Studio 2008/2010 projects from items passed in from autotools files
56 # $(1) - Base Name of the MSVC project files (outputs)
59 define msvcproj-builder
61 $(top_builddir)/win32/vs10/$(1).vcxproj: $(top_builddir)/win32/vs9/$(1).vcproj
62 $(top_builddir)/win32/vs10/$(1).vcxproj.filters: $(top_builddir)/win32/vs9/$(1).vcproj
63 $(1).sourcefiles: $(top_builddir)/win32/vs9/$(1).vcproj
64 $(1).vs10.sourcefiles: $(top_builddir)/win32/vs9/$(1).vcproj
65 $(1).vs10.sourcefiles.filters: $(top_builddir)/win32/vs9/$(1).vcproj
67 $(top_builddir)/win32/vs9/$(1).vcproj: Makefile
68 -$(RM) $(top_builddir)/win32/vs9/$(1).vcproj
69 -$(RM) $(top_builddir)/win32/vs10/$(1).vcxproj
70 -$(RM) $(top_builddir)/win32/vs10/$(1).vcxproj.filters
71 -$(RM) $(top_builddir)/win32/vs11/$(1).vcxproj
72 -$(RM) $(top_builddir)/win32/vs11/$(1).vcxproj.filters
73 -$(RM) $(top_builddir)/win32/vs12/$(1).vcxproj
74 -$(RM) $(top_builddir)/win32/vs12/$(1).vcxproj.filters
75 -$(RM) $(top_builddir)/win32/vs14/$(1).vcxproj
76 -$(RM) $(top_builddir)/win32/vs14/$(1).vcxproj.filters
79 for F in $(_proj_files); do \
83 *.c|*.cpp|*.cc|*.cxx) \
84 echo ' <File RelativePath="..\..'$(_proj_subdir)$$$$F'" />' >>$(1).sourcefiles && \
85 echo ' <ClCompile Include="..\..'$(_proj_subdir)$$$$F'" />' >>$(1).vs10.sourcefiles && \
86 echo ' <ClCompile Include="..\..'$(_proj_subdir)$$$$F'"><Filter>Source Files</Filter></ClCompile>' >>$(1).vs10.sourcefiles.filters \
92 $(CPP) -P - <$(top_srcdir)/win32/vs9/$(1).vcprojin >$(top_builddir)/win32/vs9/$(1).vcproj
93 $(CPP) -P - <$(top_srcdir)/win32/vs10/$(1).vcxprojin >$(top_builddir)/win32/vs10/$(1).vcxproj
94 $(CPP) -P - <$(top_srcdir)/win32/vs10/$(1).vcxproj.filtersin >$(top_builddir)/win32/vs10/$(1).vcxproj.filters
95 $(RM) $(1).sourcefiles
96 $(RM) $(1).vs10.sourcefiles
97 $(RM) $(1).vs10.sourcefiles.filters
99 $(top_builddir)/win32/vs10/$(1).vs10.headers: $(top_builddir)/win32/vs9/$(1).headers
101 $(top_builddir)/win32/vs9/$(1).headers: Makefile
102 -$(RM) $(top_builddir)/win32/vs9/$(1).headers
103 -$(RM) $(top_builddir)/win32/vs10/$(1).vs10.headers
105 for F in $(_proj_headers); do \
107 $(_proj_headers_excludes)) \
109 *.h|*.hpp|*.hh|*.hxx) \
110 echo 'copy ..\..'$(_proj_subdir)$$$$F' $$$$(CopyDir)\include'$(_headers_destdir)'\'$$$$F'
' >>$(top_builddir)/win32/vs9/$(1).headers && \
111 echo 'copy ..\..'$(_proj_subdir)$$$$F' $$$$(CopyDir)\include'$(_headers_destdir)'\'$$$$F >>$(top_builddir)/win32/vs10/$(1).vs10.headers \
116 $(top_builddir)/win32/vs12/$(1).vcxproj.filters: $(top_builddir)/win32/vs12/$(1).vcxproj
118 $(top_builddir)/win32/vs12/$(1).vcxproj: Makefile
119 -$(RM) $(top_builddir)/win32/vs14/$(1).vcxproj
120 -$(RM) $(top_builddir)/win32/vs14/$(1).vcxproj.filters
122 for F in $(_proj_files); do \
126 *.c|*.cpp|*.cc|*.cxx) \
127 echo ' <ClCompile Include="..\..'$(_proj_subdir)$$$$F'" />' >>$(1).vs12.sourcefiles && \
128 echo ' <ClCompile Include="..\..'$(_proj_subdir)$$$$F'"><Filter>Source Files</Filter></ClCompile>' >>$(1).vs12.sourcefiles.filters \
133 $(CPP) -P - <$(top_srcdir)/win32/vs12/$(1).vcxprojin >$(top_builddir)/win32/vs12/$(1).vcxproj
134 $(CPP) -P - <$(top_srcdir)/win32/vs12/$(1).vcxproj.filtersin >$(top_builddir)/win32/vs12/$(1).vcxproj.filters
135 $(RM) $(1).vs12.sourcefiles
136 $(RM) $(1).vs12.sourcefiles.filters
138 $(top_builddir)/win32/vs12/$(1).vs12.headers: Makefile
139 -$(RM) $(top_builddir)/win32/vs12/$(1).vs12.headers
141 for F in $(_proj_headers); do \
143 $(_proj_headers_excludes)) \
145 *.h|*.hpp|*.hh|*.hxx) \
146 echo 'copy ..\..'$(_proj_subdir)$$$$F' $$$$(CopyDir)\include'$(_headers_destdir)'\'$$$$F >>$(top_builddir)/win32/vs12/$(1).vs12.headers \
153 $(foreach proj,$(MSVCPROJS),$(eval $(call msvcproj-builder,$(proj))))