Makefile.msvcproj, Makefile-newvs.am: Update from GLib
[platform/upstream/atk.git] / build / Makefile.msvcproj
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 #   (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>
24 #
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
28 #
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
33
34 # Private functions
35
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))
43
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)
47
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)
51
52 _headers_dest_posix=$(subst $(includedir),,$($(_proj_name)_HEADERS_DIR))
53 _headers_destdir=$(subst /,\\,$(_headers_dest_posix))
54
55 #
56 # Creates Visual Studio 2008/2010 projects from items passed in from autotools files
57 # $(1) - Base Name of the MSVC project files (outputs)
58 #
59
60 define msvcproj-builder
61
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
67
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
78
79
80         for F in $(_proj_files); do \
81                 case $$$$F in \
82                 $(_proj_filters)) \
83                         ;; \
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 \
88                         ;; \
89                 esac;   \
90         done
91
92
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
99
100 $(top_builddir)/build/win32/vs10/$(1).vs10.headers: $(top_builddir)/build/win32/vs9/$(1).headers
101
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
105
106         for F in $(_proj_headers); do \
107                 case $$$$F in \
108                 $(_proj_headers_excludes)) \
109                         ;; \
110                 *.h|*.hpp|*.hh|*.hxx) \
111                         echo 'copy ..\..\..'$(_proj_subdir)$$$$F' $$$$(CopyDir)\include'$(_headers_destdir)'\'$$$$F'&#x0D;&#x0A;' >>$(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 \
113                         ;; \
114                 esac;   \
115         done
116
117 $(top_builddir)/build/win32/vs12/$(1).vcxproj.filters: $(top_builddir)/build/win32/vs12/$(1).vcxproj
118
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
122
123         for F in $(_proj_files); do \
124                 case $$$$F in \
125                 $(_proj_filters)) \
126                         ;; \
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 \
130                         ;; \
131                 esac;   \
132         done
133
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
138
139 $(top_builddir)/build/win32/vs12/$(1).vs12.headers: Makefile
140         -$(RM) $(top_builddir)/build/win32/vs12/$(1).vs12.headers
141
142         for F in $(_proj_headers); do \
143                 case $$$$F in \
144                 $(_proj_headers_excludes)) \
145                         ;; \
146                 *.h|*.hpp|*.hh|*.hxx) \
147                         echo 'copy ..\..\..'$(_proj_subdir)$$$$F' $$$$(CopyDir)\include'$(_headers_destdir)'\'$$$$F >>$(top_builddir)/build/win32/vs12/$(1).vs12.headers \
148                         ;; \
149                 esac;   \
150         done
151
152 endef
153
154 $(foreach proj,$(MSVCPROJS),$(eval $(call msvcproj-builder,$(proj))))