Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 23 additions & 23 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -157,50 +157,50 @@ Compat.ml: Compat.ml.in COMPILER-$(COMPAT_VERSION)

flexlink.exe: $(OBJS) $(RES)
@echo Building flexlink.exe with TOOLCHAIN=$(TOOLCHAIN) for OCaml $(OCAML_VERSION)
rm -f flexlink.exe
$(RES_PREFIX) $(OCAMLOPT) -o flexlink.exe $(LINKFLAGS) $(OBJS)
rm -f $@
$(RES_PREFIX) $(OCAMLOPT) -o $@ $(LINKFLAGS) $(OBJS)

version.res: version.rc
$(RES_PREFIX) rc version.rc
$(RES_PREFIX) rc $<

version_res.o: version.rc
$(TOOLPREF)windres version.rc version_res.o
$(TOOLPREF)windres -i $< -o $@

flexdll_msvc.obj: flexdll.h flexdll.c
$(MSVC_PREFIX) $(MSVCC) /DMSVC -c /Fo"flexdll_msvc.obj" flexdll.c
flexdll_msvc.obj: flexdll.c flexdll.h
$(MSVC_PREFIX) $(MSVCC) /DMSVC -c /Fo"$@" $<

flexdll_msvc64.obj: flexdll.h flexdll.c
$(MSVC64_PREFIX) $(MSVCC64) /DMSVC /DMSVC64 -c /Fo"flexdll_msvc64.obj" flexdll.c
flexdll_msvc64.obj: flexdll.c flexdll.h
$(MSVC64_PREFIX) $(MSVCC64) /DMSVC /DMSVC64 -c /Fo"$@" $<

flexdll_cygwin64.o: flexdll.h flexdll.c
$(CYG64CC) -c -DCYGWIN -o flexdll_cygwin64.o flexdll.c
flexdll_cygwin64.o: flexdll.c flexdll.h
$(CYG64CC) -DCYGWIN -c -o $@ $<

flexdll_mingw.o: flexdll.h flexdll.c
$(MINCC) -c -DMINGW -o flexdll_mingw.o flexdll.c
flexdll_mingw.o: flexdll.c flexdll.h
$(MINCC) -DMINGW -c -o $@ $<

flexdll_gnat.o: flexdll.h flexdll.c
gcc -c -o flexdll_gnat.o flexdll.c
flexdll_gnat.o: flexdll.c flexdll.h
gcc -c -o $@ $<

flexdll_mingw64.o: flexdll.h flexdll.c
$(MIN64CC) -c -DMINGW -o flexdll_mingw64.o flexdll.c
flexdll_mingw64.o: flexdll.c flexdll.h
$(MIN64CC) -DMINGW -c -o $@ $<

flexdll_initer_msvc.obj: flexdll_initer.c
$(MSVC_PREFIX) $(MSVCC) -c /Fo"flexdll_initer_msvc.obj" flexdll_initer.c
$(MSVC_PREFIX) $(MSVCC) -c /Fo"$@" $<

flexdll_initer_msvc64.obj: flexdll_initer.c
$(MSVC64_PREFIX) $(MSVCC64) -c /Fo"flexdll_initer_msvc64.obj" flexdll_initer.c
$(MSVC64_PREFIX) $(MSVCC64) -c /Fo"$@" $<

flexdll_initer_cygwin64.o: flexdll_initer.c
$(CYG64CC) -c -o flexdll_initer_cygwin64.o flexdll_initer.c
$(CYG64CC) -c -o $@ $<

flexdll_initer_mingw.o: flexdll_initer.c
$(MINCC) -c -o flexdll_initer_mingw.o flexdll_initer.c
$(MINCC) -c -o $@ $<

flexdll_initer_gnat.o: flexdll_initer.c
gcc -c -o flexdll_initer_gnat.o flexdll_initer.c
gcc -c -o $@ $<

flexdll_initer_mingw64.o: flexdll_initer.c
$(MIN64CC) -c -o flexdll_initer_mingw64.o flexdll_initer.c
$(MIN64CC) -c -o $@ $<


demo_msvc: flexlink.exe flexdll_msvc.obj flexdll_initer_msvc.obj
Expand All @@ -223,7 +223,7 @@ distclean: clean

clean:
rm -f *.obj *.o *.lib *.a *.exe *.opt *.cmx *.dll *.exp *.cmi *.cmo *~ version.res version.ml COMPILER-* Compat.ml
cd test && $(MAKE) clean
$(MAKE) -C test clean


## Packaging
Expand Down
31 changes: 17 additions & 14 deletions msvs-detect
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# ################################################################################################ #
# Microsoft C Compiler Environment Detection Script #
# ################################################################################################ #
# Copyright (c) 2016, 2017, 2018, 2019, 2020 MetaStack Solutions Ltd. #
# Copyright (c) 2016, 2017, 2018, 2019, 2020, 2021 MetaStack Solutions Ltd. #
# ################################################################################################ #
# Author: David Allsopp #
# 16-Feb-2016 #
Expand All @@ -27,7 +27,7 @@
# of this software, even if advised of the possibility of such damage. #
# ################################################################################################ #

