From ff238e224d4e7cf66224bbc5bf2157e788fd7541 Mon Sep 17 00:00:00 2001 From: cathugger Date: Sun, 31 Mar 2019 23:16:58 +0300 Subject: [PATCH] proper extensions for windows executables --- Makefile.in | 17 +++++++++-------- configure.ac | 24 +++++++++++++++++++++--- 2 files changed, 30 insertions(+), 11 deletions(-) diff --git a/Makefile.in b/Makefile.in index 37fc000..7e18db2 100644 --- a/Makefile.in +++ b/Makefile.in @@ -68,32 +68,33 @@ CLEANO= $(filter %.o,$(ALLO)) MAINLIB= -lpthread -lsodium @MAINLIB@ TEST_ED25519LIB= -lsodium -EXE= mkp224o test_base64 test_base32 test_base16 test_ed25519 +ALLTGTS= mkp224o test_base64 test_base32 test_base16 test_ed25519 +ALLEXE= $(patsubst %,%@EXESFX@,$(ALLTGTS)) .PHONY: default all clean distclean depend default: mkp224o -all: $(EXE) +all: $(ALLEXE) -mkp224o: $(MAINOBJ) +mkp224o@EXESFX@: $(MAINOBJ) $(CC) $(LDFLAGS) $(CFLAGS) -o $@.tmp $^ $(MAINLIB) && $(MV) $@.tmp $@ -test_base64: $(TEST_BASE64OBJ) +test_base64@EXESFX@: $(TEST_BASE64OBJ) $(CC) $(LDFLAGS) $(CFLAGS) -o $@.tmp $^ && $(MV) $@.tmp $@ -test_base32: $(TEST_BASE32OBJ) +test_base32@EXESFX@: $(TEST_BASE32OBJ) $(CC) $(LDFLAGS) $(CFLAGS) -o $@.tmp $^ && $(MV) $@.tmp $@ -test_base16: $(TEST_BASE16OBJ) +test_base16@EXESFX@: $(TEST_BASE16OBJ) $(CC) $(LDFLAGS) $(CFLAGS) -o $@.tmp $^ && $(MV) $@.tmp $@ -test_ed25519: $(TEST_ED25519OBJ) +test_ed25519@EXESFX@: $(TEST_ED25519OBJ) $(CC) $(LDFLAGS) $(CFLAGS) -o $@.tmp $^ $(TEST_ED25519LIB) && $(MV) $@.tmp $@ clean: $(RM) $(CLEANO) - $(RM) $(EXE) + $(RM) $(ALLEXE) distclean: clean $(RM) -r autom4te.cache diff --git a/configure.ac b/configure.ac index 8e88701..cb36cdf 100644 --- a/configure.ac +++ b/configure.ac @@ -209,16 +209,27 @@ then ) fi -CFLAGS="$cstd -Wno-pedantic-ms-format -Werror" -AC_MSG_CHECKING([whether CC supports and needs -Wno-pedantic-ms-format]) +WIN=0 +AC_MSG_CHECKING([whether CC compiles for Windows API]) AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#ifndef _WIN32 #error wants windows #endif]], [])], [AC_MSG_RESULT([yes])] - [cstd="$cstd -Wno-pedantic-ms-format"], + [WIN=1], [AC_MSG_RESULT([no])] ) +if test "$WIN" -eq 1 +then + CFLAGS="$cstd -Wno-pedantic-ms-format -Werror" + AC_MSG_CHECKING([whether CC supports and needs -Wno-pedantic-ms-format]) + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])], + [AC_MSG_RESULT([yes])] + [cstd="$cstd -Wno-pedantic-ms-format"], + [AC_MSG_RESULT([no])] + ) +fi + if test "x$ed25519impl" = "xdonna" then CFLAGS="$cstd -Wno-unused-function -Werror" @@ -309,6 +320,12 @@ yes|pcre2) ;; esac +EXESFX='' +if test "$WIN" -eq 1 +then + EXESFX='.exe' +fi + # recreate dir tree, because otherwise gcc will fuck up (cd "$srcdir" && find ed25519 -type d) | xargs mkdir -p @@ -318,4 +335,5 @@ AC_SUBST(MYDEFS,["$MYDEFS"]) AC_SUBST(MAINLIB,["$MAINLIB"]) AC_SUBST(NOPIE,["$nopie"]) AC_SUBST(SRCDIR,["$srcdir"]) +AC_SUBST(EXESFX,["$EXESFX"]) AC_OUTPUT(Makefile)