2000-02-18 03:38:33 +08:00
|
|
|
# Makefile for Cygwin utilities
|
2006-01-17 23:37:13 +08:00
|
|
|
# Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
|
2010-01-23 06:31:50 +08:00
|
|
|
# 2005, 2006, 2007, 2008, 2009, 2010 Red Hat, Inc.
|
2000-02-18 03:38:33 +08:00
|
|
|
|
|
|
|
# This file is part of Cygwin.
|
|
|
|
|
|
|
|
# This software is a copyrighted work licensed under the terms of the
|
|
|
|
# Cygwin license. Please consult the file "CYGWIN_LICENSE" for
|
|
|
|
# details.
|
|
|
|
|
|
|
|
SHELL:=@SHELL@
|
|
|
|
|
|
|
|
srcdir:=@srcdir@
|
|
|
|
VPATH:=@srcdir@
|
|
|
|
prefix:=@prefix@
|
|
|
|
exec_prefix:=@exec_prefix@
|
|
|
|
|
|
|
|
bindir:=@bindir@
|
|
|
|
program_transform_name:=@program_transform_name@
|
|
|
|
|
2003-07-26 08:10:48 +08:00
|
|
|
override INSTALL:=@INSTALL@
|
|
|
|
override INSTALL_PROGRAM:=@INSTALL_PROGRAM@
|
|
|
|
override INSTALL_DATA:=@INSTALL_DATA@
|
2000-02-18 03:38:33 +08:00
|
|
|
|
|
|
|
EXEEXT:=@EXEEXT@
|
|
|
|
EXEEXT_FOR_BUILD:=@EXEEXT_FOR_BUILD@
|
|
|
|
|
|
|
|
CC:=@CC@
|
|
|
|
CC_FOR_TARGET:=$(CC)
|
2000-12-03 13:42:03 +08:00
|
|
|
CXX:=@CXX@
|
2000-10-28 13:39:38 +08:00
|
|
|
CXX_FOR_TARGET:=$(CXX)
|
2000-02-18 03:38:33 +08:00
|
|
|
|
|
|
|
CFLAGS:=@CFLAGS@
|
2002-01-22 11:22:55 +08:00
|
|
|
CXXFLAGS:=@CXXFLAGS@
|
2002-02-28 00:10:17 +08:00
|
|
|
override CXXFLAGS+=-fno-exceptions -fno-rtti -DHAVE_DECL_GETOPT=0
|
2000-02-18 03:38:33 +08:00
|
|
|
|
|
|
|
include $(srcdir)/../Makefile.common
|
|
|
|
|
|
|
|
.SUFFIXES:
|
|
|
|
.NOEXPORT:
|
2008-03-09 01:52:49 +08:00
|
|
|
.PHONY: all install clean realclean warn_dumper warn_cygcheck_zlib
|
|
|
|
|
|
|
|
ALL_LDLIBS := -lnetapi32 -ladvapi32
|
2008-10-29 21:13:26 +08:00
|
|
|
ALL_LDFLAGS := -static-libgcc -Wl,--enable-auto-import -B$(newlib_build)/libc -B$(w32api_lib) $(LDFLAGS) $(ALL_LDLIBS)
|
2008-03-09 01:52:49 +08:00
|
|
|
ALL_DEP_LDLIBS := $(cygwin_build)/libcygwin.a ${patsubst -l%,\
|
|
|
|
$(w32api_lib)/lib%.a,$(ALL_LDLIBS) -lkernel32 -luser32}
|
|
|
|
|
|
|
|
MINGW_LIB := $(mingw_build)/libmingw32.a
|
|
|
|
MINGW_LDLIBS := $(ALL_LDLIBS) $(MINGW_LIB)
|
|
|
|
MINGW_DEP_LDLIBS := $(ALL_DEP_LDLIBS) $(MINGW_LIB)
|
2008-10-12 11:06:12 +08:00
|
|
|
MINGW_CXX := ${srcdir}/mingw ${CXX} -I${updir}
|
2008-03-09 01:52:49 +08:00
|
|
|
|
|
|
|
# List all binaries to be linked in Cygwin mode. Each binary on this list
|
|
|
|
# must have a corresponding .o of the same name.
|
2011-07-20 09:18:14 +08:00
|
|
|
CYGWIN_BINS := ${addsuffix .exe,cygpath getconf getfacl ldd locale kill mkgroup \
|
2008-03-09 01:52:49 +08:00
|
|
|
mkpasswd mount passwd ps regtool setfacl setmetamode ssp umount}
|
|
|
|
|
|
|
|
# List all binaries to be linked in MinGW mode. Each binary on this list
|
|
|
|
# must have a corresponding .o of the same name.
|
2009-07-05 08:01:26 +08:00
|
|
|
MINGW_BINS := ${addsuffix .exe,cygcheck cygwin-console-helper ldh strace}
|
2008-03-09 01:52:49 +08:00
|
|
|
|
|
|
|
# List all objects to be compiled in MinGW mode. Any object not on this
|
|
|
|
# list will will be compiled in Cygwin mode implicitly, so there is no
|
|
|
|
# need for a CYGWIN_OBJS.
|
2009-03-18 12:19:05 +08:00
|
|
|
MINGW_OBJS := bloda.o cygcheck.o dump_setup.o ldh.o path.o strace.o
|
2008-03-09 01:52:49 +08:00
|
|
|
|
|
|
|
# If a binary should link in any objects besides the .o with the same
|
|
|
|
# name as the binary, then list those here.
|
|
|
|
strace.exe: path.o
|
|
|
|
cygcheck.exe: bloda.o path.o dump_setup.o
|
|
|
|
|
2009-07-22 18:20:26 +08:00
|
|
|
path-mount.o: path.cc
|
|
|
|
$(CXX) -c $(CXXFLAGS) -DFSTAB_ONLY -I$(updir) $< -o $@
|
|
|
|
mount.exe: path-mount.o
|
|
|
|
|
2008-03-09 01:52:49 +08:00
|
|
|
# Provide any necessary per-target variable overrides.
|
2008-07-30 14:07:42 +08:00
|
|
|
cygcheck.exe: MINGW_LDFLAGS += -lntdll
|
2009-05-16 23:46:42 +08:00
|
|
|
cygpath.exe: ALL_LDFLAGS += -lcygwin -lntdll
|
2009-11-04 22:14:52 +08:00
|
|
|
cygpath.exe: CXXFLAGS += -fno-threadsafe-statics
|
2009-05-16 23:46:42 +08:00
|
|
|
ps.exe: ALL_LDFLAGS += -lcygwin -lntdll
|
2008-03-09 01:52:49 +08:00
|
|
|
|
2009-01-09 13:11:57 +08:00
|
|
|
ldd.exe: ALL_LDFLAGS += -lpsapi
|
|
|
|
|
2009-03-18 12:19:05 +08:00
|
|
|
ldh.exe: MINGW_LDLIBS :=
|
|
|
|
ldh.exe: MINGW_LDFLAGS := -nostdlib -lkernel32
|
|
|
|
|
2008-03-09 01:52:49 +08:00
|
|
|
# Check for dumper's requirements and enable it if found.
|
|
|
|
LIBICONV := @libiconv@
|
|
|
|
libbfd := ${shell $(CC) -B$(bupdir2)/bfd/ --print-file-name=libbfd.a}
|
|
|
|
libintl := ${shell $(CC) -B$(bupdir2)/intl/ --print-file-name=libintl.a}
|
|
|
|
build_dumper := ${shell test -r $(libbfd) -a -r $(libintl) -a -n "$(LIBICONV)" && echo 1}
|
|
|
|
ifdef build_dumper
|
|
|
|
CYGWIN_BINS += dumper.exe
|
|
|
|
dumper.o module_info.o parse_pe.o: CXXFLAGS += -I$(bupdir2)/bfd -I$(updir1)/include
|
|
|
|
dumper.o parse_pe.o: dumper.h
|
|
|
|
dumper.exe: module_info.o parse_pe.o
|
2009-04-14 06:51:02 +08:00
|
|
|
dumper.exe: ALL_LDFLAGS += ${libbfd} ${libintl} -L$(bupdir1)/libiberty $(LIBICONV) -liberty -lz
|
2001-11-11 11:06:59 +08:00
|
|
|
else
|
2008-03-09 01:52:49 +08:00
|
|
|
all: warn_dumper
|
2001-11-11 11:06:59 +08:00
|
|
|
endif
|
|
|
|
|
2008-03-09 01:52:49 +08:00
|
|
|
# Check for availability of a MinGW libz and enable for cygcheck.
|
2008-10-12 11:06:12 +08:00
|
|
|
libz:=${shell x=$$(${MINGW_CXX} --print-file-name=libz.a); cd $$(dirname $$x); dir=$$(pwd); case "$$dir" in *mingw*) echo $$dir/libz.a ;; esac}
|
2008-03-09 01:52:49 +08:00
|
|
|
ifdef libz
|
|
|
|
zlib_h := -include ${patsubst %/lib/mingw/libz.a,%/include/zlib.h,${patsubst %/lib/libz.a,%/include/zlib.h,$(libz)}}
|
|
|
|
zconf_h := ${patsubst %/zlib.h,%/zconf.h,$(zlib_h)}
|
|
|
|
dump_setup.o: MINGW_CXXFLAGS += $(zconf_h) $(zlib_h)
|
2008-07-30 14:07:42 +08:00
|
|
|
cygcheck.exe: MINGW_LDFLAGS += $(libz)
|
2000-10-28 13:39:38 +08:00
|
|
|
else
|
2008-03-09 01:52:49 +08:00
|
|
|
all: warn_cygcheck_zlib
|
2000-10-28 13:39:38 +08:00
|
|
|
endif
|
|
|
|
|
2008-03-09 01:52:49 +08:00
|
|
|
all: Makefile $(CYGWIN_BINS) $(MINGW_BINS)
|
2000-08-25 03:03:12 +08:00
|
|
|
|
2008-03-09 12:10:10 +08:00
|
|
|
# test harness support (note: the "MINGW_BINS +=" should come after the
|
|
|
|
# "all:" above so that the testsuite is not run for "make" but only
|
|
|
|
# "make check".)
|
|
|
|
MINGW_BINS += testsuite.exe
|
|
|
|
MINGW_OBJS += path-testsuite.o testsuite.o
|
|
|
|
testsuite.exe: path-testsuite.o
|
|
|
|
path-testsuite.cc: path.cc ; @test -L $@ || ln -sf ${filter %.cc,$^} $@
|
|
|
|
path-testsuite.o: MINGW_CXXFLAGS += -DTESTSUITE
|
|
|
|
# this is necessary because this .c lives in the build dir instead of src
|
|
|
|
path-testsuite.o: MINGW_CXX := ${patsubst -I.,-I$(utils_source),$(MINGW_CXX)}
|
|
|
|
path-testsuite.cc path.cc testsuite.cc: testsuite.h
|
|
|
|
check: testsuite.exe ; $(<D)/$(<F)
|
|
|
|
|
|
|
|
# the rest of this file contains generic rules
|
|
|
|
|
2008-03-09 01:52:49 +08:00
|
|
|
# how to compile a MinGW object
|
|
|
|
$(MINGW_OBJS): %.o: %.cc
|
2001-11-11 11:06:59 +08:00
|
|
|
ifdef VERBOSE
|
2003-09-11 10:00:42 +08:00
|
|
|
$(MINGW_CXX) $c -o $(@D)/$(basename $@)$o $(MINGW_CXXFLAGS) $<
|
2001-11-11 11:06:59 +08:00
|
|
|
else
|
2008-03-09 01:52:49 +08:00
|
|
|
@echo $(MINGW_CXX) $c $(MINGW_CXXFLAGS) ... $(*F).cc;\
|
|
|
|
$(MINGW_CXX) $c -o $(@D)/$(basename $@)$o $(MINGW_CXXFLAGS) $<
|
2001-11-11 14:07:36 +08:00
|
|
|
endif
|
|
|
|
|
2008-03-09 01:52:49 +08:00
|
|
|
# how to link a MinGW binary
|
|
|
|
$(MINGW_BINS): %.exe: %.o
|
2007-08-04 03:41:48 +08:00
|
|
|
ifdef VERBOSE
|
2008-10-12 11:06:12 +08:00
|
|
|
$(MINGW_CXX) $(MINGW_CXXFLAGS) -o $@ ${filter %.o,$^} -B$(mingw_build)/ $(MINGW_LDFLAGS)
|
2007-08-04 03:41:48 +08:00
|
|
|
else
|
2008-10-12 11:06:12 +08:00
|
|
|
@echo $(MINGW_CXX) -o $@ ${filter %.o,$^} ${filter-out -B%, $(MINGW_CXXFLAGS) $(MINGW_LDFLAGS)};\
|
|
|
|
$(MINGW_CXX) $(MINGW_CXXFLAGS) -o $@ ${filter %.o,$^} -B$(mingw_build)/ $(MINGW_LDFLAGS)
|
2007-08-04 03:41:48 +08:00
|
|
|
endif
|
|
|
|
|
2008-03-09 01:52:49 +08:00
|
|
|
# how to link a Cygwin binary
|
2008-10-12 11:08:33 +08:00
|
|
|
$(CYGWIN_BINS): %.exe: %.o
|
2002-01-22 11:17:59 +08:00
|
|
|
ifdef VERBOSE
|
2008-03-09 01:52:49 +08:00
|
|
|
$(CXX) -o $@ ${filter %.o,$^} -B$(cygwin_build)/ $(ALL_LDFLAGS)
|
2002-01-22 11:17:59 +08:00
|
|
|
else
|
2008-03-09 01:52:49 +08:00
|
|
|
@echo $(CXX) -o $@ ${filter %.o,$^} ... ${filter-out -B%, $(ALL_LDFLAGS)};\
|
|
|
|
$(CXX) -o $@ ${filter %.o,$^} -B$(cygwin_build)/ $(ALL_LDFLAGS)
|
2002-01-22 11:17:59 +08:00
|
|
|
endif
|
|
|
|
|
2008-03-09 01:52:49 +08:00
|
|
|
# note: how to compile a Cygwin object is covered by the pattern rule in Makefile.common
|
2002-01-22 11:17:59 +08:00
|
|
|
|
2008-03-09 01:52:49 +08:00
|
|
|
# these dependencies ensure that the required in-tree libs are built first
|
|
|
|
$(MINGW_BINS): $(MINGW_DEP_LDLIBS)
|
|
|
|
$(CYGWIN_BINS): $(ALL_DEP_LDLIBS)
|
2002-05-13 13:13:58 +08:00
|
|
|
|
2000-02-18 03:38:33 +08:00
|
|
|
clean:
|
2008-03-09 12:10:10 +08:00
|
|
|
rm -f *.o $(CYGWIN_BINS) $(MINGW_BINS) path-testsuite.cc testsuite.exe
|
2000-02-18 03:38:33 +08:00
|
|
|
|
|
|
|
realclean: clean
|
2008-03-09 01:52:49 +08:00
|
|
|
rm -f Makefile config.cache
|
2000-02-18 03:38:33 +08:00
|
|
|
|
|
|
|
install: all
|
2009-02-24 10:11:14 +08:00
|
|
|
$(SHELL) $(updir1)/mkinstalldirs $(DESTDIR)$(bindir)
|
2008-03-09 17:41:42 +08:00
|
|
|
for i in $(CYGWIN_BINS) ${filter-out testsuite.exe,$(MINGW_BINS)} ; do \
|
2000-02-18 03:38:33 +08:00
|
|
|
n=`echo $$i | sed '$(program_transform_name)'`; \
|
2009-02-24 10:11:14 +08:00
|
|
|
$(INSTALL_PROGRAM) $$i $(DESTDIR)$(bindir)/$$n; \
|
2000-02-18 03:38:33 +08:00
|
|
|
done
|
|
|
|
|
|
|
|
$(cygwin_build)/libcygwin.a: $(cygwin_build)/Makefile
|
|
|
|
@$(MAKE) -C $(@D) $(@F)
|
|
|
|
|
2008-03-09 01:52:49 +08:00
|
|
|
$(MINGW_LIB): $(mingw_build)/Makefile
|
2000-02-18 03:38:33 +08:00
|
|
|
@$(MAKE) -C $(@D) $(@F)
|
|
|
|
|
2000-08-26 00:50:08 +08:00
|
|
|
warn_dumper:
|
2000-09-11 00:56:00 +08:00
|
|
|
@echo '*** Not building dumper.exe since some required libraries are'
|
|
|
|
@echo '*** missing: libbfd.a and libintl.a.'
|
|
|
|
@echo '*** If you need this program, check out the naked-bfd and naked-intl'
|
2008-07-30 14:07:42 +08:00
|
|
|
@echo '*** sources from sourceware.org. Then, configure and build these'
|
2000-09-11 00:56:00 +08:00
|
|
|
@echo '*** libraries. Otherwise, you can safely ignore this warning.'
|
2000-08-26 00:50:08 +08:00
|
|
|
|
2008-03-09 01:52:49 +08:00
|
|
|
warn_cygcheck_zlib:
|
|
|
|
@echo '*** Building cygcheck without package content checking due to missing mingw libz.a.'
|