Some compile fixes for Cygwin + improved Makefile to generate version info (on Windows).

This commit is contained in:
LoRd_MuldeR 2020-10-20 17:46:18 +02:00
parent 23df735ba2
commit aeb7d1af4a
Signed by: mulder
GPG Key ID: 2B5913365F57E03F
7 changed files with 28 additions and 17 deletions

View File

@ -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 $@

View File

@ -36,10 +36,10 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="res\SlunkCrypt.rc" />
<Manifest Include="res\compatibility.manifest" />
</ItemGroup>
<ItemGroup>
<Manifest Include="res\Compatibility.manifest" />
<ResourceCompile Include="res\version.rc" />
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>16.0</VCProjectVersion>

View File

@ -43,13 +43,13 @@
</ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="res\SlunkCrypt.rc">
<Filter>Resource Files</Filter>
</ResourceCompile>
</ItemGroup>
<ItemGroup>
<Manifest Include="res\Compatibility.manifest">
<Manifest Include="res\compatibility.manifest">
<Filter>Resource Files</Filter>
</Manifest>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="res\version.rc">
<Filter>Resource Files</Filter>
</ResourceCompile>
</ItemGroup>
</Project>

View File

@ -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)
{

View File

@ -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"