From ed0d714686cfe65b3cf8d9fa94bdabe4f5905283 Mon Sep 17 00:00:00 2001 From: LoRd_MuldeR Date: Fri, 9 Sep 2022 23:12:23 +0200 Subject: [PATCH] Some Linux build fixes. --- Makefile | 23 ++++++++++++++++------- crc64.c | 5 ++--- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index 9598e64..7557e10 100644 --- a/Makefile +++ b/Makefile @@ -1,19 +1,28 @@ MACHINE := $(shell $(CC) -dumpmachine || echo unknown) -ifneq (,$(firstword $(filter x86_64-%,$(shell $(CC) -dumpmachine)))) +ifneq (,$(firstword $(filter x86_64-%,$(MACHINE)))) MARCH ?= x86-64 MTUNE ?= nocona else - MARCH ?= i586 - MTUNE ?= pentium2 + ifneq (,$(firstword $(filter i686-%,$(MACHINE)))) + MARCH ?= i586 + MTUNE ?= pentium2 + endif endif -CFLAGS = -Wall -std=gnu99 -O3 -march=$(MARCH) -mtune=$(MTUNE) -DNDEBUG +CFLAGS = -Wall -std=gnu99 -O3 -DNDEBUG + +ifneq (,$(MARCH)) + CFLAGS += -march=$(MARCH) +endif +ifneq (,$(MTUNE)) + CFLAGS += -mtune=$(MTUNE) +endif ifneq (,$(firstword $(filter %mingw32 %-windows-gnu %-cygwin %-cygnus,$(MACHINE)))) - SUFFIX := .exe + OUTNAME := crc64.exe else - SUFFIX := + OUTNAME := crc64 endif ifneq (,$(firstword $(filter %-w64-mingw32 %w64-windows-gnu,$(MACHINE)))) @@ -25,4 +34,4 @@ CFLAGS += -s -static .PHONY: all all: - $(CC) $(CFLAGS) -o crc64$(SUFFIX) crc64.c + $(CC) $(CFLAGS) -o $(OUTNAME) crc64.c diff --git a/crc64.c b/crc64.c index fd905ef..9ae3a38 100644 --- a/crc64.c +++ b/crc64.c @@ -18,8 +18,6 @@ #include #include #include -#else -#include #endif static const int VERSION_MAJOR = 1; @@ -68,7 +66,8 @@ int _dowildcard = -1; #define FPUTS fputs #define FPRINTF fprintf #define FOPEN fopen -#define T(X) (X) +#define __T(X) X +#define T(X) __T(X) #endif