OSDN Git Service

* winsup.api/winsup.exp: Force linking all tests against binmode.o.
[pf3gnuchains/pf3gnuchains3x.git] / winsup / Makefile.common
1 # Makefile.common - common definitions for the winsup directory
2 #
3 # Copyright 2000, 2001 Red Hat, Inc.
4 #
5 # This file is part of Cygwin.
6 #
7 # This software is a copyrighted work licensed under the terms of the
8 # Cygwin license.  Please consult the file "CYGWIN_LICENSE" for
9 # details.
10
11 # This makefile requires GNU make.
12
13 CFLAGS_COMMON:=-Wall -Wwrite-strings # -finline-functions
14 MALLOC_DEBUG:=#-DMALLOC_DEBUG -I/cygnus/src/uberbaum/winsup/cygwin/dlmalloc
15 MALLOC_OBJ:=#/cygnus/src/uberbaum/winsup/cygwin/dlmalloc/malloc.o
16
17 override srcdir:=${shell cd $(srcdir); pwd}
18 ifneq (,${filter-out /%,$(srcdir)})
19     updir:=$(srcdir)/..
20     updir1:=$(updir)/..
21 else
22     updir:=${patsubst %:::,%,${patsubst %/:::,%,$(dir $(srcdir)):::}}
23 ifneq (,${findstring /,$(updir)})
24     updir1:=${patsubst %:::,%,${patsubst %/:::,%,$(dir $(updir)):::}}
25 else
26     updir1:=$(updir)/..
27 endif
28 endif
29
30 pwd:=${shell pwd}
31 ifneq "${filter winsup%,${notdir $(pwd)}}" ""
32 a:=${shell ${filter winsup%,${notdir $(pwd)}} >/dev/tty}
33     here:=${pwd}/cygwin
34 else
35 a:=${shell ${filter winsup%,${notdir $(pwd)}} >/dev/tty}
36     here:=${dir $(pwd)}cygwin
37 endif
38 bupdir:=${shell cd $(here)/..; pwd}
39 ifneq (,${filter-out /%,$(bupdir)})
40     bupdir1:=../..
41     bupdir2:=../../..
42 else
43 ifneq (,${findstring /,$(bupdir)})
44     bupdir1:=${patsubst %:::,%,${patsubst %/:::,%,$(dir $(bupdir)):::}}
45 else
46     bupdir1:=$(bupdir)/..
47 endif
48 ifneq (,${findstring /,$(bupdir1)})
49     bupdir2:=${patsubst %:::,%,${patsubst %/:::,%,$(dir $(bupdir1)):::}}
50 else
51     bupdir2:=$(bupdir1)/..
52 endif
53 endif
54
55 w32api_source:=$(updir)/w32api
56 w32api_build:=$(bupdir)/w32api
57 w32api_include:=$(w32api_source)/include
58 w32api_lib:=$(w32api_build)/lib
59 newlib_source:=$(updir1)/newlib
60 newlib_build:=$(bupdir1)/newlib
61 cygwin_build:=$(bupdir)/cygwin
62 cygwin_source:=$(updir)/cygwin
63 mingw_build:=$(bupdir)/mingw
64 mingw_source:=$(updir)/mingw
65 utils_build:=$(bupdir)/utils
66 utils_source:=$(updir)/utils
67
68 INCLUDES:=-I. -I$(cygwin_source)/include -I$(cygwin_source) -I$(newlib_source)/libc/sys/cygwin -I$(newlib_source)/libc/include -I$(w32api_include)
69 ifdef CONFIG_DIR
70 INCLUDES+=-I$(CONFIG_DIR)
71 endif
72
73 MINGW_INCLUDES:=-I$(updir)/mingw/include $(INCLUDES)
74
75 GCC_DEFAULT_OPTIONS:=$(CFLAGS_COMMON) $(CFLAGS_CONFIG) $(INCLUDES)
76
77 # Link in libc and libm from newlib
78
79 LIBC:=$(newlib_build)/libc/libc.a
80 LIBM:=$(newlib_build)/libm/libm.a
81 CRT0:=$(newlib_build)/libc/crt0.o
82
83 ALL_CFLAGS:=$(DEFS) $(MALLOC_DEBUG) $(CFLAGS) $(GCC_DEFAULT_OPTIONS)
84 ALL_CXXFLAGS:=$(DEFS) $(MALLOC_DEBUG) $(CXXFLAGS) $(GCC_DEFAULT_OPTIONS)
85
86 ifndef PREPROCESS
87 c=-c
88 o=.o
89 else
90 c=-E
91 o=.E
92 endif
93
94 libgcc:=${subst \,/,${shell $(CC_FOR_TARGET) -print-libgcc-file-name}}
95 GCC_INCLUDE:=${word 1,${dir $(libgcc)}}/include
96
97 COMPILE_CXX:=$(CXX) $c -nostdinc++ $(ALL_CXXFLAGS) -I$(GCC_INCLUDE) \
98              -fno-rtti -fno-exceptions
99 COMPILE_CC:=$(CC) $c -nostdinc $(ALL_CFLAGS) -I$(GCC_INCLUDE)
100
101 vpath %.a       $(cygwin_build):$(w32api_lib):$(newlib_build)/libc:$(newlib_build)/libm
102
103 MAKEOVERRIDES_WORKAROUND=${wordlist 2,1,a b c}
104
105 ifneq ($(MAKEOVERRIDES_WORKAROUND),)
106     override MAKE:=$(MAKE) $(MAKEOVERRIDES)
107     MAKEOVERRIDES:=
108     export MAKEOVERRIDES
109 endif
110
111 ifdef RPATH_ENVVAR
112 VERBOSE=1
113 endif
114
115 ifneq "${findstring -B,$(COMPILE_CXX) $(COMPILE_CC)}" ""
116 VERBOSE=1
117 endif
118
119 .PRECIOUS: %.o
120
121 %.o: %.cc
122 ifdef VERBOSE
123         $(COMPILE_CXX) -o $(@D)/$(*F)$o $<
124 else
125         @echo $(CXX) $c $(CXXFLAGS) ... $(*F).cc
126         @$(COMPILE_CXX) -o $(@D)/$(*F)$o $<
127 endif
128
129 %.o: %.c
130 ifdef VERBOSE
131         $(COMPILE_CC) -o $(@D)/$(*F)$o $<
132 else
133         @echo $(CC) $c $(CFLAGS) ... $(*F).c
134         @$(COMPILE_CC) -o $(@D)/$(*F)$o $<
135 endif
136
137 $(bupdir1)/libiberty/%.o: $(updir1)/libiberty/%.c
138         @$(MAKE) -C $(@D) $(@F)
139
140 $(w32api_lib)/%.a: $(w32api_lib)/Makefile
141         @$(MAKE) --no-print-dir -C $(@D) $(@F)
142
143 all:
144
145 # For auto-rebuilding the Makefile
146
147 .PRECIOUS: Makefile
148
149 Makefile: Makefile.in $(srcdir)/configure.in config.status
150         $(SHELL) config.status
151
152 config.status: configure
153         $(SHELL) config.status --recheck