1 # Makefile.common - common definitions for the winsup directory
3 # Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2009, 2012 Red Hat, Inc.
5 # This file is part of Cygwin.
7 # This software is a copyrighted work licensed under the terms of the
8 # Cygwin license. Please consult the file "CYGWIN_LICENSE" for
11 # This makefile requires GNU make.
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
17 override srcdir:=${shell cd $(srcdir); pwd}
18 ifneq (,${filter-out /%,$(srcdir)})
22 updir:=${patsubst %:::,%,${patsubst %/:::,%,$(dir $(srcdir)):::}}
23 ifneq (,${findstring /,$(updir)})
24 updir1:=${patsubst %:::,%,${patsubst %/:::,%,$(dir $(updir)):::}}
31 ifneq "${filter winsup%,${notdir $(pwd)}}" ""
34 here:=${dir $(pwd)}cygwin
36 bupdir:=${shell cd $(here)/..; pwd}
37 ifneq (,${filter-out /%,$(bupdir)})
41 ifneq (,${findstring /,$(bupdir)})
42 bupdir1:=${patsubst %:::,%,${patsubst %/:::,%,$(dir $(bupdir)):::}}
46 ifneq (,${findstring /,$(bupdir1)})
47 bupdir2:=${patsubst %:::,%,${patsubst %/:::,%,$(dir $(bupdir1)):::}}
49 bupdir2:=$(bupdir1)/..
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
71 ifeq (,${findstring $(cygwin_source)/include,$(CFLAGS) $(CXXFLAGS) $(CXX) $(CC)})
72 cygwin_include:=-I$(cygwin_source)/include
75 nostdincxx:=-nostdinc++
83 INCLUDES:=-I. $(cygwin_include) -I$(cygwin_source) $(newlib_include)
85 INCLUDES+=-I$(CONFIG_DIR)
88 MINGW_LDFLAGS:=-static
92 GCC_DEFAULT_OPTIONS:=$(CFLAGS_COMMON) $(CFLAGS_CONFIG) $(INCLUDES)
94 # Link in libc and libm from newlib
96 LIBC:=$(newlib_build)/libc/libc.a
97 LIBM:=$(newlib_build)/libm/libm.a
98 CRT0:=$(cygwin_build)/crt0.o
100 ALL_CFLAGS=$(DEFS) $(MALLOC_DEBUG) $(CFLAGS) $(GCC_DEFAULT_OPTIONS)
101 ALL_CXXFLAGS=$(DEFS) $(MALLOC_DEBUG) $(CXXFLAGS) $(GCC_DEFAULT_OPTIONS)
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}
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)
121 vpath %.a $(cygwin_build):$(newlib_build)/libc:$(newlib_build)/libm
123 MAKEOVERRIDES_WORKAROUND=${wordlist 2,1,a b c}
125 ifneq ($(MAKEOVERRIDES_WORKAROUND),)
126 override MAKE:=$(MAKE) $(MAKEOVERRIDES)
135 ifneq "${findstring -B,$(COMPILE_CXX) $(COMPILE_CC)}" ""
143 $(COMPILE_CXX) -o $(@D)/$(*F)$o $<
145 @echo $(CXX) $c $(CXXFLAGS) ... $(*F).cc
146 @$(COMPILE_CXX) -o $(@D)/$(*F)$o $<
151 $(COMPILE_CC) -o $(@D)/$(*F)$o $<
153 @echo $(CC) $c $(CFLAGS) ... $(*F).c
154 @$(COMPILE_CC) -o $(@D)/$(*F)$o $<
157 $(bupdir1)/libiberty/%.o: $(updir1)/libiberty/%.c
158 @$(MAKE) -C $(@D) $(@F)
160 $(w32api_lib)/%.a: $(w32api_lib)/Makefile
161 @$(MAKE) --no-print-dir -C $(@D) $(@F)
163 $(bz2lib)/%.a: $(bz2lib)/Makefile
164 @$(MAKE) --no-print-dir -C $(@D) $(@F)
166 $(zlib)/%.a: $(zlib)/Makefile
167 @$(MAKE) --no-print-dir -C $(@D) $(@F)
171 # For auto-rebuilding the Makefile
175 Makefile: Makefile.in $(srcdir)/configure.in config.status
176 $(SHELL) config.status
178 config.status: configure
179 $(SHELL) config.status --recheck