VERSION=0.4.1
VERSION=0.6.0

# debug [level=2] message
debug ()
Expand Down Expand Up @@ -204,13 +204,6 @@ SCAN_ENV=0
# Various PATH messing around means it's sensible to know where tools are now
WHICH=$(which which)

if [[ $(uname --operating-system 2>/dev/null) = "Msys" ]] ; then
# Prevent MSYS from translating command line switches to paths
SWITCH_PREFIX='//'
else
SWITCH_PREFIX='/'
fi

# Parse command-line. At the moment, the short option which usefully combines with anything is -d,
# so for the time being, combining short options is not permitted, as the loop becomes even less
# clear with getopts. GNU getopt isn't installed by default on Cygwin...
Expand Down Expand Up @@ -337,7 +330,7 @@ if [[ $MODE -eq 1 ]] ; then
MSVS_PREFERENCE=
SCAN_ENV=1
elif [[ -z ${MSVS_PREFERENCE+x} ]] ; then
MSVS_PREFERENCE='@;VS16.*;VS15.*;VS14.0;VS12.0;VS11.0;10.0;9.0;8.0;7.1;7.0'
MSVS_PREFERENCE='@;VS17.*;VS16.*;VS15.*;VS14.0;VS12.0;VS11.0;10.0;9.0;8.0;7.1;7.0'
fi

MSVS_PREFERENCE=${MSVS_PREFERENCE//;/ }
Expand Down Expand Up @@ -480,6 +473,9 @@ COMPILERS=(
["VS16.*"]='(
["NAME"]="Visual Studio 2019"
["VSWHERE"]="1")'
["VS17.*"]='(
["NAME"]="Visual Studio 2022"
["VSWHERE"]="1")'
["SDK5.2"]='(
["NAME"]="Windows Server 2003 SP1 SDK"
["VC_VER"]="8.0"
Expand Down Expand Up @@ -733,7 +729,7 @@ if [[ -x $VSWHERE ]] ; then
warning "vcvarsall.bat not found for $INSTANCE"
fi;;
esac
done < <("$VSWHERE" -all -nologo | tr -d '\r')
done < <("$VSWHERE" -all -products '*' -nologo | tr -d '\r')
fi

if [[ $DEBUG -gt 1 ]] ; then
Expand Down Expand Up @@ -920,6 +916,8 @@ for i in "${TEST[@]}" ; do
if [[ $DEBUG -gt 3 ]] ; then
printf "Scanning %s... " "$(basename "$SCRIPT") $ARCH_SWITCHES $SCRIPT_SWITCHES">&2
fi
# Setting MSYS2_ARG_CONV_EXCL to * inhibits attempts to convert the flags to COMSPEC as
# command line parameters.
num=0
while IFS= read -r line; do
case $num in
Expand All @@ -933,7 +931,8 @@ for i in "${TEST[@]}" ; do
((num++))
done < <(INCLUDE='' LIB='' PATH="?msvs-detect?:$DIR:$PATH" ORIGINALPATH='' \
EXEC_SCRIPT="$(basename "$SCRIPT") $ARCH_SWITCHES $SCRIPT_SWITCHES" \
$(cygpath "$COMSPEC") ${SWITCH_PREFIX}v:on ${SWITCH_PREFIX}c $COMMAND 2>/dev/null | grep -F XMARKER -A 3 | tr -d '\015' | tail -3)
MSYS2_ARG_CONV_EXCL='*' \
$(cygpath "$COMSPEC") /v:on /c $COMMAND 2>/dev/null | grep -F XMARKER -A 3 | tr -d '\015' | tail -3)
if [[ $DEBUG -gt 3 ]] ; then
echo done>&2
fi
Expand Down Expand Up @@ -977,8 +976,12 @@ for i in "${TEST[@]}" ; do
TEST_cl=${TEST_cl,,}
TEST_cl=${TEST_cl/bin\/*_/bin\/}
if [[ $TEST_cl = $ENV_cl ]] ; then
if [[ ${!ENV_INC/"$MSVS_INC"/} != "${!ENV_INC}" && \
${!ENV_LIB/"$MSVS_LIB"/} != "${!ENV_LIB}" ]] ; then
# Create trailing semi-colon versions of the expansions of ENV_ for comparison with MSVS_
ENV_EXPAND_INC="${!ENV_INC%%;};"
ENV_EXPAND_LIB="${!ENV_LIB%%;};"

if [[ ${ENV_EXPAND_INC/"$MSVS_INC"/} != "${ENV_EXPAND_INC}" && \
${ENV_EXPAND_LIB/"$MSVS_LIB"/} != "${ENV_EXPAND_LIB}" ]] ; then
debug "$i-$arch is a strong candidate for the Environment C compiler"
if [[ -n ${ENV_COMPILER+x} ]] ; then
if [[ -z ${ENV_COMPILER} ]] ; then
Expand Down