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
7 # $(srcroot)/build/, except those that have their main sources
8 # in their $(srcroot), or those that have their autotools build
9 # files in $(srcroot). Those that should not use this include:
10 # gobject-introspection, librsvg, instead they would currently
11 # need a modified version of this.
15 # MSVCPROJS - List of Projects that should be generated
19 # Add this to Makefile.am where your library/program is built:
20 # include $(top_srcdir)/build/Makefile.msvcproj
21 # MSVCPROJS = YourProject (can be multiple projects in a single srcdir)
22 # YourProject_FILES = $(libyourlib_1_0_SOURCES)
23 # YourProject_EXCLUDES = ... # list of sources to exclude, separated by '|', wildcards allowed; use random unsed value if none
24 # YourProject_HEADERS_DIR = $(libyourlibincludedir)
25 # YourProject_HEADERS_INST = $(libyourlib_1_0_HEADERS)
26 # YourProject_HEADERS_EXCLUDES = ... # <list of headers to exclude from installation, separated by '|', wildcards allowed; use random unsed value if none>
28 # dist-hook: \ # (or add to it if it is already there, note the vs9 items will also call the vs10 items in the process)
29 # $(top_builddir)/build/win32/vs9/YourProject.vcproj \
30 # $(top_builddir)/build/win32/vs9/YourProject.headers
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=$(if $(ifeq $(_proj_path),\.),\\,\\$(_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)/build/win32/vs10/$(1).vcxproj: $(top_builddir)/build/win32/vs9/$(1).vcproj
62 $(top_builddir)/build/win32/vs10/$(1).vcxproj.filters: $(top_builddir)/build/win32/vs9/$(1).vcproj
63 $(1).sourcefiles: $(top_builddir)/build/win32/vs9/$(1).vcproj
64 $(1).vs10.sourcefiles: $(top_builddir)/build/win32/vs9/$(1).vcproj
65 $(1).vs10.sourcefiles.filters: $(top_builddir)/build/win32/vs9/$(1).vcproj
67 $(top_builddir)/build/win32/vs9/$(1).vcproj:
68 -$(RM) $(top_builddir)/build/win32/vs9/$(1).vcproj
69 -$(RM) $(top_builddir)/build/win32/vs10/$(1).vcxproj
70 -$(RM) $(top_builddir)/build/win32/vs10/$(1).vcxproj.filters
72 for F in $(_proj_files); do \
76 *.c|*.cpp|*.cc|*.cxx) \
77 echo ' <File RelativePath="..\..\..'$(_proj_subdir)$$$$F'" />' >>$(1).sourcefiles && \
78 echo ' <ClCompile Include="..\..\..'$(_proj_subdir)$$$$F'" />' >>$(1).vs10.sourcefiles && \
79 echo ' <ClCompile Include="..\..\..'$(_proj_subdir)$$$$F'"><Filter>Source Files</Filter></ClCompile>' >>$(1).vs10.sourcefiles.filters \
85 $(CPP) -P - <$(top_srcdir)/build/win32/vs9/$(1).vcprojin >$(top_builddir)/build/win32/vs9/$(1).vcproj
86 $(CPP) -P - <$(top_srcdir)/build/win32/vs10/$(1).vcxprojin >$(top_builddir)/build/win32/vs10/$(1).vcxproj
87 $(CPP) -P - <$(top_srcdir)/build/win32/vs10/$(1).vcxproj.filtersin >$(top_builddir)/build/win32/vs10/$(1).vcxproj.filters
88 $(RM) $(1).sourcefiles
89 $(RM) $(1).vs10.sourcefiles
90 $(RM) $(1).vs10.sourcefiles.filters
92 $(top_builddir)/build/win32/vs10/$(1).vs10.headers: $(top_builddir)/build/win32/vs9/$(1).headers
94 $(top_builddir)/build/win32/vs9/$(1).headers:
95 -$(RM) $(top_builddir)/build/win32/vs9/$(1).headers
96 -$(RM) $(top_builddir)/build/win32/vs10/$(1).vs10.headers
98 for F in $(_proj_headers); do \
100 $(_proj_headers_excludes)) \
102 *.h|*.hpp|*.hh|*.hxx) \
103 echo 'copy ..\..\..'$(_proj_subdir)$$$$F' $$$$(CopyDir)\include'$(_headers_destdir)'\'$$$$F'
' >>$(top_builddir)/build/win32/vs9/$(1).headers && \
104 echo 'copy ..\..\..'$(_proj_subdir)$$$$F' $$$$(CopyDir)\include'$(_headers_destdir)'\'$$$$F >>$(top_builddir)/build/win32/vs10/$(1).vs10.headers \
111 $(foreach proj,$(MSVCPROJS),$(eval $(call msvcproj-builder,$(proj))))