1 # Makefile.in for the winsup/mingw directory.
2 # Copyright (c) 1995-2008, 1996, 1997, 1998 Cygnus Solutions
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 # This makefile requires GNU make.
20 PACKAGE = mingw-runtime
21 VERSION = @PACKAGE_VERSION@
28 host_alias = @host_alias@
29 build_alias = @build_alias@
30 target_alias = @target_alias@
31 with_cross_host = @with_cross_host@
33 conf_prefix = @prefix@
35 program_transform_name = @program_transform_name@
36 exec_prefix = @exec_prefix@
39 ifneq (,$(findstring cygwin,$(target_alias)))
40 mandir = $(prefix)/share/man
46 manpage_transform = @mingw_manpage_transform@
47 ifeq ($(target_alias),$(host_alias))
48 ifeq ($(build_alias),$(host_alias))
49 tooldir:=$(exec_prefix)
51 tooldir:=$(exec_prefix)/$(target_alias)
54 tooldir:=$(exec_prefix)/$(target_alias)
58 includedir = @includedir@
59 ifneq (,$(findstring cygwin,$(target_alias)))
60 inst_bindir:=$(tooldir)/bin
61 inst_includedir:=$(tooldir)/include/mingw
62 inst_libdir:=$(tooldir)/lib/mingw
63 inst_docdir:=$(tooldir)/share/doc/mingw-runtime
65 ifneq (,$(with_cross_host))
66 inst_bindir:=$(tooldir)/bin
67 inst_includedir:=$(tooldir)/include
68 inst_libdir:=$(tooldir)/lib
69 inst_docdir:=$(tooldir)/share/doc/mingw-runtime
71 inst_bindir:=$(bindir)
72 inst_includedir:=$(includedir)
73 inst_libdir:=$(libdir)
74 inst_docdir:=$(prefix)/doc/mingw-runtime
78 # The Mingw headers are installed under a subdirectory of
79 # $(tooldir)/include when configuring in Cygwin.
80 HEADER_SUBDIR = @HEADER_SUBDIR@
85 INSTALL_DATA = @INSTALL_DATA@
86 INSTALL_PROGRAM = @INSTALL_PROGRAM@
87 mkinstalldirs = $(SHELL) @MKINSTALLDIRS@
90 ifneq (,$(findstring cygwin,$(target_alias)))
91 override CC := ${filter-out -L% -B%,${shell echo $(CC) | sed -e 's%\(-isystem\|-iwithprefixbefore\) *[^ ]*\( \|$$\)% %g'}}
93 # FIXME: Which is it, CC or CC_FOR_TARGET?
99 # compiling with Cygwin?
100 MNO_CYGWIN = @MNO_CYGWIN@
107 # Either crtdll (CRT_ID 1) or msvcrt (CRT_ID 2).
111 # Needed for threading dll.
112 THREAD_DLL = @THREAD_DLL@
113 THREAD_DLL_VERSION = 10
114 THREAD_DLL_NAME = $(THREAD_DLL)$(THREAD_DLL_VERSION).dll
119 W32API_INCLUDE = @W32API_INCLUDE@
120 INCLUDES = -I$(srcdir)/include \
121 -I$(srcdir)/../include \
123 -iwithprefixbefore include
124 ALL_CFLAGS = $(CFLAGS) $(INCLUDES) $(W32API_INCLUDE) $(MNO_CYGWIN)
125 ALL_CXXFLAGS = $(CXXFLAGS) $(INCLUDES) -nostdinc++ $(W32API_INCLUDE) $(MNO_CYGWIN)
134 DLLTOOL_FOR_TARGET = $(DLLTOOL)
135 DLLTOOL_FLAGS = --as $(AS_FOR_TARGET)
137 DLLWRAP_FOR_TARGET = $(DLLWRAP)
138 DLLWRAP_FLAGS = --dlltool $(DLLTOOL) --as $(AS) --driver-name $(CC)
151 CFLAGS="$(CFLAGS) $(CFLAGS_COMMON) $(CFLAGS_CONFIG)" \
152 CXXFLAGS="$(CXXFLAGS) $(CFLAGS_COMMON) $(CFLAGS_CONFIG)" \
153 EXE_LDFLAGS="$(EXE_LDFLAGS)" \
157 DLLTOOL="$(DLLTOOL)" \
158 exec_prefix="$(exec_prefix)" \
161 tooldir="$(tooldir)" \
162 datadir="$(datadir)" \
163 infodir="$(infodir)" \
164 includedir="$(includedir)" \
165 inst_bindir="$(inst_bindir)" \
166 inst_includedir="$(inst_includedir)" \
167 inst_libdir="$(inst_libdir)" \
168 inst_docdir="$(inst_docdir)" \
170 target_alias="$(target_alias)" \
172 TARFLAGS="$(TARFLAGS)" \
173 TARFILEEXT="$(TARFILEEXT)"
175 CRT0S = crt1.o dllcrt1.o crt2.o dllcrt2.o CRT_noglob.o crtmt.o crtst.o \
176 CRT_fp8.o CRT_fp10.o txtmode.o binmode.o
177 MINGW_OBJS = CRTglob.o CRTfmode.o CRTinit.o dllmain.o gccmain.o \
178 main.o crtst.o mthr_stub.o CRT_fp10.o txtmode.o \
179 pseudo-reloc.o pseudo-reloc-list.o cpu_features.o
181 MOLD_OBJS = isascii.o iscsym.o iscsymf.o toascii.o \
182 strcasecmp.o strncasecmp.o wcscmpi.o
185 libmsvcrt.a libmsvcrtd.a \
186 libmsvcr70.a libmsvcr70d.a \
187 libmsvcr71.a libmsvcr71d.a \
188 libmsvcr80.a libmsvcr80d.a \
189 libmsvcr90.a libmsvcr90d.a \
192 libmoldname.a libmoldnamed.a \
193 libmoldname70.a libmoldname70d.a \
194 libmoldname71.a libmoldname71d.a \
195 libmoldname80.a libmoldname80d.a \
196 libmoldname90.a libmoldname90d.a \
200 DLLS = $(THREAD_DLL_NAME)
202 INSTDOCS = CONTRIBUTORS \
206 SRCDIST_FILES = CRT_noglob.c CRTfmode.c CRTglob.c CRTinit.c ChangeLog \
207 Makefile.in README TODO config.guess config.sub configure configure.in \
208 aclocal.m4 crt1.c crtdll.def crtmt.c crtst.c dllcrt1.c dllmain.c \
209 gccmain.c init.c install-sh jamfile main.c mkinstalldirs \
210 moldname.def.in msvcrt.def.in ofmt_stub.s \
211 mthr.c mthr_init.c mthr_stub.c readme.txt \
212 isascii.c iscsym.c iscsymf.c toascii.c \
213 strcasecmp.c strncasecmp.c wcscmpi.c \
214 CRT_fp8.c CRT_fp10.c test_headers.c txtmode.c binmode.c pseudo-reloc.c \
215 pseudo-reloc-list.c cpu_features.c cpu_features.h \
216 DISCLAIMER CONTRIBUTORS
219 all_dlls_host = @all_dlls_host@
220 install_dlls_host = @install_dlls_host@
222 all: $(CRT0S) $(LIBS) $(all_dlls_host)
223 @$(MAKE) subdirs DO=$@ $(FLAGS_TO_PASS)
225 all_dlls_host: $(DLLS)
228 for i in $(DLLS); do \
229 $(INSTALL_PROGRAM) $$i $(inst_bindir)/$$i ; \
234 echo "static int __mingw_libm_dummy;" > _libm_dummy.c
235 $(CC) -c $(ALL_CFLAGS) _libm_dummy.c
238 libm.a: _libm_dummy.o
239 $(AR) rc $@ _libm_dummy.o
242 libmingwthrd.a: crtmt.o mingwthrd.def
243 $(DLLTOOL) $(DLLTOOL_FLAGS) --dllname $(THREAD_DLL_NAME) \
244 --def mingwthrd.def --output-lib $@
245 $(AR) $(ARFLAGS) $@ crtmt.o
248 DLL_OFILES = mthr.o mthr_init.o
249 DLL_CC_STUFF = -B./ -shared $(MNO_CYGWIN) -Wl,--image-base,0x6FBC0000 \
250 -Wl,--entry,_DllMainCRTStartup@12 \
251 $(DLL_OFILES) mingwthrd.def \
254 $(THREAD_DLL_NAME) mingwthrd.def: $(DLL_OFILES) Makefile $(SUBDIRS)
255 $(DLLTOOL) --as $(AS) --output-def mingwthrd.def $(DLL_OFILES)
256 $(CC) $(DLL_CC_STUFF) -o $(THREAD_DLL_NAME)
258 libmingw32.a: $(MINGW_OBJS)
259 $(AR) rc $@ $(MINGW_OBJS)
262 msvcrt.def msvcrtd.def \
263 msvcr70.def msvcr70d.def \
264 msvcr71.def msvcr71d.def \
265 msvcr80.def msvcr80d.def \
266 msvcr90.def msvcr90d.def \
268 $(CC) -DRUNTIME=$(basename $(notdir $@)) \
269 -D__$(basename $(notdir $@))__=1 \
270 -D__MSVCRT__ -C -E -P \
273 moldname-crtdll.def: moldname.def.in
274 $(CC) -DRUNTIME=crtdll \
275 -D__FILENAME__=moldname-crtdll.def \
276 -D__CRTDLL__ -C -E -P \
279 moldname-msvcrt.def: moldname.def.in
280 $(CC) -DRUNTIME=msvcrt \
281 -D__FILENAME__=moldname-msvcrt.def \
282 -D__MSVCRT__ -C -E -P \
285 libcoldname.a: moldname-crtdll.def $(MOLD_OBJS)
286 $(DLLTOOL) --as $(AS) -k -U \
287 --dllname crtdll.dll \
288 --def moldname-crtdll.def \
290 $(AR) rc $@ $(MOLD_OBJS)
293 libmoldname.a libmoldnamed.a: moldname-msvcrt.def $(MOLD_OBJS)
294 $(DLLTOOL) --as $(AS) -k -U \
295 --dllname msvcrt$(@:libmoldname%a=%)dll \
296 --def moldname-msvcrt.def \
298 $(AR) rc $@ $(MOLD_OBJS)
301 libmoldname70.a libmoldname70d.a libmoldname71.a libmoldname71d.a libmoldname80.a libmoldname80d.a libmoldname90.a libmoldname90d.a: moldname-msvcrt.def $(MOLD_OBJS)
302 $(DLLTOOL) --as $(AS) -k -U \
303 --dllname msvcr$(@:libmoldname%a=%)dll \
304 --def moldname-msvcrt.def \
306 $(AR) rc $@ $(MOLD_OBJS)
309 # The special rules are necessary.
311 $(CC) -c -D__CRTDLL__ -U__MSVCRT__ $(ALL_CFLAGS) $< -o $@
314 $(CC) -c -D__MSVCRT__ -U__CRTDLL__ $(ALL_CFLAGS) $< -o $@
316 TEST_H_OPTIONS = $(ALL_CFLAGS) -Wall -W -Wsystem-headers -c \
317 $(srcdir)/test_headers.c -o test_headers.o
321 @echo "Testing runtime headers..."
322 @for lang in c c++ objective-c ; do \
324 $(CC) -x$$lang $(TEST_H_OPTIONS) ; \
325 echo "$$lang -ansi"; \
326 $(CC) -x$$lang -ansi $(TEST_H_OPTIONS) ; \
328 # specify -std=xx only for C
329 @for std in gnu89 gnu99 c89 c99 ; do \
330 echo "std = $$std"; \
331 $(CC) -std=$$std $(TEST_H_OPTIONS) ; \
334 @rm -f test_headers.o
337 -rm -f *.o *.a *~ core a.out mingwthrd.def mingwthrd.base mingwthrd.exp
338 -rm -f $(THREAD_DLL_NAME) mingwthrd_dummy.exe
339 -rm -f msvcr*.def moldname-*.def
340 @$(MAKE) subdirs DO=$@ $(FLAGS_TO_PASS)
343 @$(MAKE) subdirs DO=$@ $(FLAGS_TO_PASS)
344 -rm -f config.cache config.status config.log
348 distdir=$(PACKAGE)-$(VERSION)-$(SNAPDATE)
350 ifneq (,$(findstring cygwin, $(target_alias)))
351 distdir=$(PACKAGE)-$(VERSION)-$(CYGRELEASE)
353 distdir=$(PACKAGE)-$(VERSION)
357 ifneq (,$(findstring cygwin, $(target_alias)))
359 TARFILEEXT = .tar.bz2
362 ifneq (,$(findstring mingw, $(target_alias)))
365 dist_prefix = $(conf_prefix)
368 dist: srcdist bindist
374 for i in $(SRCDIST_FILES); do \
375 cp -p $(srcdir)/$$i $(distdir)/$$i ; \
377 for i in $(SUBDIRS); do \
378 (cd $$i; $(MAKE) distdir=../$(distdir) dist); \
380 #FIXME this needs to be done with SUBDIRS and Makefiles.
382 # Maybe, but this is simpler, and adequate for now!
383 # However, as more manpages are added, spanning multiple sections,
384 # we'll probably need a separate Makefile to organise them.
386 mkdir $(distdir)/include
387 mkdir $(distdir)/include/sys
388 cp $(srcdir)/include/*.h $(distdir)/include/
389 cp $(srcdir)/include/sys/*.h $(distdir)/include/sys/
391 cp $(srcdir)/man/*.man $(distdir)/man/
394 rm -f $(distdir)-src.tar.gz
395 $(TAR) $(TARFLAGS)cf $(distdir)-src$(TARFILEEXT) $(distdir)
402 $(MAKE) install prefix=$(shell pwd)/$(distdir)$(dist_prefix)
403 rm -f $(distdir).tar.gz
405 $(TAR) $(TARFLAGS)cf ../$(distdir)$(TARFILEEXT) *
408 make dist SNAPDATE=$(shell date '+%Y%m%d')
417 $(mkinstalldirs) $(inst_bindir)
418 $(mkinstalldirs) $(inst_includedir)
419 $(mkinstalldirs) $(inst_libdir)
420 $(mkinstalldirs) $(inst_docdir)
421 $(mkinstalldirs) $(mandir)/man$(mansection)
423 install: all install-dirs $(install_dlls_host)
424 for i in $(LIBS); do \
425 $(INSTALL_DATA) $$i $(inst_libdir)/$$i ; \
427 for i in $(CRT0S); do \
428 $(INSTALL_DATA) $$i $(inst_libdir)/$$i ; \
430 for i in $(INSTDOCS); do \
431 $(INSTALL_DATA) $(srcdir)/$$i $(inst_docdir)/$$i ; \
433 for sub in . sys ; do \
434 dstdir=$(inst_includedir)/$$sub ; \
435 $(mkinstalldirs) $$dstdir ; \
436 for i in $(srcdir)/include/$$sub/*.h ; do \
437 $(INSTALL_DATA) $$i $$dstdir/`basename $$i` ; \
441 # This provisional hack installs the only manpage we have at present...
442 # It simply CANNOT suffice, when we have more manpages to ship.
444 $(mkinstalldirs) $(mandir)/man$(mansection)
445 $(INSTALL_DATA) $(srcdir)/man/dirname.man $(mandir)/man$(mansection)/`\
446 echo dirname.man|sed '$(manpage_transform);s,man$$,$(mansection),'`
447 $(INSTALL_DATA) $(srcdir)/man/dirname.man $(mandir)/man$(mansection)/`\
448 echo basename.man|sed '$(manpage_transform);s,man$$,$(mansection),'`
450 # End provisional hack.
452 @$(MAKE) subdirs DO=$@ $(FLAGS_TO_PASS)
457 # The . is here because SUBDIRS may be empty
460 @if [ -d ./$@ ]; then \
461 echo "Making $(DO) in $@..." ; \
462 if (rootme=`pwd`/ ; export rootme ; \
463 rootsrc=`cd $(srcdir); pwd`/ ; export rootsrc ; \
465 $(MAKE) $(FLAGS_TO_PASS) $(DO)) ; then true ; \
476 libcrtdll.a: crtdll.def
477 libmsvcrt.a: msvcrt.def
478 libmsvcrtd.a: msvcrtd.def
479 CRT_noglob.o: CRT_noglob.c
480 CRTfmode.o: CRTfmode.c
483 crt1.o: crt1.c init.c
484 crt2.o: crt1.c init.c
487 ctype_old.o: ctype_old.c
492 oldnames.o: oldnames.c
493 string_old.o: string_old.c
495 CRT_fp10.o: CRT_fp10.c
498 Makefile: Makefile.in config.status configure
499 $(SHELL) config.status
501 config.status: configure
502 $(SHELL) config.status --recheck
504 .SUFFIXES: .y $(SUFFIXES) .cc .def .a
506 sym_prefix = __msvcrt
508 NM_LOOKUP = $(NM) $@ | sed -n \
509 -e '/:$$/h;/^[0-7][0-7]* *T */{s///;H;g;s/\n//p' \
510 -e '}' | sed -n 's/:_'"$$key"'$$//p'
512 MINGW_REPL_FUNCS = printf fprintf sprintf vprintf vfprintf vsprintf
515 $(DLLTOOL) --as=$(AS) -k --dllname $*.dll --output-lib $@ --def $<
516 for key in $(MINGW_REPL_FUNCS); do \
517 src=`$(NM_LOOKUP)`; \
518 if test -n "$$src"; then \
519 dst=`echo "$$src" | sed 's/0/4/'`; repl="$$repl $$dst"; \
520 tmpfiles="$$tmpfiles $$src $$dst"; \
522 $(OBJCOPY) --redefine-sym _$$key=_$(sym_prefix)_$$key \
523 --redefine-sym __imp__$$key=__imp__$(sym_prefix)_$$key \
526 test `key=_get_output_format; $(NM_LOOKUP)` || \
527 repl="$$repl ofmt_stub.o"; \
528 test -n "$$repl" && $(AR) rcs $@ $$repl; \
531 libmsvcrt.a libmsvcrtd.a: ofmt_stub.o
532 libmsvcr70.a libmsvcr70d.a: ofmt_stub.o
533 libmsvcr71.a libmsvcr71d.a: ofmt_stub.o
534 libcrtdll.a libcrtdlld.a: ofmt_stub.o
537 $(CC) -c $(ALL_CFLAGS) $< -o $@