]> sourceware.org Git - newlib-cygwin.git/blame - winsup/utils/Makefile.in
Avoid a fault from locking a closed standard file.
[newlib-cygwin.git] / winsup / utils / Makefile.in
CommitLineData
1fd5e000 1# Makefile for Cygwin utilities
4d7c0b51 2# Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
2ac273a9 3# 2005, 2006, 2007, 2008, 2009 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
11SHELL:=@SHELL@
12
13srcdir:=@srcdir@
14VPATH:=@srcdir@
15prefix:=@prefix@
16exec_prefix:=@exec_prefix@
17
18bindir:=@bindir@
1fd5e000
CF
19program_transform_name:=@program_transform_name@
20
9ddd929f
CF
21override INSTALL:=@INSTALL@
22override INSTALL_PROGRAM:=@INSTALL_PROGRAM@
23override INSTALL_DATA:=@INSTALL_DATA@
1fd5e000
CF
24
25EXEEXT:=@EXEEXT@
26EXEEXT_FOR_BUILD:=@EXEEXT_FOR_BUILD@
27
28CC:=@CC@
29CC_FOR_TARGET:=$(CC)
92311ab5 30CXX:=@CXX@
ce475802 31CXX_FOR_TARGET:=$(CXX)
1fd5e000
CF
32
33CFLAGS:=@CFLAGS@
2c2473bc 34CXXFLAGS:=@CXXFLAGS@
67763c0c 35override CXXFLAGS+=-fno-exceptions -fno-rtti -DHAVE_DECL_GETOPT=0
1fd5e000
CF
36
37include $(srcdir)/../Makefile.common
38
1fd5e000
CF
39.SUFFIXES:
40.NOEXPORT:
68d2dd03
BD
41.PHONY: all install clean realclean warn_dumper warn_cygcheck_zlib
42
43ALL_LDLIBS := -lnetapi32 -ladvapi32
b2e53678 44ALL_LDFLAGS := -static-libgcc -Wl,--enable-auto-import -B$(newlib_build)/libc -B$(w32api_lib) $(LDFLAGS) $(ALL_LDLIBS)
68d2dd03
BD
45ALL_DEP_LDLIBS := $(cygwin_build)/libcygwin.a ${patsubst -l%,\
46 $(w32api_lib)/lib%.a,$(ALL_LDLIBS) -lkernel32 -luser32}
47
48MINGW_LIB := $(mingw_build)/libmingw32.a
49MINGW_LDLIBS := $(ALL_LDLIBS) $(MINGW_LIB)
50MINGW_DEP_LDLIBS := $(ALL_DEP_LDLIBS) $(MINGW_LIB)
fd49ac27 51MINGW_CXX := ${srcdir}/mingw ${CXX} -I${updir}
68d2dd03
BD
52
53# List all binaries to be linked in Cygwin mode. Each binary on this list
54# must have a corresponding .o of the same name.
086dc27f 55CYGWIN_BINS := ${addsuffix .exe,cygpath getfacl ldd kill mkgroup \
68d2dd03
BD
56 mkpasswd mount passwd ps regtool setfacl setmetamode ssp umount}
57
58# List all binaries to be linked in MinGW mode. Each binary on this list
59# must have a corresponding .o of the same name.
cea37699 60MINGW_BINS := ${addsuffix .exe,cygcheck cygwin-console-helper ldh strace}
68d2dd03
BD
61
62# List all objects to be compiled in MinGW mode. Any object not on this
63# list will will be compiled in Cygwin mode implicitly, so there is no
64# need for a CYGWIN_OBJS.
2e13058e 65MINGW_OBJS := bloda.o cygcheck.o dump_setup.o ldh.o path.o strace.o
68d2dd03
BD
66
67# If a binary should link in any objects besides the .o with the same
68# name as the binary, then list those here.
69strace.exe: path.o
70cygcheck.exe: bloda.o path.o dump_setup.o
71
72# Provide any necessary per-target variable overrides.
e3e942ac 73cygcheck.exe: MINGW_LDFLAGS += -lntdll
48829c1d
CV
74cygpath.exe: ALL_LDFLAGS += -lcygwin -lntdll
75ps.exe: ALL_LDFLAGS += -lcygwin -lntdll
68d2dd03 76
086dc27f
CF
77ldd.exe: ALL_LDFLAGS += -lpsapi
78
2e13058e
CF
79ldh.exe: MINGW_LDLIBS :=
80ldh.exe: MINGW_LDFLAGS := -nostdlib -lkernel32
81
68d2dd03
BD
82# Check for dumper's requirements and enable it if found.
83LIBICONV := @libiconv@
84libbfd := ${shell $(CC) -B$(bupdir2)/bfd/ --print-file-name=libbfd.a}
85libintl := ${shell $(CC) -B$(bupdir2)/intl/ --print-file-name=libintl.a}
86build_dumper := ${shell test -r $(libbfd) -a -r $(libintl) -a -n "$(LIBICONV)" && echo 1}
87ifdef build_dumper
88CYGWIN_BINS += dumper.exe
89dumper.o module_info.o parse_pe.o: CXXFLAGS += -I$(bupdir2)/bfd -I$(updir1)/include
90dumper.o parse_pe.o: dumper.h
91dumper.exe: module_info.o parse_pe.o
228f0b11 92dumper.exe: ALL_LDFLAGS += ${libbfd} ${libintl} -L$(bupdir1)/libiberty $(LIBICONV) -liberty -lz
2fac517d 93else
68d2dd03 94all: warn_dumper
2fac517d
CF
95endif
96
68d2dd03 97# Check for availability of a MinGW libz and enable for cygcheck.
fd49ac27 98libz:=${shell x=$$(${MINGW_CXX} --print-file-name=libz.a); cd $$(dirname $$x); dir=$$(pwd); case "$$dir" in *mingw*) echo $$dir/libz.a ;; esac}
68d2dd03
BD
99ifdef libz
100zlib_h := -include ${patsubst %/lib/mingw/libz.a,%/include/zlib.h,${patsubst %/lib/libz.a,%/include/zlib.h,$(libz)}}
101zconf_h := ${patsubst %/zlib.h,%/zconf.h,$(zlib_h)}
102dump_setup.o: MINGW_CXXFLAGS += $(zconf_h) $(zlib_h)
e3e942ac 103cygcheck.exe: MINGW_LDFLAGS += $(libz)
ce475802 104else
68d2dd03 105all: warn_cygcheck_zlib
ce475802
CF
106endif
107
68d2dd03 108all: Makefile $(CYGWIN_BINS) $(MINGW_BINS)
0ad10c0f 109
59fb00ae
BD
110# test harness support (note: the "MINGW_BINS +=" should come after the
111# "all:" above so that the testsuite is not run for "make" but only
112# "make check".)
113MINGW_BINS += testsuite.exe
114MINGW_OBJS += path-testsuite.o testsuite.o
115testsuite.exe: path-testsuite.o
116path-testsuite.cc: path.cc ; @test -L $@ || ln -sf ${filter %.cc,$^} $@
117path-testsuite.o: MINGW_CXXFLAGS += -DTESTSUITE
118# this is necessary because this .c lives in the build dir instead of src
119path-testsuite.o: MINGW_CXX := ${patsubst -I.,-I$(utils_source),$(MINGW_CXX)}
120path-testsuite.cc path.cc testsuite.cc: testsuite.h
121check: testsuite.exe ; $(<D)/$(<F)
122
123# the rest of this file contains generic rules
124
68d2dd03
BD
125# how to compile a MinGW object
126$(MINGW_OBJS): %.o: %.cc
2fac517d 127ifdef VERBOSE
b07b167e 128 $(MINGW_CXX) $c -o $(@D)/$(basename $@)$o $(MINGW_CXXFLAGS) $<
2fac517d 129else
68d2dd03
BD
130 @echo $(MINGW_CXX) $c $(MINGW_CXXFLAGS) ... $(*F).cc;\
131 $(MINGW_CXX) $c -o $(@D)/$(basename $@)$o $(MINGW_CXXFLAGS) $<
d0d51791
CF
132endif
133
68d2dd03
BD
134# how to link a MinGW binary
135$(MINGW_BINS): %.exe: %.o
64b94981 136ifdef VERBOSE
fd49ac27 137 $(MINGW_CXX) $(MINGW_CXXFLAGS) -o $@ ${filter %.o,$^} -B$(mingw_build)/ $(MINGW_LDFLAGS)
64b94981 138else
fd49ac27
CF
139 @echo $(MINGW_CXX) -o $@ ${filter %.o,$^} ${filter-out -B%, $(MINGW_CXXFLAGS) $(MINGW_LDFLAGS)};\
140 $(MINGW_CXX) $(MINGW_CXXFLAGS) -o $@ ${filter %.o,$^} -B$(mingw_build)/ $(MINGW_LDFLAGS)
64b94981
DK
141endif
142
68d2dd03 143# how to link a Cygwin binary
9401a0f8 144$(CYGWIN_BINS): %.exe: %.o
ad466e2f 145ifdef VERBOSE
68d2dd03 146 $(CXX) -o $@ ${filter %.o,$^} -B$(cygwin_build)/ $(ALL_LDFLAGS)
ad466e2f 147else
68d2dd03
BD
148 @echo $(CXX) -o $@ ${filter %.o,$^} ... ${filter-out -B%, $(ALL_LDFLAGS)};\
149 $(CXX) -o $@ ${filter %.o,$^} -B$(cygwin_build)/ $(ALL_LDFLAGS)
ad466e2f
CF
150endif
151
68d2dd03 152# note: how to compile a Cygwin object is covered by the pattern rule in Makefile.common
ad466e2f 153
68d2dd03
BD
154# these dependencies ensure that the required in-tree libs are built first
155$(MINGW_BINS): $(MINGW_DEP_LDLIBS)
156$(CYGWIN_BINS): $(ALL_DEP_LDLIBS)
c49fa762 157
1fd5e000 158clean:
59fb00ae 159 rm -f *.o $(CYGWIN_BINS) $(MINGW_BINS) path-testsuite.cc testsuite.exe
1fd5e000
CF
160
161realclean: clean
68d2dd03 162 rm -f Makefile config.cache
1fd5e000
CF
163
164install: all
99fe2b78 165 $(SHELL) $(updir1)/mkinstalldirs $(DESTDIR)$(bindir)
92108f4e 166 for i in $(CYGWIN_BINS) ${filter-out testsuite.exe,$(MINGW_BINS)} ; do \
1fd5e000 167 n=`echo $$i | sed '$(program_transform_name)'`; \
99fe2b78 168 $(INSTALL_PROGRAM) $$i $(DESTDIR)$(bindir)/$$n; \
1fd5e000
CF
169 done
170
171$(cygwin_build)/libcygwin.a: $(cygwin_build)/Makefile
172 @$(MAKE) -C $(@D) $(@F)
173
68d2dd03 174$(MINGW_LIB): $(mingw_build)/Makefile
1fd5e000
CF
175 @$(MAKE) -C $(@D) $(@F)
176
0715614b 177warn_dumper:
10e1fce6
CF
178 @echo '*** Not building dumper.exe since some required libraries are'
179 @echo '*** missing: libbfd.a and libintl.a.'
180 @echo '*** If you need this program, check out the naked-bfd and naked-intl'
e3e942ac 181 @echo '*** sources from sourceware.org. Then, configure and build these'
10e1fce6 182 @echo '*** libraries. Otherwise, you can safely ignore this warning.'
0715614b 183
68d2dd03
BD
184warn_cygcheck_zlib:
185 @echo '*** Building cygcheck without package content checking due to missing mingw libz.a.'
This page took 0.218455 seconds and 5 git commands to generate.