1#**************************************************************
2#
3#  Licensed to the Apache Software Foundation (ASF) under one
4#  or more contributor license agreements.  See the NOTICE file
5#  distributed with this work for additional information
6#  regarding copyright ownership.  The ASF licenses this file
7#  to you under the Apache License, Version 2.0 (the
8#  "License"); you may not use this file except in compliance
9#  with the License.  You may obtain a copy of the License at
10#
11#    http://www.apache.org/licenses/LICENSE-2.0
12#
13#  Unless required by applicable law or agreed to in writing,
14#  software distributed under the License is distributed on an
15#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16#  KIND, either express or implied.  See the License for the
17#  specific language governing permissions and limitations
18#  under the License.
19#
20#**************************************************************
21
22
23
24PRJ=..
25PRJNAME=external
26TARGET=mingwheaders
27
28.INCLUDE :  settings.mk
29
30.IF "$(OS)$(COM)" == "WNTGCC"
31
32# Cygwin and MinGW use different directories for the W32API headers
33.IF "$(USE_MINGW)" == "cygwin"
34MINGW_INCLUDE_DIR=$/usr$/include/mingw/
35MINGW_W32API_INCLUDE_DIR=$/usr$/include/w32api/
36MINGW_W32API_LIB_DIR=$/usr$/include/w32api/
37.ELSE
38MINGW_INCLUDE_DIR=$(COMPATH)$/include/
39MINGW_W32API_INCLUDE_DIR=$(COMPATH)$/include/
40MINGW_W32API_LIB_DIR=$(COMPATH)$/lib/
41.ENDIF
42
43SYS_INCLUDE_DIR=$(MINGW_INCLUDE_DIR)$/sys/
44
45PSDK_INCLUDE_DIR=$(PSDK_HOME)$/include$/
46
47ATL_INCLUDE_DIR=$(PSDK_HOME)$/include$/atl$/
48
49DIRECTXSDK_INCLUDE_DIR=$(DIRECTXSDK_HOME)$/include$/
50
51FILES_TO_COPY_FROM_MINGW= \
52	excpt.h \
53	 tchar.h
54
55FILES_TO_COPY_FROM_W32API= \
56	amvideo.h \
57	basetyps.h \
58	objidl.h \
59	specstrings.h \
60	uxtheme.h \
61	winbase.h \
62	windef.h \
63	wininet.h \
64	winver.h \
65	wtypes.h
66
67FILES_TO_COPY_FROM_SYS= \
68	stat.h
69
70FILES_TO_COPY_FROM_PSDK= \
71	adoctint.h \
72	adodef.h \
73	adoguids.h \
74	adoint.h \
75	bcrypt.h \
76	commctrl.h \
77	control.h \
78	dispex.h \
79	filter.h \
80	gdiplusbitmap.h \
81	gdiplusbrush.h \
82	gdiplusenums.h \
83	gdiplusfont.h \
84	gdiplusheaders.h \
85	gdiplusimageattributes.h \
86	gdiplusimaging.h \
87	gdiplusmatrix.h \
88	gdipluspath.h \
89	gdipluspen.h \
90	gdiplusregion.h \
91	gdiplusstringformat.h \
92	imm.h \
93	imagehlp.h \
94	mapiwin.h \
95	msdasc.h \
96	msi.h \
97	msiquery.h \
98	multimon.h \
99	ntquery.h \
100	oaidl.h \
101	ocidl.h \
102	oleauto.h \
103	olectl.h \
104	oledb.h \
105	oleidl.h \
106	propidl.h \
107	propkeydef.h \
108	propsys.h \
109	propvarutil.h \
110	shlobj.h \
111	shobjidl.h \
112	shtypes.h \
113	sspi.h \
114	strmif.h \
115	strsafe.h \
116	structuredquery.h \
117	urlmon.h \
118	wincrypt.h \
119	winerror.h \
120	wingdi.h \
121	wintrust.h \
122	winuser.h \
123	wspiapi.h \
124	exdispid.h \
125	dshow.h \
126	gdiplus.h \
127	msxml.h \
128	ncrypt.h \
129	shlguid.h \
130	transact.h
131
132.IF "$(DISABLE_ATL)"==""
133MINGWHEADER_ATL_PATCH_TARGET=$(MISC)$/mingwheader_atl_patch
134MINGWHEADER_ATL_COPY_TARGET=$(MISC)$/mingwheader_atl_copy
135FILES_TO_COPY_FROM_ATL= \
136	atlbase.h \
137	atlcom.h \
138	atlconv.h \
139	atlctl.h \
140	atlwin.h \
141	statreg.h
142.ENDIF
143
144FILES_TO_COPY_FROM_DIRECTXSDK= \
145	d3dtypes.h \
146	d3dx9core.h \
147	d3dx9math.h \
148	d3dx9math.inl \
149	dxtrans.h \
150	d3dx9.h
151
152$(MISC)$/mingwheader_patch_all : $(MISC)$/mingwheader_patch $(MINGWHEADER_ATL_PATCH_TARGET) $(LB)$/libmsvcrt.a
153
154$(MISC)$/mingwheader_patch : $(MISC)$/mingwheader_copy
155	patch -bd $(MISC)$/mingw -p0 -N -f -Z <mingw_headers.patch
156	$(TOUCH) $(MISC)$/mingwheader_patch
157
158.IF "$(DISABLE_ATL)"==""
159$(MINGWHEADER_ATL_PATCH_TARGET) : $(MINGWHEADER_ATL_COPY_TARGET)
160	patch -bd $(MISC)$/mingw -p0 -N -f -Z <mingw_atl_headers.patch
161	$(TOUCH) $(MINGWHEADER_ATL_PATCH_TARGET)
162.ENDIF
163
164$(MISC)$/mingwheader_copy:
165	$(MKDIRHIER) $(MISC)$/mingw$/include
166	$(MKDIRHIER) $(MISC)$/mingw$/include/sys
167	$(COPY) $(FILES_TO_COPY_FROM_MINGW:^$(MINGW_INCLUDE_DIR)) $(MISC)$/mingw$/include
168	$(COPY) $(FILES_TO_COPY_FROM_W32API:^$(MINGW_W32API_INCLUDE_DIR)) $(MISC)$/mingw$/include
169	$(COPY) $(FILES_TO_COPY_FROM_SYS:^$(SYS_INCLUDE_DIR)) $(MISC)$/mingw$/include$/sys
170	$(COPY) $(FILES_TO_COPY_FROM_PSDK:^$(PSDK_INCLUDE_DIR)) $(MISC)$/mingw$/include
171	$(COPY) $(FILES_TO_COPY_FROM_DIRECTXSDK:^$(DIRECTXSDK_INCLUDE_DIR)) $(MISC)$/mingw$/include
172	$(TOUCH) $(MISC)$/mingwheader_copy
173
174.IF "$(DISABLE_ATL)"==""
175$(MINGWHEADER_ATL_COPY_TARGET):
176	$(MKDIRHIER) $(MISC)$/mingw$/include/atl
177	$(COPY) $(FILES_TO_COPY_FROM_ATL:^$(ATL_INCLUDE_DIR)) $(MISC)$/mingw$/include$/atl
178 	$(TOUCH) $(MINGWHEADER_ATL_COPY_TARGET)
179.ENDIF
180
181$(LB)$/libmsvcrt.a:
182.IF "$(USE_MINGW)" == "cygwin"
183	$(COPY) $(COMPATH)$/lib/mingw/libmsvcrt.a $(LB)$/libmsvcrt_orig.a
184.ELSE
185	$(COPY) $(COMPATH)$/lib/libmsvcrt.a $(LB)$/libmsvcrt_orig.a
186.ENDIF
187	cd $(LB) && ar -x libmsvcrt_orig.a ofmt_stub.o
188	ar -d $(LB)$/libmsvcrt_orig.a ofmt_stub.o
189	nm -g --defined-only $(LB)$/libmsvcrt_orig.a > $(MISC)$/msvcrt.nm
190	echo EXPORTS > $(MISC)$/msvcrt.def
191	sed -ne 's/.* T _//p' $(MISC)$/msvcrt.nm | sort >> $(MISC)$/msvcrt.def
192	-sed -ne 's/.* I __imp__//p' $(MISC)$/msvcrt.nm | sort | diff - $(MISC)$/msvcrt.def | \
193		sed -ne 's/^< \(.*\)$/\1 DATA/p' > $(MISC)$/msvcrtdata.def
194	cat $(MISC)$/msvcrtdata.def >> $(MISC)$/msvcrt.def
195	dlltool --dllname msvcrt.dll --input-def=$(MISC)$/msvcrt.def --kill-at --output-lib=$(LB)$/libmsvcrt.a
196	cd $(LB) && ar -rs libmsvcrt.a ofmt_stub.o
197
198clean:
199	-$(RM) $(MISC)$/mingw$/include$/*.h
200	-$(RM) $(MISC)$/mingwheader_copy
201	-$(RM) $(MISC)$/mingwheader_patch
202
203.ENDIF
204
205.INCLUDE :  target.mk
206
207