newlib/winsup/utils/Makefile.in
Corinna Vinschen 6e1e3bb8e5 * Makefile.in (cygcheck.exe): Link against psapi.dll.
* bloda.cc: Change include section to work with Mingw64 headers.
	Include psapi.h.  Use SystemProcessInformation instead of
	SystemProcessesAndThreadsInformation throughout and add define for
	w32api headers.  Ditto for PSYSTEM_PROCESS_INFORMATION vs.
	PSYSTEM_PROCESSES.
	(system_module_list): New type to replace SYSTEM_MODULE_INFORMATION.
	Change usage throughout accordingly.
	(get_module_list): Fetch module list using PSAPI functions
	EnumDeviceDrivers and GetDeviceDriverBaseNameA.
	* cygcheck.cc (max): Define as __max if not defined already.
	(alloca): Only define if not defined already.
	(handle_unique_object_name): Use explicit sharing flags rather than
	FILE_SHARE_VALID_FLAGS which officially is only available in DDK
	headers.
	(PRODUCT_ULTIMATE_E): Only define if not defined already.
	* dump_setup.cc: Change include section to work with Mingw64 headers.
	(NtQueryAttributesFile): Drop NTOSAPI aka DECLSPEC_IMPORT.
	* strace.cc: Change include section to work with Mingw64 headers.
	(alloca): Only define if not defined already.
2012-07-11 16:41:51 +00:00

195 lines
6.9 KiB
Makefile

