OSDN Git Service

Small Makefile improvement.
authorLoRd_MuldeR <mulder2@gmx.de>
Mon, 19 Apr 2021 20:21:07 +0000 (22:21 +0200)
committerLoRd_MuldeR <mulder2@gmx.de>
Mon, 19 Apr 2021 20:21:07 +0000 (22:21 +0200)
Makefile

index 9bc473a..8f3a065 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -9,8 +9,9 @@ STATIC ?= 0
 FLTO   ?= 0
 FPGO   ?= 0
 STRIP  ?= 0
-MARCH  ?= native
-MTUNE  ?= native
+CPU    ?= 0
+MARCH  ?= 0
+MTUNE  ?= 0
 
 # ---------------------------------------------------------------------------
 # Directories
@@ -25,7 +26,17 @@ SUBDIR_LIB := libslunkcrypt
 
 CONFIG =
 LDFLGS =
-CFLAGS = -I$(SUBDIR_LIB)/include -std=gnu99 -Wall -march=$(MARCH) -mtune=$(MTUNE)
+CFLAGS = -I$(SUBDIR_LIB)/include -std=gnu99 -Wall
+
+ifneq ($(CPU),0)
+  CFLAGS += -m$(firstword $(CPU))
+endif
+ifneq ($(MARCH),0)
+  CFLAGS += -march=$(firstword $(MARCH))
+endif
+ifneq ($(MTUNE),0)
+  CFLAGS += -mtune=$(firstword $(MTUNE))
+endif
 
 ifneq ($(ASAN),0)
   CONFIG := _a
@@ -39,7 +50,7 @@ ifneq ($(FLTO),0)
   CFLAGS += -flto -fuse-linker-plugin
 endif
 ifneq ($(FPGO),0)
-  CFLAGS += -fprofile-$(FPGO)
+  CFLAGS += -fprofile-$(firstword $(FPGO))
 endif
 endif
 ifneq ($(NALYZE),0)
@@ -48,13 +59,13 @@ endif
 
 MACHINE := $(shell $(CC) -dumpmachine)
 
-ifneq ($(filter %mingw32 %-windows-gnu %-cygwin %-cygnus,$(MACHINE)),)
+ifeq ($(MACHINE),$(filter %mingw32 %-windows-gnu %-cygwin %-cygnus,$(MACHINE)))
   SUFFIX := .exe
 else
   SUFFIX :=
 endif
 
-ifeq ($(filter %mingw32 %-windows-gnu,$(MACHINE)),)
+ifneq ($(MACHINE),$(filter %mingw32 %-windows-gnu,$(MACHINE)))
   LDFLGS += -lpthread
 endif
 
@@ -66,7 +77,7 @@ ifeq ($(STATIC),1)
   LDFLGS += -static
 endif
 
-ifneq ($(filter %-w64-mingw32 %w64-windows-gnu,$(MACHINE)),)
+ifeq ($(MACHINE),$(filter %-w64-mingw32 %w64-windows-gnu,$(MACHINE)))
   LDFLGS += -mconsole -municode
 endif