OSDN Git Service

c9ced3cf699bdc17cecaac7ab83984b137efb494
[pf3gnuchains/pf3gnuchains4x.git] / winsup / mingw / Makefile.in
1 # Makefile.in for the winsup/mingw directory.
2 # Copyright (c) 1995-2008, 1996, 1997, 1998 Cygnus Solutions
3
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.
8 #
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.
13 #
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.
17
18 # This makefile requires GNU make.
19
20 PACKAGE = mingw-runtime
21 VERSION = @PACKAGE_VERSION@
22 CYGRELEASE = 1
23
24 VPATH = @srcdir@
25 srcdir = @srcdir@
26 objdir = .
27
28 host_alias = @host_alias@
29 build_alias = @build_alias@
30 target_alias = @target_alias@
31 with_cross_host = @with_cross_host@
32 prefix = @prefix@
33 conf_prefix = @prefix@
34
35 program_transform_name = @program_transform_name@
36 exec_prefix = @exec_prefix@
37 bindir = @bindir@
38 libdir = @libdir@
39 ifneq (,$(findstring cygwin,$(target_alias)))
40 mandir = $(prefix)/share/man
41 mansection = mingw
42 else
43 mandir = @mandir@
44 mansection = 3
45 endif
46 manpage_transform = @mingw_manpage_transform@
47 ifeq ($(target_alias),$(host_alias))
48 ifeq ($(build_alias),$(host_alias))
49 tooldir:=$(exec_prefix)
50 else
51 tooldir:=$(exec_prefix)/$(target_alias)
52 endif
53 else
54 tooldir:=$(exec_prefix)/$(target_alias)
55 endif
56 datadir = @datadir@
57 infodir = @infodir@
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
64 else
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
70 else
71 inst_bindir:=$(bindir)
72 inst_includedir:=$(includedir)
73 inst_libdir:=$(libdir)
74 inst_docdir:=$(prefix)/doc/mingw-runtime
75 endif
76 endif
77
78 # The Mingw headers are installed under a subdirectory of
79 # $(tooldir)/include when configuring in Cygwin.
80 HEADER_SUBDIR = @HEADER_SUBDIR@
81
82 SHELL = /bin/sh
83
84 INSTALL = @INSTALL@
85 INSTALL_DATA = @INSTALL_DATA@
86 INSTALL_PROGRAM = @INSTALL_PROGRAM@
87 mkinstalldirs = $(SHELL) @MKINSTALLDIRS@
88
89 CC := @CC@
90 ifneq (,$(findstring cygwin,$(target_alias)))
91 override CC := ${filter-out -L% -B%,${shell echo $(CC) | sed -e 's%\(-isystem\|-iwithprefixbefore\)  *[^ ]*\( \|$$\)% %g'}}
92 endif
93 # FIXME: Which is it, CC or CC_FOR_TARGET?
94 CC_FOR_TARGET = $(CC)
95 AS_FOR_TARGET = $(AS)
96 CFLAGS = @CFLAGS@
97 CXXFLAGS = @CXXFLAGS@
98
99 # compiling with Cygwin?
100 MNO_CYGWIN = @MNO_CYGWIN@
101 ifdef MNO_CYGWIN
102    subdirforlib=/mingw
103 else
104    libdir=
105 endif
106
107 # Either crtdll (CRT_ID 1) or msvcrt (CRT_ID 2).
108 RUNTIME = @RUNTIME@
109 CRT_ID = @CRT_ID@
110
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
115
116 # Various libraries.
117 LIBM_A=@LIBM_A@
118
119 W32API_INCLUDE = @W32API_INCLUDE@
120 INCLUDES = -I$(srcdir)/include \
121   -I$(srcdir)/../include \
122   -nostdinc \
123   -iwithprefixbefore include
124 ALL_CFLAGS = $(CFLAGS) $(INCLUDES) $(W32API_INCLUDE) $(MNO_CYGWIN)
125 ALL_CXXFLAGS = $(CXXFLAGS) $(INCLUDES) -nostdinc++ $(W32API_INCLUDE) $(MNO_CYGWIN)
126
127 AS = @AS@
128 AR = @AR@
129 LD = @LD@
130 AR_FLAGS = rcv
131 RANLIB = @RANLIB@
132 DLLTOOL = @DLLTOOL@
133 DLLTOOLFLAGS =
134 DLLTOOL_FOR_TARGET = $(DLLTOOL)
135 DLLTOOL_FLAGS = --as $(AS_FOR_TARGET)
136 DLLWRAP = @DLLWRAP@
137 DLLWRAP_FOR_TARGET = $(DLLWRAP)
138 DLLWRAP_FLAGS = --dlltool $(DLLTOOL) --as $(AS) --driver-name $(CC)
139 OBJCOPY = @OBJCOPY@
140 NM = @NM@
141
142 TAR = tar
143 TARFLAGS = z
144 TARFILEEXT = .tar.gz
145
146 SUBDIRS := @subdirs@
147
148 FLAGS_TO_PASS:=\
149         AS="$(AS)" \
150         CC="$(CC)" \
151         CFLAGS="$(CFLAGS) $(CFLAGS_COMMON) $(CFLAGS_CONFIG)" \
152         CXXFLAGS="$(CXXFLAGS) $(CFLAGS_COMMON) $(CFLAGS_CONFIG)" \
153         EXE_LDFLAGS="$(EXE_LDFLAGS)" \
154         AR="$(AR)" \
155         RANLIB="$(RANLIB)" \
156         LD="$(LD)" \
157         DLLTOOL="$(DLLTOOL)" \
158         exec_prefix="$(exec_prefix)" \
159         bindir="$(bindir)" \
160         libdir="$(libdir)" \
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)" \
169         prefix="$(prefix)" \
170         target_alias="$(target_alias)" \
171         TAR="$(TAR)" \
172         TARFLAGS="$(TARFLAGS)" \
173         TARFILEEXT="$(TARFILEEXT)"
174
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
180
181 MOLD_OBJS = isascii.o iscsym.o iscsymf.o toascii.o \
182         strcasecmp.o strncasecmp.o wcscmpi.o
183
184 LIBS = libcrtdll.a \
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 \
190        libmingw32.a \
191        libcoldname.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 \
197        $(LIBM_A) \
198        libmingwthrd.a
199
200 DLLS = $(THREAD_DLL_NAME)
201
202 INSTDOCS = CONTRIBUTORS \
203            DISCLAIMER \
204            README
205
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
217
218
219 all_dlls_host = @all_dlls_host@
220 install_dlls_host = @install_dlls_host@
221
222 all: $(CRT0S) $(LIBS) $(all_dlls_host)
223         @$(MAKE) subdirs DO=$@ $(FLAGS_TO_PASS)
224
225 all_dlls_host: $(DLLS)
226
227 install_dlls_host:
228         for i in $(DLLS); do \
229                 $(INSTALL_PROGRAM) $$i $(inst_bindir)/$$i ; \
230         done
231
232 _libm_dummy.o:
233         rm -f _libm_dummy.c
234         echo "static int __mingw_libm_dummy;" > _libm_dummy.c
235         $(CC) -c $(ALL_CFLAGS) _libm_dummy.c
236         rm -f _libm_dummy.c
237
238 libm.a: _libm_dummy.o
239         $(AR) rc $@ _libm_dummy.o
240         $(RANLIB) $@
241
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
246         $(RANLIB) $@
247
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 \
252                     -Lmingwex
253
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)
257
258 libmingw32.a: $(MINGW_OBJS)
259         $(AR) rc $@ $(MINGW_OBJS)
260         $(RANLIB) $@
261
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 \
267 : msvcrt.def.in
268         $(CC) -DRUNTIME=$(basename $(notdir $@)) \
269                 -D__$(basename $(notdir $@))__=1 \
270                 -D__MSVCRT__ -C -E -P \
271                 -xc-header $? > $@
272
273 moldname-crtdll.def: moldname.def.in
274         $(CC) -DRUNTIME=crtdll \
275                 -D__FILENAME__=moldname-crtdll.def \
276                 -D__CRTDLL__  -C -E -P \
277                 -xc-header $? > $@
278
279 moldname-msvcrt.def: moldname.def.in
280         $(CC) -DRUNTIME=msvcrt \
281                 -D__FILENAME__=moldname-msvcrt.def \
282                 -D__MSVCRT__  -C -E -P \
283                 -xc-header $? > $@
284
285 libcoldname.a: moldname-crtdll.def $(MOLD_OBJS)
286         $(DLLTOOL) --as $(AS) -k -U     \
287                 --dllname crtdll.dll    \
288                 --def moldname-crtdll.def       \
289                 --output-lib $@
290         $(AR) rc $@ $(MOLD_OBJS)
291         $(RANLIB) $@
292
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       \
297                 --output-lib $@
298         $(AR) rc $@ $(MOLD_OBJS)
299         $(RANLIB) $@
300
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       \
305                 --output-lib $@
306         $(AR) rc $@ $(MOLD_OBJS)
307         $(RANLIB) $@
308
309 # The special rules are necessary.
310 crt1.o dllcrt1.o:
311         $(CC) -c -D__CRTDLL__ -U__MSVCRT__ $(ALL_CFLAGS) $< -o $@
312
313 crt2.o dllcrt2.o:
314         $(CC) -c -D__MSVCRT__ -U__CRTDLL__ $(ALL_CFLAGS) $< -o $@
315
316 TEST_H_OPTIONS = $(ALL_CFLAGS) -Wall -W -Wsystem-headers -c \
317         $(srcdir)/test_headers.c -o test_headers.o
318
319 .PHONY: test_headers
320 test_headers:
321         @echo "Testing runtime headers..."
322         @for lang in c c++ objective-c ; do \
323                 echo "$$lang ..."; \
324                 $(CC) -x$$lang  $(TEST_H_OPTIONS) ; \
325                 echo "$$lang -ansi"; \
326                 $(CC) -x$$lang -ansi $(TEST_H_OPTIONS) ; \
327         done
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) ; \
332         done
333
334         @rm -f test_headers.o
335
336 clean:
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)
341
342 distclean: clean
343         @$(MAKE) subdirs DO=$@ $(FLAGS_TO_PASS)
344         -rm -f config.cache config.status config.log
345         -rm -f Makefile
346
347 ifdef SNAPDATE
348       distdir=$(PACKAGE)-$(VERSION)-$(SNAPDATE)
349 else
350    ifneq (,$(findstring cygwin, $(target_alias)))
351       distdir=$(PACKAGE)-$(VERSION)-$(CYGRELEASE)
352    else
353       distdir=$(PACKAGE)-$(VERSION)
354    endif
355 endif
356
357 ifneq (,$(findstring cygwin, $(target_alias)))
358   TARFLAGS = j
359   TARFILEEXT = .tar.bz2
360 endif
361
362 ifneq (,$(findstring mingw, $(target_alias)))
363     dist_prefix =
364 else
365     dist_prefix = $(conf_prefix)
366 endif
367
368 dist: srcdist bindist
369
370 srcdist:
371         rm -rf $(distdir)
372         mkdir $(distdir)
373         chmod 755 $(distdir)
374         for i in $(SRCDIST_FILES); do \
375                 cp -p $(srcdir)/$$i $(distdir)/$$i ; \
376         done
377         for i in $(SUBDIRS); do \
378                 (cd $$i; $(MAKE) distdir=../$(distdir) dist); \
379         done
380 #FIXME this needs to be done with SUBDIRS and Makefiles.
381 #
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.
385 #
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/
390         mkdir $(distdir)/man
391         cp $(srcdir)/man/*.man $(distdir)/man/
392 #
393 #end FIXME
394         rm -f $(distdir)-src.tar.gz
395         $(TAR) $(TARFLAGS)cf $(distdir)-src$(TARFILEEXT) $(distdir)
396
397
398 bindist:
399         rm -rf $(distdir)
400         mkdir $(distdir)
401         chmod 755 $(distdir)
402         $(MAKE) install prefix=$(shell pwd)/$(distdir)$(dist_prefix)
403         rm -f $(distdir).tar.gz
404         cd $(distdir); \
405         $(TAR) $(TARFLAGS)cf ../$(distdir)$(TARFILEEXT) *
406
407 snapshot:
408         make dist SNAPDATE=$(shell date '+%Y%m%d')
409
410 info:
411
412 info-html:
413
414 install-info: info
415
416 install-dirs:
417         $(mkinstalldirs) $(inst_bindir)
418         $(mkinstalldirs) $(inst_includedir)
419         $(mkinstalldirs) $(inst_libdir)
420         $(mkinstalldirs) $(inst_docdir)
421         $(mkinstalldirs) $(mandir)/man$(mansection)
422
423 install: all install-dirs $(install_dlls_host)
424         for i in $(LIBS); do \
425                 $(INSTALL_DATA) $$i $(inst_libdir)/$$i ; \
426         done
427         for i in $(CRT0S); do \
428                 $(INSTALL_DATA) $$i $(inst_libdir)/$$i ; \
429         done
430         for i in $(INSTDOCS); do \
431                 $(INSTALL_DATA) $(srcdir)/$$i $(inst_docdir)/$$i ; \
432         done
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` ; \
438                 done ; \
439         done
440 #
441 # This provisional hack installs the only manpage we have at present...
442 # It simply CANNOT suffice, when we have more manpages to ship.
443 #
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),'`
449 #
450 # End provisional hack.
451 #
452         @$(MAKE) subdirs DO=$@ $(FLAGS_TO_PASS)
453
454 subdirs: $(SUBDIRS)
455         @true
456
457 # The . is here because SUBDIRS may be empty
458
459 . $(SUBDIRS): force
460         @if [ -d ./$@ ]; then \
461           echo "Making $(DO) in $@..." ; \
462           if (rootme=`pwd`/ ; export rootme ; \
463             rootsrc=`cd $(srcdir); pwd`/ ; export rootsrc ; \
464             cd ./$@; \
465             $(MAKE) $(FLAGS_TO_PASS) $(DO)) ; then true ; \
466           else exit 1 ; \
467           fi ; \
468         else true ; \
469         fi
470
471 force:
472
473 #
474 # Dependencies
475 #
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
481 CRTglob.o: CRTglob.c
482 CRTinit.o: CRTinit.c
483 crt1.o: crt1.c init.c
484 crt2.o: crt1.c init.c
485 crtmt.o: crtmt.c
486 crtst.o: crtst.c
487 ctype_old.o: ctype_old.c
488 dllcrt1.o: dllcrt1.c
489 dllcrt2.o: dllcrt1.c
490 dllmain.o: dllmain.c
491 main.o: main.c
492 oldnames.o: oldnames.c
493 string_old.o: string_old.c
494 CRT_fp8.o: CRT_fp8.c
495 CRT_fp10.o: CRT_fp10.c
496
497
498 Makefile: Makefile.in config.status configure
499         $(SHELL) config.status
500
501 config.status: configure
502         $(SHELL) config.status --recheck
503
504 .SUFFIXES: .y $(SUFFIXES) .cc .def .a
505
506 sym_prefix = __msvcrt
507
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'
511
512 MINGW_REPL_FUNCS = printf fprintf sprintf vprintf vfprintf vsprintf
513
514 lib%.a: %.def
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"; \
521             $(AR) x $@ $$src; \
522             $(OBJCOPY) --redefine-sym _$$key=_$(sym_prefix)_$$key \
523               --redefine-sym __imp__$$key=__imp__$(sym_prefix)_$$key \
524               $$src $$dst; \
525           fi; done; \
526         test `key=_get_output_format; $(NM_LOOKUP)` || \
527           repl="$$repl ofmt_stub.o"; \
528         test -n "$$repl" && $(AR) rcs $@ $$repl; \
529         $(RM) $$tmpfiles
530
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
535
536 .c.o:
537         $(CC) -c $(ALL_CFLAGS) $< -o $@
538