]>
Commit | Line | Data |
---|---|---|
1fd5e000 CF |
1 | # Makefile.common - common definitions for the winsup directory |
2 | # | |
c24d1592 | 3 | # Copyright 2000, 2001, 2002, 2003, 2004, 2005 Red Hat, Inc. |
1fd5e000 CF |
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 | ||
a5ac89cb | 13 | CFLAGS_COMMON:=-Wall -Wstrict-aliasing -Wwrite-strings -fno-common -pipe -fbuiltin -fmessage-length=0# -finline-functions |
de7ba863 CF |
14 | MALLOC_DEBUG:=#-DMALLOC_DEBUG -I/cygnus/src/uberbaum/winsup/cygwin/dlmalloc |
15 | MALLOC_OBJ:=#/cygnus/src/uberbaum/winsup/cygwin/dlmalloc/malloc.o | |
1fd5e000 | 16 | |
2cf2f098 | 17 | override srcdir:=${shell cd $(srcdir); pwd} |
ba87a619 | 18 | ifneq (,${filter-out /%,$(srcdir)}) |
1fd5e000 CF |
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 | ||
1fd5e000 | 30 | pwd:=${shell pwd} |
f162ad82 | 31 | ifneq "${filter winsup%,${notdir $(pwd)}}" "" |
f162ad82 CF |
32 | here:=${pwd}/cygwin |
33 | else | |
f162ad82 CF |
34 | here:=${dir $(pwd)}cygwin |
35 | endif | |
b13be6f6 CF |
36 | bupdir:=${shell cd $(here)/..; pwd} |
37 | ifneq (,${filter-out /%,$(bupdir)}) | |
1fd5e000 | 38 | bupdir1:=../.. |
5f3cb291 | 39 | bupdir2:=../../.. |
1fd5e000 | 40 | else |
1fd5e000 CF |
41 | ifneq (,${findstring /,$(bupdir)}) |
42 | bupdir1:=${patsubst %:::,%,${patsubst %/:::,%,$(dir $(bupdir)):::}} | |
43 | else | |
44 | bupdir1:=$(bupdir)/.. | |
45 | endif | |
5f3cb291 CF |
46 | ifneq (,${findstring /,$(bupdir1)}) |
47 | bupdir2:=${patsubst %:::,%,${patsubst %/:::,%,$(dir $(bupdir1)):::}} | |
48 | else | |
49 | bupdir2:=$(bupdir1)/.. | |
50 | endif | |
1fd5e000 CF |
51 | endif |
52 | ||
94597cd0 CF |
53 | zlib_source:=$(updir)/zlib |
54 | zlib_build:=$(bupdir)/zlib | |
55 | bz2lib_source:=$(updir)/bz2lib | |
56 | bz2lib_build:=$(bupdir)/bz2lib | |
1fd5e000 CF |
57 | w32api_source:=$(updir)/w32api |
58 | w32api_build:=$(bupdir)/w32api | |
1fd5e000 CF |
59 | w32api_lib:=$(w32api_build)/lib |
60 | newlib_source:=$(updir1)/newlib | |
61 | newlib_build:=$(bupdir1)/newlib | |
62 | cygwin_build:=$(bupdir)/cygwin | |
63 | cygwin_source:=$(updir)/cygwin | |
64 | mingw_build:=$(bupdir)/mingw | |
65 | mingw_source:=$(updir)/mingw | |
66 | utils_build:=$(bupdir)/utils | |
67 | utils_source:=$(updir)/utils | |
0055a6c6 | 68 | ifeq (,${findstring $(newlib_source)/libc/include,$(CFLAGS) $(CXXFLAGS) $(CXX) $(CC)}) |
bc6aa7e1 | 69 | newlib_include:=-I$(newlib_source)/libc/include |
0055a6c6 | 70 | endif |
bc6aa7e1 CF |
71 | ifeq (,${findstring $(cygwin_source)/include,$(CFLAGS) $(CXXFLAGS) $(CXX) $(CC)}) |
72 | cygwin_include:=-I$(cygwin_source)/include | |
73 | endif | |
1fd5e000 | 74 | |
b128dd21 CF |
75 | # Try to determine what directories are available in winsup. |
76 | # Attempt to properly detect missing mingw or w32api and adjust command | |
77 | # line parameters appropriately | |
78 | ||
bade737e CF |
79 | # nostdinc:=${shell [ -d "$(updir)/w32api" ] && echo "-nostdinc"} |
80 | # ifneq (,$(nostdinc)) | |
c6f80f3e | 81 | nostdincxx:=-nostdinc++ |
bade737e | 82 | # ifeq (,${findstring $(w32api_source),$(CFLAGS) $(CXXFLAGS) $(CXX) $(CC)}) |
b128dd21 | 83 | w32api_include:=-I$(w32api_source)/include |
bade737e CF |
84 | # endif |
85 | # endif | |
b128dd21 CF |
86 | |
87 | mingw_include:=${shell [ -d "$(mingw_source)/include" ] && echo "-I$(mingw_source)/include"} | |
88 | ifneq (,$(mingw_include)) | |
89 | nostdlib:=-nostdlib | |
90 | else | |
91 | nostdlib:= | |
92 | endif | |
93 | ||
94 | ifeq (,${nostdlib}) | |
95 | nostdinc:= | |
96 | endif | |
97 | ||
01859fc4 | 98 | INCLUDES:=-I. $(cygwin_include) -I$(cygwin_source) $(newlib_include) $(w32api_include) |
1fd5e000 CF |
99 | ifdef CONFIG_DIR |
100 | INCLUDES+=-I$(CONFIG_DIR) | |
101 | endif | |
102 | ||
b128dd21 | 103 | MINGW_INCLUDES:=${mingw_include} $(w32api_include) |
9d6ac548 CF |
104 | MINGW_CFLAGS:=-mno-cygwin $(MINGW_INCLUDES) |
105 | MINGW_CXXFLAGS:=${filter-out $(newlib_source)/%,$(CXXFLAGS)} -mno-cygwin $(MINGW_INCLUDES) | |
df8c8e18 | 106 | MINGW_LDFLAGS:=-L${mingw_build} -L${mingw_build}/mingwex |
1fd5e000 CF |
107 | |
108 | GCC_DEFAULT_OPTIONS:=$(CFLAGS_COMMON) $(CFLAGS_CONFIG) $(INCLUDES) | |
109 | ||
110 | # Link in libc and libm from newlib | |
111 | ||
112 | LIBC:=$(newlib_build)/libc/libc.a | |
113 | LIBM:=$(newlib_build)/libm/libm.a | |
01859fc4 | 114 | CRT0:=$(cygwin_build)/crt0.o |
1fd5e000 | 115 | |
0390476c | 116 | ALL_CFLAGS=$(DEFS) $(MALLOC_DEBUG) $(CFLAGS) $(GCC_DEFAULT_OPTIONS) |
b7f68d3e | 117 | ALL_CXXFLAGS=$(DEFS) $(MALLOC_DEBUG) $(CXXFLAGS) $(GCC_DEFAULT_OPTIONS) |
1fd5e000 CF |
118 | |
119 | ifndef PREPROCESS | |
120 | c=-c | |
121 | o=.o | |
122 | else | |
bade737e | 123 | c=-E -dD |
1fd5e000 CF |
124 | o=.E |
125 | endif | |
126 | ||
8494f61e | 127 | libgcc:=${subst \,/,${shell $(CC_FOR_TARGET) -print-libgcc-file-name}} |
bc6aa7e1 CF |
128 | gcc_libdir:=${word 1,${dir $(libgcc)}} |
129 | ifeq (,${findstring $(gcc_libdir),$(CFLAGS) $(CXXFLAGS) $(CXX) $(CC)}) | |
cb837d41 | 130 | GCC_INCLUDE:=${subst //,/,-I$(gcc_libdir)/include} |
bc6aa7e1 | 131 | endif |
1fd5e000 | 132 | |
b602bb90 DK |
133 | COMPILE_CXX=$(CXX) $c $(if $($(*F)_STDINCFLAGS),,$(nostdincxx) $(nostdinc)) \ |
134 | $(ALL_CXXFLAGS) $(GCC_INCLUDE) -fno-rtti -fno-exceptions | |
135 | COMPILE_CC=$(CC) $c $(if $($(*F)_STDINCFLAGS),,$(nostdinc)) $(ALL_CFLAGS) $(GCC_INCLUDE) | |
1fd5e000 CF |
136 | |
137 | vpath %.a $(cygwin_build):$(w32api_lib):$(newlib_build)/libc:$(newlib_build)/libm | |
138 | ||
7f363152 CF |
139 | MAKEOVERRIDES_WORKAROUND=${wordlist 2,1,a b c} |
140 | ||
141 | ifneq ($(MAKEOVERRIDES_WORKAROUND),) | |
142 | override MAKE:=$(MAKE) $(MAKEOVERRIDES) | |
143 | MAKEOVERRIDES:= | |
144 | export MAKEOVERRIDES | |
145 | endif | |
1fd5e000 | 146 | |
72be82da CF |
147 | ifdef RPATH_ENVVAR |
148 | VERBOSE=1 | |
149 | endif | |
150 | ||
0ce83ef6 CF |
151 | ifneq "${findstring -B,$(COMPILE_CXX) $(COMPILE_CC)}" "" |
152 | VERBOSE=1 | |
153 | endif | |
154 | ||
1fd5e000 CF |
155 | .PRECIOUS: %.o |
156 | ||
157 | %.o: %.cc | |
158 | ifdef VERBOSE | |
159 | $(COMPILE_CXX) -o $(@D)/$(*F)$o $< | |
160 | else | |
8494f61e | 161 | @echo $(CXX) $c $(CXXFLAGS) ... $(*F).cc |
4b9f883e | 162 | @$(COMPILE_CXX) -o $(@D)/$(*F)$o $< |
1fd5e000 CF |
163 | endif |
164 | ||
165 | %.o: %.c | |
166 | ifdef VERBOSE | |
167 | $(COMPILE_CC) -o $(@D)/$(*F)$o $< | |
168 | else | |
4b9f883e DD |
169 | @echo $(CC) $c $(CFLAGS) ... $(*F).c |
170 | @$(COMPILE_CC) -o $(@D)/$(*F)$o $< | |
1fd5e000 CF |
171 | endif |
172 | ||
173 | $(bupdir1)/libiberty/%.o: $(updir1)/libiberty/%.c | |
ba87a619 | 174 | @$(MAKE) -C $(@D) $(@F) |
1fd5e000 CF |
175 | |
176 | $(w32api_lib)/%.a: $(w32api_lib)/Makefile | |
ba87a619 | 177 | @$(MAKE) --no-print-dir -C $(@D) $(@F) |
1fd5e000 | 178 | |
b6ddef77 | 179 | $(bz2lib)/%.a: $(bz2lib)/Makefile |
94597cd0 CF |
180 | @$(MAKE) --no-print-dir -C $(@D) $(@F) |
181 | ||
b6ddef77 | 182 | $(zlib)/%.a: $(zlib)/Makefile |
94597cd0 CF |
183 | @$(MAKE) --no-print-dir -C $(@D) $(@F) |
184 | ||
1fd5e000 CF |
185 | all: |
186 | ||
187 | # For auto-rebuilding the Makefile | |
188 | ||
189 | .PRECIOUS: Makefile | |
190 | ||
191 | Makefile: Makefile.in $(srcdir)/configure.in config.status | |
192 | $(SHELL) config.status | |
193 | ||
194 | config.status: configure | |
195 | $(SHELL) config.status --recheck |