]> sourceware.org Git - newlib-cygwin.git/blob - winsup/Makefile.common
2012-10-24 Kai Tietz <ktietz70@googlemail.com>
[newlib-cygwin.git] / winsup / Makefile.common
1 # Makefile.common - common definitions for the winsup directory
2 #
3 # Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2009, 2012 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 -Wstrict-aliasing -Wwrite-strings -fno-common -pipe -fbuiltin -fmessage-length=0 -D_SDKDDKVER_H
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 here:=${pwd}/cygwin
33 else
34 here:=${dir $(pwd)}cygwin
35 endif
36 bupdir:=${shell cd $(here)/..; pwd}
37 ifneq (,${filter-out /%,$(bupdir)})
38 bupdir1:=../..
39 bupdir2:=../../..
40 else
41 ifneq (,${findstring /,$(bupdir)})
42 bupdir1:=${patsubst %:::,%,${patsubst %/:::,%,$(dir $(bupdir)):::}}
43 else
44 bupdir1:=$(bupdir)/..
45 endif
46 ifneq (,${findstring /,$(bupdir1)})
47 bupdir2:=${patsubst %:::,%,${patsubst %/:::,%,$(dir $(bupdir1)):::}}
48 else
49 bupdir2:=$(bupdir1)/..
50 endif
51 endif
52
53 zlib_source:=$(updir)/zlib
54 zlib_build:=$(bupdir)/zlib
55 bz2lib_source:=$(updir)/bz2lib
56 bz2lib_build:=$(bupdir)/bz2lib
57 w32api_source:=$(updir)/w32api
58 w32api_build:=$(bupdir)/w32api
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
68 ifeq (,${findstring $(newlib_source)/libc/include,$(CFLAGS) $(CXXFLAGS) $(CXX) $(CC)})
69 newlib_include:=-I$(newlib_source)/libc/include
70 endif
71 ifeq (,${findstring $(cygwin_source)/include,$(CFLAGS) $(CXXFLAGS) $(CXX) $(CC)})
72 cygwin_include:=-I$(cygwin_source)/include
73 endif
74
75 nostdincxx:=-nostdinc++
76
77 nostdlib:=-nostdlib
78
79 ifeq (,${nostdlib})
80 nostdinc:=
81 endif
82
83 INCLUDES:=-I. $(cygwin_include) -I$(cygwin_source) $(newlib_include)
84 ifdef CONFIG_DIR
85 INCLUDES+=-I$(CONFIG_DIR)
86 endif
87
88 MINGW_LDFLAGS:=-static
89 MINGW_CFLAGS:=
90 MINGW_CXXFLAGS:=
91
92 GCC_DEFAULT_OPTIONS:=$(CFLAGS_COMMON) $(CFLAGS_CONFIG) $(INCLUDES)
93
94 # Link in libc and libm from newlib
95
96 LIBC:=$(newlib_build)/libc/libc.a
97 LIBM:=$(newlib_build)/libm/libm.a
98 CRT0:=$(cygwin_build)/crt0.o
99
100 ALL_CFLAGS=$(DEFS) $(MALLOC_DEBUG) $(CFLAGS) $(GCC_DEFAULT_OPTIONS)
101 ALL_CXXFLAGS=$(DEFS) $(MALLOC_DEBUG) $(CXXFLAGS) $(GCC_DEFAULT_OPTIONS)
102
103 ifndef PREPROCESS
104 c=-c
105 o=.o
106 else
107 c=-E -dD
108 o=.E
109 endif
110
111 libgcc:=${subst \,/,${shell $(CC_FOR_TARGET) -print-libgcc-file-name}}
112 gcc_libdir:=${word 1,${dir $(libgcc)}}
113 ifeq (,${findstring $(gcc_libdir),$(CFLAGS) $(CXXFLAGS) $(CXX) $(CC)})
114 GCC_INCLUDE:=${subst //,/,-I$(gcc_libdir)/include}
115 endif
116
117 COMPILE_CXX=$(CXX) $c $(if $($(*F)_STDINCFLAGS),,$(nostdincxx) $(nostdinc)) \
118 $(ALL_CXXFLAGS) $(GCC_INCLUDE) -fno-rtti -fno-exceptions
119 COMPILE_CC=$(CC) $c $(if $($(*F)_STDINCFLAGS),,$(nostdinc)) $(ALL_CFLAGS) $(GCC_INCLUDE)
120
121 vpath %.a $(cygwin_build):$(newlib_build)/libc:$(newlib_build)/libm
122
123 MAKEOVERRIDES_WORKAROUND=${wordlist 2,1,a b c}
124
125 ifneq ($(MAKEOVERRIDES_WORKAROUND),)
126 override MAKE:=$(MAKE) $(MAKEOVERRIDES)
127 MAKEOVERRIDES:=
128 export MAKEOVERRIDES
129 endif
130
131 ifdef RPATH_ENVVAR
132 VERBOSE=1
133 endif
134
135 ifneq "${findstring -B,$(COMPILE_CXX) $(COMPILE_CC)}" ""
136 VERBOSE=1
137 endif
138
139 .PRECIOUS: %.o
140
141 %.o: %.cc
142 ifdef VERBOSE
143 $(COMPILE_CXX) -o $(@D)/$(*F)$o $<
144 else
145 @echo $(CXX) $c $(CXXFLAGS) ... $(*F).cc
146 @$(COMPILE_CXX) -o $(@D)/$(*F)$o $<
147 endif
148
149 %.o: %.c
150 ifdef VERBOSE
151 $(COMPILE_CC) -o $(@D)/$(*F)$o $<
152 else
153 @echo $(CC) $c $(CFLAGS) ... $(*F).c
154 @$(COMPILE_CC) -o $(@D)/$(*F)$o $<
155 endif
156
157 $(bupdir1)/libiberty/%.o: $(updir1)/libiberty/%.c
158 @$(MAKE) -C $(@D) $(@F)
159
160 $(w32api_lib)/%.a: $(w32api_lib)/Makefile
161 @$(MAKE) --no-print-dir -C $(@D) $(@F)
162
163 $(bz2lib)/%.a: $(bz2lib)/Makefile
164 @$(MAKE) --no-print-dir -C $(@D) $(@F)
165
166 $(zlib)/%.a: $(zlib)/Makefile
167 @$(MAKE) --no-print-dir -C $(@D) $(@F)
168
169 all:
170
171 # For auto-rebuilding the Makefile
172
173 .PRECIOUS: Makefile
174
175 Makefile: Makefile.in $(srcdir)/configure.in config.status
176 $(SHELL) config.status
177
178 config.status: configure
179 $(SHELL) config.status --recheck
This page took 0.044182 seconds and 5 git commands to generate.