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 VERSION = @PACKAGE_VERSION@
27 host_alias = @host_alias@
28 build_alias = @build_alias@
29 target_alias = @target_alias@
30 with_cross_host = @with_cross_host@
32 conf_prefix = @prefix@
33 # FIXME: this needs an appropriate AC_SUBST
36 ifneq (,$(findstring cygwin, $(target_alias)))
37 PACKAGE = mingw-runtime
42 program_transform_name = @program_transform_name@
43 exec_prefix = @exec_prefix@
46 ifneq (,$(findstring cygwin,$(target_alias)))
47 mandir = $(prefix)/share/man
53 manpage_transform = @mingw_manpage_transform@
54 ifeq ($(target_alias),$(host_alias))
55 ifeq ($(build_alias),$(host_alias))
56 tooldir:=$(exec_prefix)
58 tooldir:=$(exec_prefix)/$(target_alias)
61 tooldir:=$(exec_prefix)/$(target_alias)
65 includedir = @includedir@
66 ifneq (,$(findstring cygwin,$(target_alias)))
67 inst_bindir:=$(tooldir)/bin
68 inst_includedir:=$(tooldir)/include/mingw
69 inst_libdir:=$(tooldir)/lib/mingw
70 inst_docdir:=$(tooldir)/share/doc/mingw-runtime
72 ifneq (,$(with_cross_host))
73 inst_bindir:=$(tooldir)/bin
74 inst_includedir:=$(tooldir)/include
75 inst_libdir:=$(tooldir)/lib
76 inst_docdir:=$(tooldir)/share/doc/mingw-runtime
78 inst_bindir:=$(bindir)
79 inst_includedir:=$(includedir)
80 inst_libdir:=$(libdir)
81 inst_docdir:=$(prefix)/doc/runtime
85 # The Mingw headers are installed under a subdirectory of
86 # $(tooldir)/include when configuring in Cygwin.
87 HEADER_SUBDIR = @HEADER_SUBDIR@
92 INSTALL_DATA = @INSTALL_DATA@
93 INSTALL_PROGRAM = @INSTALL_PROGRAM@
94 mkinstalldirs = $(SHELL) @MKINSTALLDIRS@
97 ifneq (,$(findstring cygwin,$(target_alias)))
98 override CC := ${filter-out -L% -B%,${shell echo $(CC) | sed -e 's%\(-isystem\|-iwithprefixbefore\) *[^ ]*\( \|$$\)% %g'}}
100 # FIXME: Which is it, CC or CC_FOR_TARGET?
101 CC_FOR_TARGET = $(CC)
102 AS_FOR_TARGET = $(AS)
104 CXXFLAGS = @CXXFLAGS@
106 # compiling with Cygwin?
107 NO_CYGWIN := @NO_CYGWIN@
109 override CC := ${NO_CYGWIN} $(firstword ${CC})
112 # Either crtdll (CRT_ID 1) or msvcrt (CRT_ID 2).
116 # Needed for threading dll.
117 THREAD_DLL = @THREAD_DLL@
118 THREAD_DLL_VERSION = 10
119 THREAD_DLL_NAME = $(THREAD_DLL)$(THREAD_DLL_VERSION).dll
124 W32API_INCLUDE = @W32API_INCLUDE@
125 INCLUDES = -I$(srcdir)/include \
126 -I$(srcdir)/../include \
128 -iwithprefixbefore include
129 ALL_CFLAGS = $(CFLAGS) $(INCLUDES) $(W32API_INCLUDE)
130 ALL_CXXFLAGS = $(CXXFLAGS) $(INCLUDES) -nostdinc++ $(W32API_INCLUDE)
139 DLLTOOL_FOR_TARGET = $(DLLTOOL)
140 DLLTOOL_FLAGS = --as $(AS_FOR_TARGET)
142 DLLWRAP_FOR_TARGET = $(DLLWRAP)
143 DLLWRAP_FLAGS = --dlltool $(DLLTOOL) --as $(AS) --driver-name $(CC)
156 CFLAGS="$(CFLAGS) $(CFLAGS_COMMON) $(CFLAGS_CONFIG)" \
157 CXXFLAGS="$(CXXFLAGS) $(CFLAGS_COMMON) $(CFLAGS_CONFIG)" \
158 EXE_LDFLAGS="$(EXE_LDFLAGS)" \
162 DLLTOOL="$(DLLTOOL)" \
163 exec_prefix="$(exec_prefix)" \
166 tooldir="$(tooldir)" \
167 datadir="$(datadir)" \
168 infodir="$(infodir)" \
169 includedir="$(includedir)" \
170 inst_bindir="$(inst_bindir)" \
171 inst_includedir="$(inst_includedir)" \
172 inst_libdir="$(inst_libdir)" \
173 inst_docdir="$(inst_docdir)" \
175 target_alias="$(target_alias)" \
177 TARFLAGS="$(TARFLAGS)" \
178 TARFILEEXT="$(TARFILEEXT)"
180 CRT0S = crt1.o dllcrt1.o crt2.o dllcrt2.o CRT_noglob.o crtmt.o crtst.o \
181 CRT_fp8.o CRT_fp10.o txtmode.o binmode.o
182 MINGW_OBJS = CRTglob.o CRTfmode.o CRTinit.o dllmain.o gccmain.o \
183 main.o crtst.o mthr_stub.o CRT_fp10.o txtmode.o \
184 pseudo-reloc.o pseudo-reloc-list.o cpu_features.o
186 MOLD_OBJS = isascii.o iscsym.o iscsymf.o toascii.o \
187 strcasecmp.o strncasecmp.o wcscmpi.o
190 libmsvcrt.a libmsvcrtd.a \
191 libmsvcr70.a libmsvcr70d.a \
192 libmsvcr71.a libmsvcr71d.a \
193 libmsvcr80.a libmsvcr80d.a \
194 libmsvcr90.a libmsvcr90d.a \
197 libmoldname.a libmoldnamed.a \
198 libmoldname70.a libmoldname70d.a \
199 libmoldname71.a libmoldname71d.a \
200 libmoldname80.a libmoldname80d.a \
201 libmoldname90.a libmoldname90d.a \
205 DLLS = $(THREAD_DLL_NAME)
207 INSTDOCS = CONTRIBUTORS \
211 SRCDIST_FILES = CRT_noglob.c CRTfmode.c CRTglob.c CRTinit.c ChangeLog \
212 Makefile.in README TODO config.guess config.sub configure configure.in \
213 aclocal.m4 crt1.c crtdll.def crtmt.c crtst.c dllcrt1.c dllmain.c \
214 gccmain.c init.c install-sh jamfile main.c mkinstalldirs \
215 moldname.def.in msvcrt.def.in ofmt_stub.s \
216 mthr.c mthr_init.c mthr_stub.c readme.txt \
217 isascii.c iscsym.c iscsymf.c toascii.c \
218 strcasecmp.c strncasecmp.c wcscmpi.c \
219 CRT_fp8.c CRT_fp10.c test_headers.c txtmode.c binmode.c pseudo-reloc.c \
220 pseudo-reloc-list.c cpu_features.c cpu_features.h \
221 DISCLAIMER CONTRIBUTORS
224 all_dlls_host = @all_dlls_host@
225 install_dlls_host = @install_dlls_host@
227 all: $(CRT0S) $(LIBS) $(all_dlls_host)
228 @$(MAKE) subdirs DO=$@ $(FLAGS_TO_PASS)
230 all_dlls_host: $(DLLS)
233 for i in $(DLLS); do \
234 $(INSTALL_PROGRAM) $$i $(inst_bindir)/$$i ; \
239 echo "static int __mingw_libm_dummy;" > _libm_dummy.c
240 $(CC) -c $(ALL_CFLAGS) _libm_dummy.c
243 libm.a: _libm_dummy.o
244 $(AR) rc $@ _libm_dummy.o
247 libmingwthrd.a: crtmt.o mingwthrd.def
248 $(DLLTOOL) $(DLLTOOL_FLAGS) --dllname $(THREAD_DLL_NAME) \
249 --def mingwthrd.def --output-lib $@
250 $(AR) $(ARFLAGS) $@ crtmt.o
253 DLL_OFILES = mthr.o mthr_init.o
254 DLL_CC_STUFF = -B./ -shared $(MNO_CYGWIN) -Wl,--image-base,0x6FBC0000 \
255 -Wl,--entry,_DllMainCRTStartup@12 \
256 $(DLL_OFILES) mingwthrd.def \
259 $(THREAD_DLL_NAME) mingwthrd.def: $(DLL_OFILES) Makefile $(SUBDIRS)
260 $(DLLTOOL) --as $(AS) --output-def mingwthrd.def $(DLL_OFILES)
261 $(CC) $(DLL_CC_STUFF) -o $(THREAD_DLL_NAME)
263 libmingw32.a: $(MINGW_OBJS)
264 $(AR) rc $@ $(MINGW_OBJS)
267 msvcrt.def msvcrtd.def \
268 msvcr70.def msvcr70d.def \
269 msvcr71.def msvcr71d.def \
270 msvcr80.def msvcr80d.def \
271 msvcr90.def msvcr90d.def \
273 $(CC) -DRUNTIME=$(basename $(notdir $@)) \
274 -D__$(basename $(notdir $@))__=1 \
275 -D__MSVCRT__ -C -E -P \
278 moldname-crtdll.def: moldname.def.in
279 $(CC) -DRUNTIME=crtdll \
280 -D__FILENAME__=moldname-crtdll.def \
281 -D__CRTDLL__ -C -E -P \
284 moldname-msvcrt.def: moldname.def.in
285 $(CC) -DRUNTIME=msvcrt \
286 -D__FILENAME__=moldname-msvcrt.def \
287 -D__MSVCRT__ -C -E -P \
290 libcoldname.a: moldname-crtdll.def $(MOLD_OBJS)
291 $(DLLTOOL) --as $(AS) -k -U \
292 --dllname crtdll.dll \
293 --def moldname-crtdll.def \
295 $(AR) rc $@ $(MOLD_OBJS)
298 libmoldname.a libmoldnamed.a: moldname-msvcrt.def $(MOLD_OBJS)
299 $(DLLTOOL) --as $(AS) -k -U \
300 --dllname msvcrt$(@:libmoldname%a=%)dll \
301 --def moldname-msvcrt.def \
303 $(AR) rc $@ $(MOLD_OBJS)
306 libmoldname70.a libmoldname70d.a \
307 libmoldname71.a libmoldname71d.a \
308 libmoldname80.a libmoldname80d.a \
309 libmoldname90.a libmoldname90d.a: moldname-msvcrt.def $(MOLD_OBJS)
310 $(DLLTOOL) --as $(AS) -k -U \
311 --dllname msvcr$(@:libmoldname%a=%)dll \
312 --def moldname-msvcrt.def \
314 $(AR) rc $@ $(MOLD_OBJS)
317 # The special rules are necessary.
319 $(CC) -c -D__CRTDLL__ -U__MSVCRT__ $(ALL_CFLAGS) $< -o $@
322 $(CC) -c -D__MSVCRT__ -U__CRTDLL__ $(ALL_CFLAGS) $< -o $@
326 TEST_H_OPTIONS = $(ALL_CFLAGS) -Wall -W -Wsystem-headers -c \
327 $(srcdir)/test_headers.c -o test_headers.o
329 .PHONY: check-headers
331 @echo "Testing runtime headers..."
332 @for lang in c c++ objective-c ; do \
334 $(CC) -x$$lang $(TEST_H_OPTIONS) ; \
335 echo "$$lang -ansi"; \
336 $(CC) -x$$lang -ansi $(TEST_H_OPTIONS) ; \
338 # specify -std=xx only for C
339 @for std in gnu89 gnu99 c89 c99 ; do \
340 echo "std = $$std"; \
341 $(CC) -std=$$std $(TEST_H_OPTIONS) ; \
344 @rm -f test_headers.o
347 -rm -f *.o *.a *~ core a.out mingwthrd.def mingwthrd.base mingwthrd.exp
348 -rm -f $(THREAD_DLL_NAME) mingwthrd_dummy.exe
349 -rm -f msvcr*.def moldname-*.def
350 @$(MAKE) subdirs DO=$@ $(FLAGS_TO_PASS)
353 @$(MAKE) subdirs DO=$@ $(FLAGS_TO_PASS)
354 -rm -f config.cache config.status config.log
358 distdir=$(PACKAGE)-$(VERSION)-$(SNAPDATE)
360 ifneq (,$(findstring cygwin, $(target_alias)))
361 distdir=$(PACKAGE)-$(VERSION)-$(CYGRELEASE)
363 distdir=$(PACKAGE)-$(VERSION)-$(host_os)
367 ifneq (,$(findstring cygwin, $(target_alias)))
369 TARFILEEXT = .tar.bz2
370 dist_prefix = $(conf_prefix)
373 dist: srcdist bindist
379 for i in $(SRCDIST_FILES); do \
380 cp -p $(srcdir)/$$i $(distdir)/$$i ; \
382 for i in $(SUBDIRS); do \
383 (cd $$i; $(MAKE) distdir=../$(distdir) dist); \
385 #FIXME this needs to be done with SUBDIRS and Makefiles.
387 # Maybe, but this is simpler, and adequate for now!
388 # However, as more manpages are added, spanning multiple sections,
389 # we'll probably need a separate Makefile to organise them.
391 mkdir $(distdir)/include
392 mkdir $(distdir)/include/sys
393 cp $(srcdir)/include/*.h $(distdir)/include/
394 cp $(srcdir)/include/sys/*.h $(distdir)/include/sys/
396 cp $(srcdir)/man/*.man $(distdir)/man/
399 rm -f $(distdir)-src.tar.gz
400 $(TAR) $(TARFLAGS)cf $(distdir)-src$(TARFILEEXT) $(distdir)
402 # Binary package structure is determined according to the
403 # preferred package name assigned at configure time...
405 bindist: bindist-$(PACKAGE)
407 # The directory structure is common to both package styles...
413 $(MAKE) install prefix=$(shell pwd)/$(distdir)$(dist_prefix)
414 rm -f $(distdir).tar.gz
416 # Current MinGW distributions prefer separate `dev' and `dll' bundles,
417 # and use the abbreviated `mingwrt' form for the package name...
419 DEVDIST_FILES = * --exclude=bin
420 DLLDIST_FILES = bin/*.dll doc/*
422 bindist-mingwrt: bindist-common
424 $(TAR) $(TARFLAGS)cf ../$(distdir)-dev$(TARFILEEXT) $(DEVDIST_FILES); \
425 $(TAR) $(TARFLAGS)cf ../$(distdir)-dll$(TARFILEEXT) $(DLLDIST_FILES)
428 # However, Cygwin maintainers continue to prefer a composite package,
429 # retaining the older `mingw-runtime' naming convention...
433 bindist-mingw-runtime: bindist-common
435 $(TAR) $(TARFLAGS)cf ../$(distdir)$(TARFILEEXT) $(BINDIST_FILES)
439 make dist SNAPDATE=$(shell date '+%Y%m%d')
448 $(mkinstalldirs) $(inst_bindir)
449 $(mkinstalldirs) $(inst_includedir)
450 $(mkinstalldirs) $(inst_libdir)
451 $(mkinstalldirs) $(inst_docdir)
452 $(mkinstalldirs) $(mandir)/man$(mansection)
454 install: all install-dirs $(install_dlls_host)
455 for i in $(LIBS); do \
456 $(INSTALL_DATA) $$i $(inst_libdir)/$$i ; \
458 for i in $(CRT0S); do \
459 $(INSTALL_DATA) $$i $(inst_libdir)/$$i ; \
461 for i in $(INSTDOCS); do \
462 $(INSTALL_DATA) $(srcdir)/$$i $(inst_docdir)/$$i ; \
464 for sub in . sys ; do \
465 dstdir=$(inst_includedir)/$$sub ; \
466 $(mkinstalldirs) $$dstdir ; \
467 for i in $(srcdir)/include/$$sub/*.h ; do \
468 $(INSTALL_DATA) $$i $$dstdir/`basename $$i` ; \
472 # This provisional hack installs the only manpage we have at present...
473 # It simply CANNOT suffice, when we have more manpages to ship.
475 $(mkinstalldirs) $(mandir)/man$(mansection)
476 $(INSTALL_DATA) $(srcdir)/man/dirname.man $(mandir)/man$(mansection)/`\
477 echo dirname.man|sed '$(manpage_transform);s,man$$,$(mansection),'`
478 $(INSTALL_DATA) $(srcdir)/man/dirname.man $(mandir)/man$(mansection)/`\
479 echo basename.man|sed '$(manpage_transform);s,man$$,$(mansection),'`
481 # End provisional hack.
483 @$(MAKE) subdirs DO=$@ $(FLAGS_TO_PASS)
488 # The . is here because SUBDIRS may be empty
491 @if [ -d ./$@ ]; then \
492 echo "Making $(DO) in $@..." ; \
493 if (rootme=`pwd`/ ; export rootme ; \
494 rootsrc=`cd $(srcdir); pwd`/ ; export rootsrc ; \
496 $(MAKE) $(FLAGS_TO_PASS) $(DO)) ; then true ; \
507 libcrtdll.a: crtdll.def
508 libmsvcrt.a: msvcrt.def
509 libmsvcrtd.a: msvcrtd.def
510 CRT_noglob.o: CRT_noglob.c
511 CRTfmode.o: CRTfmode.c
514 crt1.o: crt1.c init.c
515 crt2.o: crt1.c init.c
518 ctype_old.o: ctype_old.c
523 oldnames.o: oldnames.c
524 string_old.o: string_old.c
526 CRT_fp10.o: CRT_fp10.c
529 Makefile: Makefile.in config.status configure
530 $(SHELL) config.status
532 config.status: configure
533 $(SHELL) config.status --recheck
535 .SUFFIXES: .y $(SUFFIXES) .cc .def .a
537 sym_prefix = __msvcrt
539 NM_LOOKUP = $(NM) $@ | sed -n \
540 -e '/:$$/h;/^[0-7][0-7]* *T */{s///;H;g;s/\n//p' \
541 -e '}' | sed -n 's/:_'"$$key"'$$//p'
543 MINGW_REPL_FUNCS = printf fprintf sprintf vprintf vfprintf vsprintf
546 $(DLLTOOL) --as=$(AS) -k --dllname $*.dll --output-lib $@ --def $<
547 for key in $(MINGW_REPL_FUNCS); do \
548 src=`$(NM_LOOKUP)`; \
549 if test -n "$$src"; then \
550 dst=`echo "$$src" | sed 's/0/4/'`; repl="$$repl $$dst"; \
551 tmpfiles="$$tmpfiles $$src $$dst"; \
553 $(OBJCOPY) --redefine-sym _$$key=_$(sym_prefix)_$$key \
554 --redefine-sym __imp__$$key=__imp__$(sym_prefix)_$$key \
557 test `key=_get_output_format; $(NM_LOOKUP)` || \
558 repl="$$repl ofmt_stub.o"; \
559 test -n "$$repl" && $(AR) rcs $@ $$repl; \
562 libmsvcrt.a libmsvcrtd.a: ofmt_stub.o
563 libmsvcr70.a libmsvcr70d.a: ofmt_stub.o
564 libmsvcr71.a libmsvcr71d.a: ofmt_stub.o
565 libcrtdll.a libcrtdlld.a: ofmt_stub.o
568 $(CC) -c $(ALL_CFLAGS) $< -o $@