Build into dist/, list primes to 1,000,000 with timing, add wiki
This commit is contained in:
@@ -1,36 +1,39 @@
|
||||
# Builds prime_avx2 on Linux (gcc) and Windows (MinGW-w64 / MSYS2 gcc).
|
||||
# Builds prime_avx2 into dist/ on Linux (gcc) and Windows (MinGW-w64 / MSYS2 gcc).
|
||||
# make build
|
||||
# make run build and run
|
||||
# make clean remove build output
|
||||
# make clean remove dist/
|
||||
|
||||
CC ?= gcc
|
||||
CFLAGS ?= -O3 -mavx2 -Wall -Wextra
|
||||
LDLIBS += -lm
|
||||
|
||||
DIST := dist
|
||||
|
||||
ifeq ($(OS),Windows_NT)
|
||||
EXE := .exe
|
||||
RM := del /Q /F
|
||||
# make on Windows may use cmd.exe, which needs backslashes
|
||||
RUN := .\prime_avx2$(EXE)
|
||||
RMTARGET := prime_avx2$(EXE)
|
||||
RUN := $(DIST)\prime_avx2$(EXE)
|
||||
RMDIR := if exist $(DIST) rmdir /S /Q $(DIST)
|
||||
else
|
||||
EXE :=
|
||||
RM := rm -f
|
||||
RUN := ./prime_avx2
|
||||
RMTARGET := prime_avx2
|
||||
RUN := ./$(DIST)/prime_avx2
|
||||
RMDIR := rm -rf $(DIST)
|
||||
endif
|
||||
|
||||
TARGET := prime_avx2$(EXE)
|
||||
TARGET := $(DIST)/prime_avx2$(EXE)
|
||||
|
||||
.PHONY: all run clean
|
||||
|
||||
all: $(TARGET)
|
||||
|
||||
$(TARGET): prime_avx2.c
|
||||
$(TARGET): src/prime_avx2.c | $(DIST)
|
||||
$(CC) $(CFLAGS) $< -o $@ $(LDLIBS)
|
||||
|
||||
$(DIST):
|
||||
mkdir $(DIST)
|
||||
|
||||
run: $(TARGET)
|
||||
$(RUN)
|
||||
|
||||
clean:
|
||||
-$(RM) $(RMTARGET)
|
||||
-$(RMDIR)
|
||||
|
||||
Reference in New Issue
Block a user