atk/Makefile.am: Dist atk.rc
[platform/upstream/atk.git] / win32 / 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.
7
8 # * Input variables:
9 #
10 #   MSVCPROJS - List of Projects that should be generated
11 #
12 # * Simple tutorial
13 #
14 # Add this to Makefile.am where your library/program is built:
15 #   include $(top_srcdir)/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>
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)/win32/vs9/YourProject.vcproj    \
26 #       $(top_builddir)/win32/vs9/YourProject.headers   # if headers need to be installed
27 #
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
32
33 # Private functions
34
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))
42
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)
46
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)
50
51 _headers_dest_posix=$(subst $(includedir),,$($(_proj_name)_HEADERS_DIR))
52 _headers_destdir=$(subst /,\\,$(_headers_dest_posix))
53
54 #
55 # Creates Visual Studio 2008/2010 projects from items passed in from autotools files
56 # $(1) - Base Name of the MSVC project files (outputs)
57 #
58
59 define msvcproj-builder
60
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
66
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
77
78
79         for F in $(_proj_files); do \
80                 case $$$$F in \
81                 $(_proj_filters)) \
82                         ;; \
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 \
87                         ;; \
88                 esac;   \
89         done
90
91
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
98
99 $(top_builddir)/win32/vs10/$(1).vs10.headers: $(top_builddir)/win32/vs9/$(1).headers
100
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
104
105         for F in $(_proj_headers); do \
106                 case $$$$F in \
107                 $(_proj_headers_excludes)) \
108                         ;; \
109                 *.h|*.hpp|*.hh|*.hxx) \
110                         echo 'copy ..\..'$(_proj_subdir)$$$$F' $$$$(CopyDir)\include'$(_headers_destdir)'\'$$$$F'&#x0D;&#x0A;' >>$(top_builddir)/win32/vs9/$(1).headers && \
111                         echo 'copy ..\..'$(_proj_subdir)$$$$F' $$$$(CopyDir)\include'$(_headers_destdir)'\'$$$$F >>$(top_builddir)/win32/vs10/$(1).vs10.headers \
112                         ;; \
113                 esac;   \
114         done
115
116 $(top_builddir)/win32/vs12/$(1).vcxproj.filters: $(top_builddir)/win32/vs12/$(1).vcxproj
117
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
121
122         for F in $(_proj_files); do \
123                 case $$$$F in \
124                 $(_proj_filters)) \
125                         ;; \
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 \
129                         ;; \
130                 esac;   \
131         done
132
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
137
138 $(top_builddir)/win32/vs12/$(1).vs12.headers: Makefile
139         -$(RM) $(top_builddir)/win32/vs12/$(1).vs12.headers
140
141         for F in $(_proj_headers); do \
142                 case $$$$F in \
143                 $(_proj_headers_excludes)) \
144                         ;; \
145                 *.h|*.hpp|*.hh|*.hxx) \
146                         echo 'copy ..\..'$(_proj_subdir)$$$$F' $$$$(CopyDir)\include'$(_headers_destdir)'\'$$$$F >>$(top_builddir)/win32/vs12/$(1).vs12.headers \
147                         ;; \
148                 esac;   \
149         done
150
151 endef
152
153 $(foreach proj,$(MSVCPROJS),$(eval $(call msvcproj-builder,$(proj))))