57
57
58
58
# OS specific
59
59
# TODO: support Windows
60
- ifeq ($(UNAME_S ) ,Linux)
61
- CFLAGS += -pthread
62
- CXXFLAGS += -pthread
63
- endif
64
- ifeq ($(UNAME_S ) ,Darwin)
65
- CFLAGS += -pthread
66
- CXXFLAGS += -pthread
67
- endif
68
- ifeq ($(UNAME_S ) ,FreeBSD)
69
- CFLAGS += -pthread
70
- CXXFLAGS += -pthread
71
- endif
72
- ifeq ($(UNAME_S ) ,Haiku)
60
+ ifeq ($(filter $(UNAME_S ) ,Linux Darwin FreeBSD Haiku) ,$(UNAME_S ) )
73
61
CFLAGS += -pthread
74
62
CXXFLAGS += -pthread
75
63
endif
@@ -79,60 +67,38 @@ endif
79
67
# feel free to update the Makefile for your architecture and send a pull request or issue
80
68
ifeq ($(UNAME_M ) ,$(filter $(UNAME_M ) ,x86_64 i686) )
81
69
ifeq ($(UNAME_S),Darwin)
82
- CFLAGS += -mf16c
83
- AVX1_M := $(shell sysctl machdep.cpu.features)
84
- ifneq (,$(findstring FMA,$(AVX1_M)))
85
- CFLAGS += -mfma
86
- endif
87
- ifneq (,$(findstring AVX1.0,$(AVX1_M)))
88
- CFLAGS += -mavx
89
- endif
90
- AVX2_M := $(shell sysctl machdep.cpu.leaf7_features)
91
- ifneq (,$(findstring AVX2,$(AVX2_M)))
92
- CFLAGS += -mavx2
93
- endif
70
+ CPUINFO_CMD := sysctl machdep.cpu.features
94
71
else ifeq ($(UNAME_S),Linux)
95
- AVX2_M := $(shell grep "avx2 " /proc/cpuinfo)
72
+ CPUINFO_CMD := cat /proc/cpuinfo
73
+ else ifeq ($(UNAME_S),Haiku)
74
+ CPUINFO_CMD := sysinfo -cpu
75
+ endif
76
+
77
+ ifdef CPUINFO_CMD
78
+ AVX2_M := $(shell $(CPUINFO_CMD) | grep -m 1 "avx2 ")
96
79
ifneq (,$(findstring avx2,$(AVX2_M)))
97
80
CFLAGS += -mavx2
98
81
endif
99
- FMA_M := $(shell grep "fma " /proc/cpuinfo)
82
+
83
+ FMA_M := $(shell $(CPUINFO_CMD) | grep -m 1 "fma ")
100
84
ifneq (,$(findstring fma,$(FMA_M)))
101
85
CFLAGS += -mfma
102
86
endif
103
- F16C_M := $(shell grep "f16c " /proc/cpuinfo)
87
+
88
+ F16C_M := $(shell $(CPUINFO_CMD) | grep -m 1 "f16c ")
104
89
ifneq (,$(findstring f16c,$(F16C_M)))
105
90
CFLAGS += -mf16c
106
91
107
- AVX1_M := $(shell grep "avx " /proc/cpuinfo )
92
+ AVX1_M := $(shell $(CPUINFO_CMD) | grep -m 1 "avx ")
108
93
ifneq (,$(findstring avx,$(AVX1_M)))
109
94
CFLAGS += -mavx
110
95
endif
111
96
endif
112
- SSE3_M := $(shell grep "sse3 " /proc/cpuinfo)
97
+
98
+ SSE3_M := $(shell $(CPUINFO_CMD) | grep -m 1 "sse3 ")
113
99
ifneq (,$(findstring sse3,$(SSE3_M)))
114
100
CFLAGS += -msse3
115
101
endif
116
- else ifeq ($(UNAME_S),Haiku)
117
- AVX2_M := $(shell sysinfo -cpu | grep "AVX2 ")
118
- ifneq (,$(findstring avx2,$(AVX2_M)))
119
- CFLAGS += -mavx2
120
- endif
121
- FMA_M := $(shell sysinfo -cpu | grep "FMA ")
122
- ifneq (,$(findstring fma,$(FMA_M)))
123
- CFLAGS += -mfma
124
- endif
125
- F16C_M := $(shell sysinfo -cpu | grep "F16C ")
126
- ifneq (,$(findstring f16c,$(F16C_M)))
127
- CFLAGS += -mf16c
128
-
129
- AVX1_M := $(shell sysinfo -cpu | grep "AVX ")
130
- ifneq (,$(findstring avx,$(AVX1_M)))
131
- CFLAGS += -mavx
132
- endif
133
- endif
134
- else
135
- CFLAGS += -mfma -mf16c -mavx -mavx2
136
102
endif
137
103
endif
138
104
ifeq ($(UNAME_M ) ,amd64)
0 commit comments