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 = @PACKAGE_TARNAME@
21 VERSION = @PACKAGE_VERSION@
26 top_srcdir = @top_srcdir@
27 top_builddir = @top_builddir@
29 # FIXME: I see no reason to define `objdir';
30 # it appears to be unused, and could be removed.
33 host_alias = @host_alias@
34 build_alias = @build_alias@
35 target_alias = @target_alias@
36 with_cross_host = @with_cross_host@
38 conf_prefix = @prefix@
41 datarootdir = @datarootdir@
42 program_transform_name = @program_transform_name@
43 exec_prefix = @exec_prefix@
47 ifneq (,$(findstring cygwin,$(target_alias)))
49 # FIXME: What is the purpose of such logic, testing `target_alias'?
51 # Firstly, there is no code generator being built here. The concept
52 # of `target' is meaningless, and there is no valid reason to expect
53 # that `target_alias' would be anything other than an empty string.
54 # Thus, the validity of such tests is extremely suspect.
56 # Secondly, the decisions being taken, on the basis of these tests,
57 # rightfully belong in the configure script; all this logic should be
58 # removed, and properly implemented in `configure.in'.
60 mandir = $(prefix)/share/man
66 manpage_transform = @mingw_manpage_transform@
67 ifeq ($(target_alias),$(host_alias))
68 ifeq ($(build_alias),$(host_alias))
69 tooldir:=$(exec_prefix)
71 tooldir:=$(exec_prefix)/$(target_alias)
74 tooldir:=$(exec_prefix)/$(target_alias)
78 includedir = @includedir@
79 ifneq (,$(findstring cygwin,$(target_alias)))
81 # FIXME: Doubtful use of `target_alias', again.
83 # Here we not only have a dubious test, based on `target_alias',
84 # but we also assign local alternatives for the standard autoconf
85 # installation path macros. This should not be necessary; the
86 # configure script should simply assign appropriate values to
87 # the standard macros, which should be used herein.
89 inst_bindir:=$(tooldir)/bin
90 inst_includedir:=$(tooldir)/include/mingw
91 inst_libdir:=$(tooldir)/lib/mingw
92 inst_docdir:=$(tooldir)/share/doc/mingw-runtime
93 need-DESTDIR-compatibility = prefix exec_prefix tooldir mandir
95 ifneq (,$(with_cross_host))
97 # FIXME: What is the intended purpose of `with_cross_host'?
99 # Notwithstanding that this conforms to no known standard, and
100 # is completely undocumented, it does not belong here; every one
101 # of these settings is the prerogative of the configure script,
102 # and they should use standard names, as noted above.
104 inst_bindir:=$(tooldir)/bin
105 inst_includedir:=$(tooldir)/include
106 inst_libdir:=$(tooldir)/lib
107 inst_docdir:=$(tooldir)/share/doc/mingw-runtime
108 need-DESTDIR-compatibility = prefix exec_prefix tooldir mandir
110 inst_bindir:=$(bindir)
111 inst_includedir:=$(includedir)
112 inst_libdir:=$(libdir)
113 inst_docdir:=$(prefix)/doc/runtime
114 need-DESTDIR-compatibility = prefix bindir includedir libdir mandir
118 # The Mingw headers are installed under a subdirectory of
119 # $(tooldir)/include when configuring in Cygwin.
120 HEADER_SUBDIR = @HEADER_SUBDIR@
125 INSTALL_DATA = @INSTALL_DATA@
126 INSTALL_PROGRAM = @INSTALL_PROGRAM@
127 mkinstalldirs = $(SHELL) @MKINSTALLDIRS@
130 ifneq (,$(findstring cygwin,$(target_alias)))
132 # FIXME: What is the purpose of this hideous kludge?
134 # Again, we have a dubious use of `target_alias'. Worse, `CC'
135 # should have been appropriately set by the configure script; to
136 # mess with it, in this fashion, should neither be necessary,
139 override CC := ${filter-out -L% -B%,${shell echo $(CC) | sed -e 's%\(-isystem\|-iwithprefixbefore\) *[^ ]*\( \|$$\)% %g'}}
141 # FIXME: Which is it, CC or CC_FOR_TARGET?
142 CC_FOR_TARGET = $(CC)
143 AS_FOR_TARGET = $(AS)
145 CXXFLAGS = @CXXFLAGS@
147 # compiling with Cygwin?
148 NO_CYGWIN := @NO_CYGWIN@
151 # FIXME: Again, this should have been resolved by `configure',
152 # and this kludge should be unnecessary.
154 override CC := ${NO_CYGWIN} $(firstword ${CC})
157 # Either crtdll (CRT_ID 1) or msvcrt (CRT_ID 2).
161 # Needed for threading dll.
162 THREAD_DLL = @THREAD_DLL@
163 THREAD_DLL_VERSION = 10
164 THREAD_DLL_NAME = $(THREAD_DLL)$(THREAD_DLL_VERSION).dll
169 W32API_INCLUDE = @W32API_INCLUDE@
170 INCLUDES = -I$(srcdir)/include \
171 -I$(srcdir)/../include \
173 -iwithprefixbefore include
174 ALL_CFLAGS = $(CFLAGS) $(INCLUDES) $(W32API_INCLUDE)
175 ALL_CXXFLAGS = $(CXXFLAGS) $(INCLUDES) -nostdinc++ $(W32API_INCLUDE)
184 DLLTOOL_FOR_TARGET = $(DLLTOOL)
185 DLLTOOL_FLAGS = --as $(AS_FOR_TARGET)
187 DLLWRAP_FOR_TARGET = $(DLLWRAP)
188 DLLWRAP_FLAGS = --dlltool $(DLLTOOL) --as $(AS) --driver-name $(CC)
196 SUBDIRS = mingwex profile
198 # FIXME: Most of these are either redundant, or should be set
199 # directly in the subdirectories' Makefiles, by `configure'.
203 CFLAGS="$(CFLAGS) $(CFLAGS_COMMON) $(CFLAGS_CONFIG)" \
204 CXXFLAGS="$(CXXFLAGS) $(CFLAGS_COMMON) $(CFLAGS_CONFIG)" \
205 EXE_LDFLAGS="$(EXE_LDFLAGS)" \
209 DLLTOOL="$(DLLTOOL)" \
210 exec_prefix="$(exec_prefix)" \
213 tooldir="$(tooldir)" \
214 datadir="$(datadir)" \
215 infodir="$(infodir)" \
216 includedir="$(includedir)" \
217 inst_bindir="$(inst_bindir)" \
218 inst_includedir="$(inst_includedir)" \
219 inst_libdir="$(inst_libdir)" \
220 inst_docdir="$(inst_docdir)" \
222 target_alias="$(target_alias)" \
224 TARFLAGS="$(TARFLAGS)" \
225 TARFILEEXT="$(TARFILEEXT)"
227 CRT0S = crt1.o dllcrt1.o crt2.o dllcrt2.o CRT_noglob.o crtmt.o crtst.o \
228 CRT_fp8.o CRT_fp10.o txtmode.o binmode.o
229 MINGW_OBJS = CRTglob.o CRTfmode.o CRTinit.o dllmain.o gccmain.o \
230 main.o crtst.o CRT_fp10.o txtmode.o \
231 pseudo-reloc.o pseudo-reloc-list.o cpu_features.o \
232 tlsmcrt.o tlsmthread.o tlssup.o tlsthrd.o
234 MOLD_OBJS = isascii.o iscsym.o iscsymf.o toascii.o \
235 strcasecmp.o strncasecmp.o wcscmpi.o
238 libmsvcrt.a libmsvcrtd.a \
239 libmsvcr70.a libmsvcr70d.a \
240 libmsvcr71.a libmsvcr71d.a \
241 libmsvcr80.a libmsvcr80d.a \
242 libmsvcr90.a libmsvcr90d.a \
243 libmsvcr100.a libmsvcr100d.a \
246 libmoldname.a libmoldnamed.a \
247 libmoldname70.a libmoldname70d.a \
248 libmoldname71.a libmoldname71d.a \
249 libmoldname80.a libmoldname80d.a \
250 libmoldname90.a libmoldname90d.a \
251 libmoldname100.a libmoldname100d.a \
256 DLLS = $(THREAD_DLL_NAME)
258 INSTDOCS = CONTRIBUTORS \
262 SRCDIST_FILES = CRT_noglob.c CRTfmode.c CRTglob.c CRTinit.c ChangeLog \
263 Makefile.in README TODO config.guess config.sub configure configure.in \
264 aclocal.m4 crt1.c crtdll.def crtmt.c crtst.c dllcrt1.c dllmain.c \
265 gccmain.c init.c install-sh jamfile main.c mkinstalldirs \
266 moldname.def.in msvcrt.def.in ofmt_stub.s \
267 mthr.c mthr_init.c tlsmcrt.c tlsmthread.c tlssup.c tlsthrd.c readme.txt \
268 isascii.c iscsym.c iscsymf.c toascii.c \
269 strcasecmp.c strncasecmp.c wcscmpi.c \
270 CRT_fp8.c CRT_fp10.c test_headers.c txtmode.c binmode.c pseudo-reloc.c \
271 pseudo-reloc-list.c cpu_features.c cpu_features.h \
272 DISCLAIMER CONTRIBUTORS
275 all_dlls_host = @all_dlls_host@
276 install_dlls_host = @install_dlls_host@
278 all: $(CRT0S) $(LIBS) $(all_dlls_host)
280 all_dlls_host: $(DLLS)
283 for i in $(DLLS); do \
284 $(INSTALL_PROGRAM) $$i $(DESTDIR)$(inst_bindir)/$$i ; \
289 echo "static int __mingw_libm_dummy;" > _libm_dummy.c
290 $(CC) -c $(ALL_CFLAGS) _libm_dummy.c
293 libm.a: _libm_dummy.o
294 $(AR) rc $@ _libm_dummy.o
297 libmingwthrd.a: crtmt.o
298 $(AR) $(ARFLAGS) $@ crtmt.o
301 libmingwthrd_old.a: crtmt.o mingwthrd.def
302 $(DLLTOOL) $(DLLTOOL_FLAGS) --dllname $(THREAD_DLL_NAME) \
303 --def mingwthrd.def --output-lib $@
304 $(AR) $(ARFLAGS) $@ crtmt.o
307 DLL_OFILES = mthr.o mthr_init.o
308 DLL_CC_STUFF = -B./ -shared $(MNO_CYGWIN) -Wl,--image-base,0x6FBC0000 \
309 -Wl,--entry,_DllMainCRTStartup@12 \
310 $(DLL_OFILES) mingwthrd.def \
313 $(THREAD_DLL_NAME) mingwthrd.def: $(DLL_OFILES) Makefile $(SUBDIRS)
314 $(DLLTOOL) --as $(AS) --output-def mingwthrd.def $(DLL_OFILES)
315 $(CC) $(DLL_CC_STUFF) -o $(THREAD_DLL_NAME)
317 libmingw32.a: $(MINGW_OBJS)
318 $(AR) rc $@ $(MINGW_OBJS)
321 msvcrt.def msvcrtd.def \
322 msvcr70.def msvcr70d.def \
323 msvcr71.def msvcr71d.def \
324 msvcr80.def msvcr80d.def \
325 msvcr90.def msvcr90d.def \
326 msvcr100.def msvcr100d.def: msvcrt.def.in
327 V=`echo $@ | sed -e 's|[a-z]*\([0-9]*\).*|\1|'`; \
328 test -z "$$V" && V=60; \
330 $(CC) -DRUNTIME=$(basename $(notdir $@)) \
331 -D__MSVCRT_VERSION__=$$V \
332 -D__$(basename $(notdir $@))__=1 \
333 -D__MSVCRT__ -C -E -P \
336 moldname-crtdll.def: moldname.def.in
337 $(CC) -DRUNTIME=crtdll \
338 -D__FILENAME__=moldname-crtdll.def \
339 -D__CRTDLL__ -C -E -P \
342 moldname-msvcrt.def: moldname.def.in
343 $(CC) -DRUNTIME=msvcrt \
344 -D__FILENAME__=moldname-msvcrt.def \
345 -D__MSVCRT__ -C -E -P \
348 libcoldname.a: moldname-crtdll.def $(MOLD_OBJS)
349 $(DLLTOOL) --as $(AS) -k -U \
350 --dllname crtdll.dll \
351 --def moldname-crtdll.def \
353 $(AR) rc $@ $(MOLD_OBJS)
356 libmoldname.a libmoldnamed.a: moldname-msvcrt.def $(MOLD_OBJS)
357 $(DLLTOOL) --as $(AS) -k -U \
358 --dllname msvcrt$(@:libmoldname%a=%)dll \
359 --def moldname-msvcrt.def \
361 $(AR) rc $@ $(MOLD_OBJS)
364 libmoldname70.a libmoldname70d.a \
365 libmoldname71.a libmoldname71d.a \
366 libmoldname80.a libmoldname80d.a \
367 libmoldname90.a libmoldname90d.a \
368 libmoldname100.a libmoldname100d.a: moldname-msvcrt.def $(MOLD_OBJS)
369 $(DLLTOOL) --as $(AS) -k -U \
370 --dllname msvcr$(@:libmoldname%a=%)dll \
371 --def moldname-msvcrt.def \
373 $(AR) rc $@ $(MOLD_OBJS)
376 # These special rules are necessary...
379 $(CC) -c -D__CRTDLL__ -U__MSVCRT__ $(ALL_CFLAGS) $< -o $@
382 $(CC) -c -D__MSVCRT__ -U__CRTDLL__ $(ALL_CFLAGS) $< -o $@
386 TEST_H_OPTIONS = $(ALL_CFLAGS) -Wall -W -Wsystem-headers -c \
387 $(srcdir)/test_headers.c -o test_headers.o
389 .PHONY: check-headers
391 @echo "Testing runtime headers..."
392 @for lang in c c++ objective-c ; do \
394 $(CC) -x$$lang $(TEST_H_OPTIONS) ; \
395 echo "$$lang -ansi"; \
396 $(CC) -x$$lang -ansi $(TEST_H_OPTIONS) ; \
398 @echo; echo "Testing runtime 8.0 headers..."
399 @for lang in c c++ objective-c ; do \
401 $(CC) -x$$lang -Wall -D__MSVCRT_VERSION__=0x0800 $(TEST_H_OPTIONS) ; \
402 echo "$$lang -ansi"; \
403 $(CC) -x$$lang -Wall -D__MSVCRT_VERSION__=0x0800 -ansi $(TEST_H_OPTIONS) ; \
405 @echo; echo "Testing runtime 8.0(time32) headers..."
406 @for lang in c c++ objective-c ; do \
408 $(CC) -x$$lang -Wall -D__MSVCRT_VERSION__=0x0800 -D_USE_32BIT_TIME_T $(TEST_H_OPTIONS) ; \
409 echo "$$lang -ansi"; \
410 $(CC) -x$$lang -Wall -D__MSVCRT_VERSION__=0x0800 -D_USE_32BIT_TIME_T -ansi $(TEST_H_OPTIONS) ; \
412 @echo; echo "Testing runtime 8.0(time32) headers..."
413 # specify -std=xx only for C
414 @for std in gnu89 gnu99 c89 c99 ; do \
415 echo "std = $$std"; \
416 $(CC) -std=$$std $(TEST_H_OPTIONS) ; \
419 @rm -f test_headers.o
422 -rm -f *.o *.a *~ core a.out mingwthrd.def mingwthrd.base mingwthrd.exp
423 -rm -f $(THREAD_DLL_NAME) mingwthrd_dummy.exe
424 -rm -f msvcr*.def moldname-*.def
425 @$(MAKE) subdirs DO=$@ $(FLAGS_TO_PASS)
428 @$(MAKE) subdirs DO=$@ $(FLAGS_TO_PASS)
429 -rm -f config.cache config.status config.log
433 distdir=$(PACKAGE)-$(VERSION)-$(SNAPDATE)
435 ifneq (,$(findstring cygwin, $(target_alias)))
436 distdir=$(PACKAGE)-$(VERSION)-$(CYGRELEASE)
438 distdir=$(PACKAGE)-$(VERSION)-$(host_os)
442 ifneq (,$(findstring cygwin, $(target_alias)))
444 # FIXME: Dubious use of `target_alias', yet again.
446 # Once more, the default settings for these macros could be
447 # more productively determined by `configure'.
450 TARFILEEXT = .tar.bz2
451 dist_prefix = $(conf_prefix)
454 dist: srcdist bindist
460 for i in $(SRCDIST_FILES); do \
461 cp -p $(srcdir)/$$i $(distdir)/$$i ; \
463 for i in $(SUBDIRS); do \
464 (cd $$i; $(MAKE) distdir=../$(distdir) dist); \
466 #FIXME this needs to be done with SUBDIRS and Makefiles.
468 # Maybe, but this is simpler, and adequate for now!
469 # However, as more manpages are added, spanning multiple sections,
470 # we'll probably need a separate Makefile to organise them.
472 mkdir $(distdir)/include
473 mkdir $(distdir)/include/sys
474 cp $(srcdir)/include/*.h $(distdir)/include/
475 cp $(srcdir)/include/sys/*.h $(distdir)/include/sys/
477 cp $(srcdir)/man/*.man $(distdir)/man/
480 rm -f $(distdir)-src.tar.gz
481 $(TAR) $(TARFLAGS)cf $(distdir)-src$(TARFILEEXT) $(distdir)
483 # Binary package structure is determined according to the
484 # preferred package name assigned at configure time...
486 bindist: bindist-$(PACKAGE)
488 # The directory structure is common to both package styles...
494 $(MAKE) install prefix=$(shell pwd)/$(distdir)$(dist_prefix)
495 rm -f $(distdir).tar.gz
497 # Current MinGW distributions prefer separate `dev' and `dll' bundles,
498 # and use the abbreviated `mingwrt' form for the package name...
500 DEVDIST_FILES = * --exclude=bin
501 DLLDIST_FILES = bin/*.dll doc/*
503 bindist-mingwrt: bindist-common
505 $(TAR) $(TARFLAGS)cf ../$(distdir)-dev$(TARFILEEXT) $(DEVDIST_FILES); \
506 $(TAR) $(TARFLAGS)cf ../$(distdir)-dll$(TARFILEEXT) $(DLLDIST_FILES)
509 # However, Cygwin maintainers continue to prefer a composite package,
510 # retaining the older `mingw-runtime' naming convention...
514 bindist-mingw-runtime: bindist-common
516 $(TAR) $(TARFLAGS)cf ../$(distdir)$(TARFILEEXT) $(BINDIST_FILES)
520 make dist SNAPDATE=$(shell date '+%Y%m%d')
528 .PHONY: $(need-DESTDIR-compatibility) fail-DESTDIR-compatibility
530 $(need-DESTDIR-compatibility):
531 @test -z "$(DESTDIR)" || case "$($@)" in ?:*) \
532 $(MAKE) --no-print-directory reject="$@" fail-DESTDIR-compatibility ;; \
535 fail-DESTDIR-compatibility:
536 $(error DESTDIR is not supported when $(reject) contains Win32 path `$($(reject))'; \
537 try `make install $(reject)=$(shell echo '$($(reject))' | sed s,:,:$(DESTDIR),) ...' instead)
539 install-dirs: $(need-DESTDIR-compatibility)
540 $(mkinstalldirs) $(DESTDIR)$(inst_bindir)
541 $(mkinstalldirs) $(DESTDIR)$(inst_includedir)
542 $(mkinstalldirs) $(DESTDIR)$(inst_libdir)
543 $(mkinstalldirs) $(DESTDIR)$(inst_docdir)
544 $(mkinstalldirs) $(DESTDIR)$(mandir)/man$(mansection)
546 install: all install-dirs $(install_dlls_host)
547 for i in $(LIBS); do \
548 $(INSTALL_DATA) $$i $(DESTDIR)$(inst_libdir)/$$i ; \
550 for i in $(CRT0S); do \
551 $(INSTALL_DATA) $$i $(DESTDIR)$(inst_libdir)/$$i ; \
553 for i in $(INSTDOCS); do \
554 $(INSTALL_DATA) $(srcdir)/$$i $(DESTDIR)$(inst_docdir)/$$i ; \
556 for sub in . sys ; do \
557 dstdir=$(DESTDIR)$(inst_includedir)/$$sub ; \
558 $(mkinstalldirs) $$dstdir ; \
559 for i in $(srcdir)/include/$$sub/*.h ; do \
560 $(INSTALL_DATA) $$i $$dstdir/`basename $$i` ; \
564 # This provisional hack installs the only manpage we have at present...
565 # It simply CANNOT suffice, when we have more manpages to ship.
567 $(mkinstalldirs) $(DESTDIR)$(mandir)/man$(mansection)
568 $(INSTALL_DATA) $(srcdir)/man/dirname.man $(DESTDIR)$(mandir)/man$(mansection)/`\
569 echo dirname.man|sed '$(manpage_transform);s,man$$,$(mansection),'`
570 $(INSTALL_DATA) $(srcdir)/man/dirname.man $(DESTDIR)$(mandir)/man$(mansection)/`\
571 echo basename.man|sed '$(manpage_transform);s,man$$,$(mansection),'`
573 # End provisional hack.
575 @$(MAKE) subdirs DO=$@ $(FLAGS_TO_PASS)
579 @test -n "$(DO)" && g="$(DO)" || g=all; echo "Making \`$$g' in \`$@'"
580 @cd $@; $(MAKE) $(FLAGS_TO_PASS) $(DO)
587 libcrtdll.a: crtdll.def
588 libmsvcrt.a: msvcrt.def
589 libmsvcrtd.a: msvcrtd.def
590 CRT_noglob.o: CRT_noglob.c
591 CRTfmode.o: CRTfmode.c
594 crt1.o: crt1.c init.c
595 crt2.o: crt1.c init.c
598 ctype_old.o: ctype_old.c
603 oldnames.o: oldnames.c
604 string_old.o: string_old.c
606 CRT_fp10.o: CRT_fp10.c
609 Makefile: Makefile.in config.status configure
610 $(SHELL) config.status
612 config.status: configure
613 $(SHELL) config.status --recheck
615 .SUFFIXES: .y $(SUFFIXES) .cc .def .a
617 sym_prefix = __msvcrt
619 NM_LOOKUP = $(NM) $@ | sed -n \
620 -e '/:$$/h;/^[0-7][0-7]* *T */{s///;H;g;s/\n//p' \
621 -e '}' | sed -n 's/:_'"$$key"'$$//p'
623 MINGW_REPL_FUNCS = printf fprintf sprintf vprintf vfprintf vsprintf
626 $(DLLTOOL) --as=$(AS) -k --dllname $*.dll --output-lib $@ --def $<
627 for key in $(MINGW_REPL_FUNCS); do \
628 src=`$(NM_LOOKUP)`; \
629 if test -n "$$src"; then \
630 dst=`echo "$$src" | sed 's/0/4/'`; repl="$$repl $$dst"; \
631 tmpfiles="$$tmpfiles $$src $$dst"; \
633 $(OBJCOPY) --redefine-sym _$$key=_$(sym_prefix)_$$key \
634 --redefine-sym __imp__$$key=__imp__$(sym_prefix)_$$key \
637 test `key=_get_output_format; $(NM_LOOKUP)` || \
638 repl="$$repl ofmt_stub.o"; \
639 test -n "$$repl" && $(AR) rcs $@ $$repl; \
642 libmsvcrt.a libmsvcrtd.a: ofmt_stub.o
643 libmsvcr70.a libmsvcr70d.a: ofmt_stub.o
644 libmsvcr71.a libmsvcr71d.a: ofmt_stub.o
645 libcrtdll.a libcrtdlld.a: ofmt_stub.o
648 $(CC) -c $(ALL_CFLAGS) $< -o $@
650 # $RCSfile$: end of file