]> sourceware.org Git - newlib-cygwin.git/blob - winsup/Makefile.common
5bdcd79b2125dff77a739ccd44f426b4f576dd5a
[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 newlib_source:=$(updir1)/newlib
54 newlib_build:=$(bupdir1)/newlib
55 cygwin_build:=$(bupdir)/cygwin
56 cygwin_source:=$(updir)/cygwin
57 utils_build:=$(bupdir)/utils
58 utils_source:=$(updir)/utils
59 ifeq (,${findstring $(newlib_source)/libc/include,$(CFLAGS) $(CXXFLAGS) $(CXX) $(CC)})
60 newlib_include:=-I$(newlib_source)/libc/include
61 endif
62 ifeq (,${findstring $(cygwin_source)/include,$(CFLAGS) $(CXXFLAGS) $(CXX) $(CC)})
63 cygwin_include:=-I$(cygwin_source)/include
64 endif
65
66 nostdincxx:=-nostdinc++
67
68 nostdlib:=-nostdlib
69
70 ifeq (,${nostdlib})
71 nostdinc:=
72 endif
73
74 INCLUDES:=-I. $(cygwin_include) -I$(cygwin_source) $(newlib_include)
75 ifdef CONFIG_DIR
76 INCLUDES+=-I$(CONFIG_DIR)
77 endif
78
79 MINGW_LDFLAGS:=-static
80 MINGW_CFLAGS:=
81 MINGW_CXXFLAGS:=
82
83 GCC_DEFAULT_OPTIONS:=$(CFLAGS_COMMON) $(CFLAGS_CONFIG) $(INCLUDES)
84
85 # Link in libc and libm from newlib
86
87 LIBC:=$(newlib_build)/libc/libc.a
88 LIBM:=$(newlib_build)/libm/libm.a
89 CRT0:=$(cygwin_build)/crt0.o
90
91 ALL_CFLAGS=$(DEFS) $(MALLOC_DEBUG) $(CFLAGS) $(GCC_DEFAULT_OPTIONS)
92 ALL_CXXFLAGS=$(DEFS) $(MALLOC_DEBUG) $(CXXFLAGS) $(GCC_DEFAULT_OPTIONS)
93
94 ifndef PREPROCESS
95 c=-c
96 o=.o
97 else
98 c=-E -dD
99 o=.E
100 endif
101
102 libgcc:=${subst \,/,${shell $(CC_FOR_TARGET) -print-libgcc-file-name}}
103 gcc_libdir:=${word 1,${dir $(libgcc)}}
104 ifeq (,${findstring $(gcc_libdir),$(CFLAGS) $(CXXFLAGS) $(CXX) $(CC)})
105 GCC_INCLUDE:=${subst //,/,-I$(gcc_libdir)/include}
106 endif
107
108 COMPILE_CXX=$(CXX) $c $(if $($(*F)_STDINCFLAGS),,$(nostdincxx) $(nostdinc)) \
109 $(ALL_CXXFLAGS) $(GCC_INCLUDE) -fno-rtti -fno-exceptions
110 COMPILE_CC=$(CC) $c $(if $($(*F)_STDINCFLAGS),,$(nostdinc)) $(ALL_CFLAGS) $(GCC_INCLUDE)
111
112 vpath %.a $(cygwin_build):$(newlib_build)/libc:$(newlib_build)/libm
113
114 MAKEOVERRIDES_WORKAROUND=${wordlist 2,1,a b c}
115
116 ifneq ($(MAKEOVERRIDES_WORKAROUND),)
117 override MAKE:=$(MAKE) $(MAKEOVERRIDES)
118 MAKEOVERRIDES:=
119 export MAKEOVERRIDES
120 endif
121
122 ifdef RPATH_ENVVAR
123 VERBOSE=1
124 endif
125
126 ifneq "${findstring -B,$(COMPILE_CXX) $(COMPILE_CC)}" ""
127 VERBOSE=1
128 endif
129
130 .PRECIOUS: %.o
131
132 %.o: %.cc
133 ifdef VERBOSE
134 $(COMPILE_CXX) -o $(@D)/$(*F)$o $<
135 else
136 @echo $(CXX) $c $(CXXFLAGS) ... $(*F).cc
137 @$(COMPILE_CXX) -o $(@D)/$(*F)$o $<
138 endif
139
140 %.o: %.c
141 ifdef VERBOSE
142 $(COMPILE_CC) -o $(@D)/$(*F)$o $<
143 else
144 @echo $(CC) $c $(CFLAGS) ... $(*F).c
145 @$(COMPILE_CC) -o $(@D)/$(*F)$o $<
146 endif
147
148 $(bupdir1)/libiberty/%.o: $(updir1)/libiberty/%.c
149 @$(MAKE) -C $(@D) $(@F)
150
151 all:
152
153 # For auto-rebuilding the Makefile
154
155 .PRECIOUS: Makefile
156
157 Makefile: Makefile.in $(srcdir)/configure.in config.status
158 $(SHELL) config.status
159
160 config.status: configure
161 $(SHELL) config.status --recheck
This page took 0.040713 seconds and 4 git commands to generate.