# Makefile for Cygwin utilities
# Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
# 2005, 2006, 2007, 2008, 2009, 2010 Red Hat, Inc.
# 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@
override INSTALL:=@INSTALL@
override INSTALL_PROGRAM:=@INSTALL_PROGRAM@
override INSTALL_DATA:=@INSTALL_DATA@
EXEEXT:=@EXEEXT@
EXEEXT_FOR_BUILD:=@EXEEXT_FOR_BUILD@
CC:=@CC@
CC_FOR_TARGET:=$(CC)
CXX:=@CXX@
CXX_FOR_TARGET:=$(CXX)
CFLAGS:=@CFLAGS@
CXXFLAGS:=@CXXFLAGS@
override CXXFLAGS+=-fno-exceptions -fno-rtti -DHAVE_DECL_GETOPT=0
include $(srcdir)/../Makefile.common
.SUFFIXES:
.NOEXPORT:
.PHONY: all install clean realclean warn_dumper warn_cygcheck_zlib
ALL_LDLIBS := -lnetapi32 -ladvapi32
ALL_LDFLAGS := -static-libgcc -Wl,--enable-auto-import -B$(newlib_build)/libc -B$(w32api_lib) $(LDFLAGS) $(ALL_LDLIBS)
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)
MINGW_CXX := ${srcdir}/mingw ${CXX} -I${updir}
# List all binaries to be linked in Cygwin mode. Each binary on this list
# must have a corresponding .o of the same name.
CYGWIN_BINS := ${addsuffix .exe,cygpath getconf getfacl ldd locale kill mkgroup \
mkpasswd mount passwd pldd ps regtool setfacl setmetamode ssp tzset umount}
# List all binaries to be linked in MinGW mode. Each binary on this list
# must have a corresponding .o of the same name.
MINGW_BINS := ${addsuffix .exe,cygcheck cygwin-console-helper ldh strace}
# 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.
MINGW_OBJS := bloda.o cygcheck.o dump_setup.o ldh.o path.o strace.o
# 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
path-mount.o: path.cc
$(CXX) -c $(CXXFLAGS) -DFSTAB_ONLY -I$(updir) $< -o $@
mount.exe: path-mount.o
# Provide any necessary per-target variable overrides.
cygcheck.exe: MINGW_LDFLAGS += -lpsapi -lntdll
cygpath.exe: ALL_LDFLAGS += -lcygwin -luserenv -lntdll
cygpath.exe: CXXFLAGS += -fno-threadsafe-statics
ps.exe: ALL_LDFLAGS += -lcygwin -lpsapi -lntdll
strace.exe: MINGW_LDFLAGS += -lntdll
ldd.exe: ALL_LDFLAGS += -lpsapi
pldd.exe: ALL_LDFLAGS += -lpsapi
ldh.exe: MINGW_LDLIBS :=
ldh.exe: MINGW_LDFLAGS := -nostdlib -lkernel32
# 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}
bfdlink := $(shell ${CC} -xc /dev/null -o /dev/null -c -B${bupdir2}/bfd/ -include bfd.h 2>&1)
build_dumper := ${shell test -r $(libbfd) -a -r $(libintl) -a -n "$(LIBICONV)" -a -z "${bfdlink}" && 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
dumper.exe: ALL_LDFLAGS += ${libbfd} ${libintl} -L$(bupdir1)/libiberty $(LIBICONV) -liberty -lz
else
all: warn_dumper
endif
# Check for availability of a MinGW libz and enable for cygcheck.
libz:=${shell x=$$(${MINGW_CXX} --print-file-name=libz.a); cd $$(dirname $$x); dir=$$(pwd); case "$$dir" in *mingw*) echo $$dir/libz.a ;; esac}
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)
cygcheck.exe: MINGW_LDFLAGS += $(libz)
else
all: warn_cygcheck_zlib
endif
all: Makefile $(CYGWIN_BINS) $(MINGW_BINS)
# 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
# how to compile a MinGW object
$(MINGW_OBJS): %.o: %.cc
ifdef VERBOSE
$(MINGW_CXX) $c -o $(@D)/$(basename $@)$o $(MINGW_CXXFLAGS) $<
else
@echo $(MINGW_CXX) $c $(MINGW_CXXFLAGS) ... $(*F).cc;\
$(MINGW_CXX) $c -o $(@D)/$(basename $@)$o $(MINGW_CXXFLAGS) $<
endif
# how to link a MinGW binary
$(MINGW_BINS): %.exe: %.o
ifdef VERBOSE
$(MINGW_CXX) $(MINGW_CXXFLAGS) -o $@ ${filter %.o,$^} -B$(mingw_build)/ $(MINGW_LDFLAGS)
else
@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)
endif
# how to link a Cygwin binary
$(CYGWIN_BINS): %.exe: %.o
ifdef VERBOSE
$(CXX) -o $@ ${filter %.o,$^} -B$(cygwin_build)/ $(ALL_LDFLAGS)
else
@echo $(CXX) -o $@ ${filter %.o,$^} ... ${filter-out -B%, $(ALL_LDFLAGS)};\
$(CXX) -o $@ ${filter %.o,$^} -B$(cygwin_build)/ $(ALL_LDFLAGS)
endif
# note: how to compile a Cygwin object is covered by the pattern rule in Makefile.common
# these dependencies ensure that the required in-tree libs are built first
$(MINGW_BINS): $(MINGW_DEP_LDLIBS)
$(CYGWIN_BINS): $(ALL_DEP_LDLIBS)
clean:
rm -f *.o $(CYGWIN_BINS) $(MINGW_BINS) path-testsuite.cc testsuite.exe
realclean: clean
rm -f Makefile config.cache
install: all
$(SHELL) $(updir1)/mkinstalldirs $(DESTDIR)$(bindir)
for i in $(CYGWIN_BINS) ${filter-out testsuite.exe,$(MINGW_BINS)} ; do \
n=`echo $$i | sed '$(program_transform_name)'`; \
$(INSTALL_PROGRAM) $$i $(DESTDIR)$(bindir)/$$n; \
done
$(cygwin_build)/libcygwin.a: $(cygwin_build)/Makefile
@$(MAKE) -C $(@D) $(@F)
$(MINGW_LIB): $(mingw_build)/Makefile
@$(MAKE) -C $(@D) $(@F)
warn_dumper:
@echo '*** Not building dumper.exe since some required libraries or'
@echo '*** or headers are missing. Potential candidates are:'
@echo '*** bfd.h, libbfd.a, libiconv.a, or libintl.a'
@echo '*** If you need this program, check out the naked-bfd and naked-intl'
@echo '*** sources from sourceware.org. Then, configure and build these'
@echo '*** libraries. Otherwise, you can safely ignore this warning.'
warn_cygcheck_zlib:
@echo '*** Building cygcheck without package content checking due to missing mingw libz.a.'