Debian Codegraph @

build/Makefile.msvcproj

raw
1 # Author: Fan, Chun-wei
2 # Common Autotools file used to generate Visual Studio 2008+
3 # Projects from their templates
4
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/.
8
9 # * Input variables:
10 #
11 # MSVCPROJS - List of Projects that should be generated
12 #
13 # * Simple tutorial
14 #
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 # 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>
23 #
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)/build/win32/vs9/YourProject.vcproj \
26 # $(top_builddir)/build/win32/vs9/YourProject.headers
27
28
29 # Private functions
30
31 ## Transform the MSVC project filename (no filename extensions) to something which can reference through a variable
32 ## without automake/make complaining, eg Gtk-2.0 -> Gtk_2_0
33 _proj_name=$(subst /,_,$(subst -,_,$(subst .,_,$(1))))
34 _proj_path_raw:=$(subst $(abs_top_srcdir),,$(abs_srcdir))
35 _proj_path=$(subst /,\\,$(_proj_path_raw))
36 _proj_subdir_int=$(subst \\\\,\\,\\$(_proj_path)\\)
37 _proj_subdir=$(subst \\.\\,\\,$(_proj_subdir_int))
38
39 _proj_files_raw=$(subst /,\\,$($(_proj_name)_FILES))
40 _proj_files=$(subst $(srcdir)\\,,$(subst $(builddir)\\,,$(subst $(top_builddir)\\$(_proj_path)\\,\\,$(_proj_files_raw))))
41 _proj_filters=$($(_proj_name)_EXCLUDES)
42
43 _proj_headers_raw=$(subst /,\\,$($(_proj_name)_HEADERS_INST))
44 _proj_headers=$(subst $(srcdir)\\,,$(subst $(builddir)\\,,$(subst $(top_builddir)\\$(_proj_path)\\,\\,$(_proj_headers_raw))))
45 _proj_headers_excludes=$($(_proj_name)_HEADERS_EXCLUDES)
46
47 _headers_dest_posix=$(subst $(includedir),,$($(_proj_name)_HEADERS_DIR))
48 _headers_destdir=$(subst /,\\,$(_headers_dest_posix))
49
50 #
51 # Creates Visual Studio 2008/2010 projects from items passed in from autotools files
52 # $(1) - Base Name of the MSVC project files (outputs)
53 #
54
55 define msvcproj-builder
56
57 $(top_builddir)/build/win32/vs10/$(1).vcxproj: $(top_builddir)/build/win32/vs9/$(1).vcproj
58 $(top_builddir)/build/win32/vs10/$(1).vcxproj.filters: $(top_builddir)/build/win32/vs9/$(1).vcproj
59 $(1).sourcefiles: $(top_builddir)/build/win32/vs9/$(1).vcproj
60 $(1).vs10.sourcefiles: $(top_builddir)/build/win32/vs9/$(1).vcproj
61 $(1).vs10.sourcefiles.filters: $(top_builddir)/build/win32/vs9/$(1).vcproj
62
63 $(top_builddir)/build/win32/vs9/$(1).vcproj: Makefile
64 -$(RM) $(top_builddir)/build/win32/vs9/$(1).vcproj
65 -$(RM) $(top_builddir)/build/win32/vs10/$(1).vcxproj
66 -$(RM) $(top_builddir)/build/win32/vs10/$(1).vcxproj.filters
67 -$(RM) $(top_builddir)/build/win32/vs11/$(1).vcxproj
68 -$(RM) $(top_builddir)/build/win32/vs11/$(1).vcxproj.filters
69 -$(RM) $(top_builddir)/build/win32/vs12/$(1).vcxproj
70 -$(RM) $(top_builddir)/build/win32/vs12/$(1).vcxproj.filters
71 -$(RM) $(top_builddir)/build/win32/vs14/$(1).vcxproj
72 -$(RM) $(top_builddir)/build/win32/vs14/$(1).vcxproj.filters
73 -$(RM) $(top_builddir)/build/win32/vs15/$(1).vcxproj
74 -$(RM) $(top_builddir)/build/win32/vs15/$(1).vcxproj.filters
75
76
77 for F in $(_proj_files); do \
78 case $$$$F in \
79 $(_proj_filters)) \
80 ;; \
81 *.c|*.cpp|*.cc|*.cxx) \
82 echo ' <File RelativePath="..\..\..'$(_proj_subdir)$$$$F'" />' >>$(1).sourcefiles && \
83 echo ' <ClCompile Include="..\..\..'$(_proj_subdir)$$$$F'" />' >>$(1).vs10.sourcefiles && \
84 echo ' <ClCompile Include="..\..\..'$(_proj_subdir)$$$$F'"><Filter>Source Files</Filter></ClCompile>' >>$(1).vs10.sourcefiles.filters \
85 ;; \
86 esac; \
87 done
88
89
90 $(CPP) -P - <$(top_srcdir)/build/win32/vs9/$(1).vcprojin >$(top_builddir)/build/win32/vs9/$(1).vcproj
91 $(CPP) -P - <$(top_srcdir)/build/win32/vs10/$(1).vcxprojin >$(top_builddir)/build/win32/vs10/$(1).vcxproj
92 $(CPP) -P - <$(top_srcdir)/build/win32/vs10/$(1).vcxproj.filtersin >$(top_builddir)/build/win32/vs10/$(1).vcxproj.filters
93 $(RM) $(1).sourcefiles
94 $(RM) $(1).vs10.sourcefiles
95 $(RM) $(1).vs10.sourcefiles.filters
96
97 $(top_builddir)/build/win32/vs10/$(1).vs10.headers: $(top_builddir)/build/win32/vs9/$(1).headers
98
99 $(top_builddir)/build/win32/vs9/$(1).headers: Makefile
100 -$(RM) $(top_builddir)/build/win32/vs9/$(1).headers
101 -$(RM) $(top_builddir)/build/win32/vs10/$(1).vs10.headers
102
103 for F in $(_proj_headers); do \
104 case $$$$F in \
105 $(_proj_headers_excludes)) \
106 ;; \
107 *.h|*.hpp|*.hh|*.hxx) \
108 echo 'copy ..\..\..'$(_proj_subdir)$$$$F' $$$$(CopyDir)\include'$(_headers_destdir)'\'$$$$F'&#x0D;&#x0A;' >>$(top_builddir)/build/win32/vs9/$(1).headers && \
109 echo 'copy ..\..\..'$(_proj_subdir)$$$$F' $$$$(CopyDir)\include'$(_headers_destdir)'\'$$$$F >>$(top_builddir)/build/win32/vs10/$(1).vs10.headers \
110 ;; \
111 esac; \
112 done
113
114 endef
115
116 $(foreach proj,$(MSVCPROJS),$(eval $(call msvcproj-builder,$(proj))))