4
0
mirror of git://sourceware.org/git/newlib-cygwin.git synced 2025-02-08 10:09:32 +08:00
Jon Turney f3ed5f2fe0
Cygwin: Ensure temporary directory used by tests exists
By default, libltp tests will create temporary files in a subdirectory
of /tmp, which will (nowadays) be located relative to the test DLL (by
assuming that it is in /bin).  This will evaluate to the directory
$target_builddir/winsup/tmp, which doesn't exist.

The location used for these temporary files can be explicitly controlled
by setting the TDIRECTORY env var.  Arrange to set that env var to the
/cygdrive path of a tmp subdirectory of the build directory.

Unfortunately, libltp doesn't clean the temporary directory if
TDIRECTORY is set, and some tests assume they are started in a clean
directory, so we need to do that in tcl.
2020-11-08 14:42:02 +00:00

183 lines
4.7 KiB
Makefile
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Makefile.in for Cygwin's testsuite.
#
# 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.
# This makefile requires GNU make.
SHELL:=@SHELL@
srcdir:=@srcdir@
objdir:=.
libltp_srcdir=$(srcdir)/libltp
target_builddir:=@target_builddir@
target_alias:=@target_alias@
build_alias:=@build_alias@
host_alias:=@host_alias@
DESTDIR=
prefix:=${DESTDIR}@prefix@
program_transform_name:=@program_transform_name@
exec_prefix:=${DESTDIR}@exec_prefix@
bindir:=${DESTDIR}@bindir@
libdir:=${DESTDIR}@libdir@
ifeq ($(target_alias),$(host_alias))
ifeq ($(build_alias),$(host_alias))
tooldir:=$(exec_prefix)
else
tooldir:=$(exec_prefix)/$(target_alias)
endif
else
tooldir:=$(exec_prefix)/$(target_alias)
endif
datarootdir:=@datarootdir@
datadir:=${DESTDIR}@datadir@
infodir:=${DESTDIR}@infodir@
includedir:=${DESTDIR}@includedir@
TESTSUP_INCLUDES:=-I$(libltp_srcdir)/include
#
# --enable options from configure
#
CC:=@CC@
# FIXME: Which is it, CC or CC_FOR_TARGET?
CC_FOR_TARGET:=$(CC)
ifneq (,$(CFLAGS))
override CFLAGS+= -MD $(TESTSUP_INCLUDES)
else
CFLAGS:=@CFLAGS@ -MD $(TESTSUP_INCLUDES)
endif
AR:=@AR@
AR_FLAGS:=qv
MINGW_CC:= @MINGW_CC@
MINGW_CXX:= @MINGW_CXX@
#
# Include common definitions for winsup directory
#
include $(srcdir)/../Makefile.common
VPATH+=$(libltp_srcdir)/lib
override CC:=$(CC) $(GCC_INCLUDE)
export CC
RUNTESTFLAGS =
ifdef VERBOSE
RUNTESTFLAGS = -v
endif
RUNTIME=$(cygwin_build)/cygwin0.dll $(cygwin_build)/libcygwin0.a
TESTSUP_LIB_NAME:=libltp.a
TESTSUP_OFILES:=${sort ${addsuffix .o,${basename ${notdir ${wildcard $(libltp_srcdir)/lib/*.c}}}}}
override ALL_CFLAGS:=${filter-out -O%,$(ALL_CFLAGS)}
override COMPILE_CC:=${filter-out -O%,$(COMPILE_CC)}
override CFLAGS:=${filter-out -O%,$(CFLAGS)}
export CFLAGS
.PHONY: all force dll_ofiles install all_target
.SUFFIXES:
.SUFFIXES: .c .cc .def .a .o .d
all: $(TESTSUP_LIB_NAME)
force:
install:
clean:
-rm -f *.o *.dll *.a *.exp junk *.bak *.base *.exe *.d *.dat
-rm -rf testsuite
maintainer-clean realclean: clean
@echo "This command is intended for maintainers to use;"
@echo "it deletes files that may require special tools to rebuild."
-rm -fr configure
# Rule to build libltp.a
$(TESTSUP_LIB_NAME): $(TESTSUP_OFILES)
$(AR) rcv temp.a $(TESTSUP_OFILES)
mv temp.a $(TESTSUP_LIB_NAME)
$(RUNTIME) : $(cygwin_build)/Makefile
@$(MAKE) --no-print-dir -C $(@D) $(@F)
# Rule to make stub library used by "make check"
#
# These targets are for the dejagnu testsuites. The file site.exp
# contains global variables that all the testsuites will use.
# Set to $(target_alias)/ for cross.
target_subdir = @target_subdir@
# temporary directory to be used for files created by tests (as an absolute,
# /cygdrive path, so it can be understood by the test DLL, which will have
# different mount table)
tmpdir = $(shell cygpath -ma $(objdir)/testsuite/tmp/ | sed -e 's#^\([A-Z]\):#/cygdrive/\L\1#')
site.exp: ./config.status Makefile
@echo "Making a new config file..."
-@rm -f ./tmp?
@touch site.exp
-@mv site.exp site.bak
@echo "## these variables are automatically generated by make ##" > ./tmp0
@echo "# Do not edit here. If you wish to override these values" >> ./tmp0
@echo "# add them to the last section" >> ./tmp0
@echo "set rootme \"`pwd`\"" >> ./tmp0
@echo "set runtime_root \"\$$rootme/../cygwin\"" >> ./tmp0
@echo "set srcdir \"`cd ${srcdir}; pwd`\"" >> ./tmp0
@echo "set host_triplet $(host_canonical)" >> ./tmp0
@echo "set build_triplet $(build_canonical)" >> ./tmp0
@echo "set target_triplet $(target)" >> ./tmp0
@echo "set target_alias $(target_alias)" >> ./tmp0
@echo "set CC \"$(CC)\"" >> ./tmp0
# CFLAGS is set even though it's empty to show we reserve the right to set it.
@echo "set CFLAGS \"$(ALL_CFLAGS)\"" >> ./tmp0
@echo "set MINGW_CXX \"$(MINGW_CXX)\"" >> ./tmp0
@echo "set tmpdir $(tmpdir)" >> ./tmp0
@echo "set ltp_includes \"$(realpath $(libltp_srcdir))/include\"" >> ./tmp0
@echo "## All variables above are generated by configure. Do Not Edit ##" >> ./tmp0
@cat ./tmp0 > site.exp
@cat site.bak | sed \
-e '1,/^## All variables above are.*##/ d' >> site.exp
-@rm -f ./tmp?
testsuite/site.exp: site.exp
if [ -d testsuite ]; then \
true; \
else \
mkdir testsuite; \
fi
rm -rf testsuite/site.exp
cp site.exp testsuite/site.exp
# Note: we set the PATH so that we can pick up cygwin0.dll
check: $(TESTSUP_LIB_NAME) $(RUNTIME) cygrun.exe testsuite/site.exp
rootme=`pwd` ;\
PATH=$$rootme/../cygwin:$${PATH} ;\
cd testsuite; runtest --tool winsup $(RUNTESTFLAGS)
cygrun.o: cygrun.c
$(MINGW_CC) $(MINGW_CFLAGS) -o $@ -c $<
cygrun.exe : cygrun.o
$(MINGW_CC) $(MINGW_LDFLAGS) -o $@ $<
Makefile: Makefile.in $(srcdir)/configure config.status
$(SHELL) config.status