OSDN Git Service

* setfacl.c (strchrnul): New function.
[pf3gnuchains/pf3gnuchains4x.git] / winsup / utils / Makefile.in
1 # Makefile for Cygwin utilities
2 # Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
3 # 2005, 2006, 2007, 2008, 2009, 2010 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 SHELL:=@SHELL@
12
13 srcdir:=@srcdir@
14 VPATH:=@srcdir@
15 prefix:=@prefix@
16 exec_prefix:=@exec_prefix@
17
18 bindir:=@bindir@
19 program_transform_name:=@program_transform_name@
20
21 override INSTALL:=@INSTALL@
22 override INSTALL_PROGRAM:=@INSTALL_PROGRAM@
23 override INSTALL_DATA:=@INSTALL_DATA@
24
25 EXEEXT:=@EXEEXT@
26 EXEEXT_FOR_BUILD:=@EXEEXT_FOR_BUILD@
27
28 CC:=@CC@
29 CC_FOR_TARGET:=$(CC)
30 CXX:=@CXX@
31 CXX_FOR_TARGET:=$(CXX)
32
33 CFLAGS:=@CFLAGS@
34 CXXFLAGS:=@CXXFLAGS@
35 override CXXFLAGS+=-fno-exceptions -fno-rtti -DHAVE_DECL_GETOPT=0
36
37 include $(srcdir)/../Makefile.common
38
39 .SUFFIXES:
40 .NOEXPORT:
41 .PHONY: all install clean realclean warn_dumper warn_cygcheck_zlib
42
43 ALL_LDLIBS     := -lnetapi32 -ladvapi32
44 ALL_LDFLAGS    := -static-libgcc -Wl,--enable-auto-import -B$(newlib_build)/libc -B$(w32api_lib) $(LDFLAGS) $(ALL_LDLIBS)
45 ALL_DEP_LDLIBS := $(cygwin_build)/libcygwin.a ${patsubst -l%,\
46                     $(w32api_lib)/lib%.a,$(ALL_LDLIBS) -lkernel32 -luser32}
47
48 MINGW_LIB        := $(mingw_build)/libmingw32.a
49 MINGW_LDLIBS     := $(ALL_LDLIBS) $(MINGW_LIB)
50 MINGW_DEP_LDLIBS := $(ALL_DEP_LDLIBS) $(MINGW_LIB)
51 MINGW_CXX        := ${srcdir}/mingw ${CXX} -I${updir}
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.
55 CYGWIN_BINS := ${addsuffix .exe,cygpath getfacl ldd locale kill mkgroup \
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.
60 MINGW_BINS := ${addsuffix .exe,cygcheck cygwin-console-helper ldh strace}
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.
65 MINGW_OBJS := bloda.o cygcheck.o dump_setup.o ldh.o path.o strace.o
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.
69 strace.exe: path.o
70 cygcheck.exe: bloda.o path.o dump_setup.o
71
72 path-mount.o: path.cc
73         $(CXX) -c $(CXXFLAGS) -DFSTAB_ONLY -I$(updir) $< -o $@
74 mount.exe: path-mount.o
75
76 # Provide any necessary per-target variable overrides.
77 cygcheck.exe: MINGW_LDFLAGS += -lntdll
78 cygpath.exe: ALL_LDFLAGS += -lcygwin -lntdll
79 cygpath.exe: CXXFLAGS += -fno-threadsafe-statics
80 ps.exe: ALL_LDFLAGS += -lcygwin -lntdll
81
82 ldd.exe: ALL_LDFLAGS += -lpsapi
83
84 ldh.exe: MINGW_LDLIBS :=
85 ldh.exe: MINGW_LDFLAGS := -nostdlib -lkernel32
86
87 # Check for dumper's requirements and enable it if found.
88 LIBICONV := @libiconv@
89 libbfd   := ${shell $(CC) -B$(bupdir2)/bfd/ --print-file-name=libbfd.a}
90 libintl  := ${shell $(CC) -B$(bupdir2)/intl/ --print-file-name=libintl.a}
91 build_dumper := ${shell test -r $(libbfd) -a -r $(libintl) -a -n "$(LIBICONV)" && echo 1}
92 ifdef build_dumper
93 CYGWIN_BINS += dumper.exe
94 dumper.o module_info.o parse_pe.o: CXXFLAGS += -I$(bupdir2)/bfd -I$(updir1)/include
95 dumper.o parse_pe.o: dumper.h
96 dumper.exe: module_info.o parse_pe.o
97 dumper.exe: ALL_LDFLAGS += ${libbfd} ${libintl} -L$(bupdir1)/libiberty $(LIBICONV) -liberty -lz
98 else
99 all: warn_dumper
100 endif
101
102 # Check for availability of a MinGW libz and enable for cygcheck.
103 libz:=${shell x=$$(${MINGW_CXX} --print-file-name=libz.a); cd $$(dirname $$x); dir=$$(pwd); case "$$dir" in *mingw*) echo $$dir/libz.a ;; esac}
104 ifdef libz
105 zlib_h  := -include ${patsubst %/lib/mingw/libz.a,%/include/zlib.h,${patsubst %/lib/libz.a,%/include/zlib.h,$(libz)}}
106 zconf_h := ${patsubst %/zlib.h,%/zconf.h,$(zlib_h)}
107 dump_setup.o: MINGW_CXXFLAGS += $(zconf_h) $(zlib_h)
108 cygcheck.exe: MINGW_LDFLAGS += $(libz)
109 else
110 all: warn_cygcheck_zlib
111 endif
112
113 all: Makefile $(CYGWIN_BINS) $(MINGW_BINS)
114
115 # test harness support (note: the "MINGW_BINS +=" should come after the
116 # "all:" above so that the testsuite is not run for "make" but only
117 # "make check".)
118 MINGW_BINS += testsuite.exe
119 MINGW_OBJS += path-testsuite.o testsuite.o
120 testsuite.exe: path-testsuite.o
121 path-testsuite.cc: path.cc ; @test -L $@ || ln -sf ${filter %.cc,$^} $@
122 path-testsuite.o: MINGW_CXXFLAGS += -DTESTSUITE
123 # this is necessary because this .c lives in the build dir instead of src
124 path-testsuite.o: MINGW_CXX := ${patsubst -I.,-I$(utils_source),$(MINGW_CXX)}
125 path-testsuite.cc path.cc testsuite.cc: testsuite.h
126 check: testsuite.exe ; $(<D)/$(<F)
127
128 # the rest of this file contains generic rules
129
130 # how to compile a MinGW object
131 $(MINGW_OBJS): %.o: %.cc
132 ifdef VERBOSE
133         $(MINGW_CXX) $c -o $(@D)/$(basename $@)$o $(MINGW_CXXFLAGS) $<
134 else
135         @echo $(MINGW_CXX) $c $(MINGW_CXXFLAGS) ... $(*F).cc;\
136         $(MINGW_CXX) $c -o $(@D)/$(basename $@)$o $(MINGW_CXXFLAGS) $<
137 endif
138
139 # how to link a MinGW binary
140 $(MINGW_BINS): %.exe: %.o
141 ifdef VERBOSE
142         $(MINGW_CXX) $(MINGW_CXXFLAGS) -o $@ ${filter %.o,$^} -B$(mingw_build)/ $(MINGW_LDFLAGS)
143 else
144         @echo $(MINGW_CXX) -o $@ ${filter %.o,$^} ${filter-out -B%, $(MINGW_CXXFLAGS) $(MINGW_LDFLAGS)};\
145         $(MINGW_CXX) $(MINGW_CXXFLAGS) -o $@ ${filter %.o,$^} -B$(mingw_build)/ $(MINGW_LDFLAGS)
146 endif
147
148 # how to link a Cygwin binary
149 $(CYGWIN_BINS): %.exe: %.o
150 ifdef VERBOSE
151         $(CXX) -o $@ ${filter %.o,$^} -B$(cygwin_build)/ $(ALL_LDFLAGS)
152 else
153         @echo $(CXX) -o $@ ${filter %.o,$^} ... ${filter-out -B%, $(ALL_LDFLAGS)};\
154         $(CXX) -o $@ ${filter %.o,$^} -B$(cygwin_build)/ $(ALL_LDFLAGS)
155 endif
156
157 # note: how to compile a Cygwin object is covered by the pattern rule in Makefile.common
158
159 # these dependencies ensure that the required in-tree libs are built first
160 $(MINGW_BINS): $(MINGW_DEP_LDLIBS)
161 $(CYGWIN_BINS): $(ALL_DEP_LDLIBS)
162
163 clean:
164         rm -f *.o $(CYGWIN_BINS) $(MINGW_BINS) path-testsuite.cc testsuite.exe
165
166 realclean: clean
167         rm -f Makefile config.cache
168
169 install: all
170         $(SHELL) $(updir1)/mkinstalldirs $(DESTDIR)$(bindir)
171         for i in $(CYGWIN_BINS) ${filter-out testsuite.exe,$(MINGW_BINS)} ; do \
172           n=`echo $$i | sed '$(program_transform_name)'`; \
173           $(INSTALL_PROGRAM) $$i $(DESTDIR)$(bindir)/$$n; \
174         done
175
176 $(cygwin_build)/libcygwin.a: $(cygwin_build)/Makefile
177         @$(MAKE) -C $(@D) $(@F)
178
179 $(MINGW_LIB): $(mingw_build)/Makefile
180         @$(MAKE) -C $(@D) $(@F)
181
182 warn_dumper:
183         @echo '*** Not building dumper.exe since some required libraries are'
184         @echo '*** missing: libbfd.a and libintl.a.'
185         @echo '*** If you need this program, check out the naked-bfd and naked-intl'
186         @echo '*** sources from sourceware.org.  Then, configure and build these'
187         @echo '*** libraries.  Otherwise, you can safely ignore this warning.'
188
189 warn_cygcheck_zlib:
190         @echo '*** Building cygcheck without package content checking due to missing mingw libz.a.'