From aeb7d1af4a3bc33a0f594032289b30401884f412 Mon Sep 17 00:00:00 2001 From: LoRd_MuldeR Date: Tue, 20 Oct 2020 17:46:18 +0200 Subject: [PATCH] Some compile fixes for Cygwin + improved Makefile to generate version info (on Windows). --- Makefile | 23 ++++++++++++------- frontend/SlunkCrypt.vcxproj | 4 ++-- frontend/SlunkCrypt.vcxproj.filters | 12 +++++----- ...bility.manifest => compatibility.manifest} | 0 frontend/res/{SlunkCrypt.rc => version.rc} | 0 frontend/src/main.c | 2 +- frontend/src/platform.h | 4 ++++ 7 files changed, 28 insertions(+), 17 deletions(-) rename frontend/res/{Compatibility.manifest => compatibility.manifest} (100%) rename frontend/res/{SlunkCrypt.rc => version.rc} (100%) diff --git a/Makefile b/Makefile index 268fa97..d0aae99 100644 --- a/Makefile +++ b/Makefile @@ -21,27 +21,25 @@ CFLAGS = -I$(SUBDIR_LIB)/include -Wall -Wno-trigraphs -march=$(MARCH) -mtune=$(M ifeq ($(DEBUG),1) CFLAGS += -Og -g + CONFIG := _g undefine LDFLGS else CFLAGS += -O3 -DNDEBUG + undefine CONFIG LDFLGS += -static -s endif -ifeq ($(OS),Windows_NT) - LDFLGS += -municode -mconsole -endif +UNAME := $(shell uname) undefine SUFFIX -ifeq ($(OS),Windows_NT) +ifneq ($(filter MINGW% CYGWIN%,$(UNAME)),) SUFFIX := .exe else undefine SUFFIX endif -ifeq ($(DEBUG),1) - CONFIG := _g -else - undefine CONFIG +ifneq ($(filter MINGW%,$(UNAME)),) + LDFLGS += -municode -mconsole endif # --------------------------------------------------------------------------- @@ -60,6 +58,11 @@ OBJECTS_APP := $(patsubst $(SUBDIR_APP)/src/%.c,$(SUBDIR_APP)/obj/%$(CONFIG).o,$ SOURCES_LIB := $(wildcard $(SUBDIR_LIB)/src/*.c) OBJECTS_LIB := $(patsubst $(SUBDIR_LIB)/src/%.c,$(SUBDIR_LIB)/obj/%$(CONFIG).o,$(SOURCES_LIB)) +ifneq ($(filter MINGW% CYGWIN%,$(UNAME)),) + RCFILES_APP := $(wildcard $(SUBDIR_APP)/res/*.rc) + OBJECTS_APP += $(patsubst $(SUBDIR_APP)/res/%.rc,$(SUBDIR_APP)/obj/%.rsrc.o,$(RCFILES_APP)) +endif + # --------------------------------------------------------------------------- # Targets # --------------------------------------------------------------------------- @@ -80,6 +83,10 @@ $(SUBDIR_APP)/obj/%$(CONFIG).o: $(SUBDIR_APP)/src/%.c @mkdir -p $(@D) $(CC) $(CFLAGS) -c $< -o $@ +$(SUBDIR_APP)/obj/%.rsrc.o: $(SUBDIR_APP)/res/%.rc + @mkdir -p $(@D) + windres -o $@ $< + $(SUBDIR_LIB)/obj/%$(CONFIG).o: $(SUBDIR_LIB)/src/%.c @mkdir -p $(@D) $(CC) $(CFLAGS) -c $< -o $@ diff --git a/frontend/SlunkCrypt.vcxproj b/frontend/SlunkCrypt.vcxproj index 652b0fe..b271dd8 100644 --- a/frontend/SlunkCrypt.vcxproj +++ b/frontend/SlunkCrypt.vcxproj @@ -36,10 +36,10 @@ - + - + 16.0 diff --git a/frontend/SlunkCrypt.vcxproj.filters b/frontend/SlunkCrypt.vcxproj.filters index a0ce886..58fb3e4 100644 --- a/frontend/SlunkCrypt.vcxproj.filters +++ b/frontend/SlunkCrypt.vcxproj.filters @@ -43,13 +43,13 @@ - - Resource Files - - - - + Resource Files + + + Resource Files + + \ No newline at end of file diff --git a/frontend/res/Compatibility.manifest b/frontend/res/compatibility.manifest similarity index 100% rename from frontend/res/Compatibility.manifest rename to frontend/res/compatibility.manifest diff --git a/frontend/res/SlunkCrypt.rc b/frontend/res/version.rc similarity index 100% rename from frontend/res/SlunkCrypt.rc rename to frontend/res/version.rc diff --git a/frontend/src/main.c b/frontend/src/main.c index db9e8f1..fca9987 100644 --- a/frontend/src/main.c +++ b/frontend/src/main.c @@ -72,7 +72,7 @@ static void print_manpage(const CHR *const program) static char* read_passphrase(const CHR* const file_name) { - const size_t max_len = SLUNKCRYPT_PWDLEN_MAX + 3U; + const size_t max_len = SLUNKCRYPT_PWDLEN_MAX + 2U; char *buffer = (char*) malloc(max_len * sizeof(char)); if (!buffer) { diff --git a/frontend/src/platform.h b/frontend/src/platform.h index 95fb069..450e9ea 100644 --- a/frontend/src/platform.h +++ b/frontend/src/platform.h @@ -16,6 +16,9 @@ #ifdef _WIN32 #define OS_TYPE "Win" #else +#ifdef __CYGWIN__ +#define OS_TYPE "Cygwin" +#else #ifdef __linux__ #define OS_TYPE "Linux" #else @@ -30,6 +33,7 @@ #endif #endif #endif +#endif #if defined(__x86_64__) || defined(_M_X64) #define CPU_ARCH "x64"