45 lines
1.5 KiB
Makefile
45 lines
1.5 KiB
Makefile
UNAME_S := $(shell uname -s)
|
|
|
|
ifeq ($(UNAME_S),Darwin)
|
|
# --- macOS / Apple Silicon ---
|
|
# Apple clang non include il runtime OpenMP: se c'e' libomp di Homebrew lo usa
|
|
# (brew install libomp), altrimenti compila single-thread (i pragma omp sono ignorati).
|
|
# Niente -march: su arm64 NEON e' baseline (i kernel __ARM_NEON si attivano da soli).
|
|
CC = clang
|
|
OMPDIR := $(shell brew --prefix libomp 2>/dev/null)
|
|
ifneq ($(OMPDIR),)
|
|
OMPC = -Xclang -fopenmp -I$(OMPDIR)/include
|
|
OMPL = -L$(OMPDIR)/lib -lomp
|
|
else
|
|
$(warning libomp non trovato: build SINGLE-THREAD. Per il multithread: brew install libomp)
|
|
OMPC =
|
|
OMPL =
|
|
endif
|
|
CFLAGS = -O3 $(OMPC) -Wall -Wextra -Wno-unused-parameter -Wno-misleading-indentation -Wno-unused-function
|
|
LDFLAGS = -lm $(OMPL)
|
|
else
|
|
# --- Linux x86-64 (percorso originale, invariato) ---
|
|
CC = gcc
|
|
# ARCH=native -> ottimizzato per QUESTA macchina (default, piu' veloce).
|
|
# ARCH=x86-64-v3 -> binario PORTABILE su qualsiasi x86-64 moderno con AVX2 (per distribuire).
|
|
# ARCH=x86-64 -> massima compatibilita' (niente AVX2: usa il path scalare di fallback).
|
|
ARCH ?= native
|
|
CFLAGS = -O3 -march=$(ARCH) -fopenmp -Wall -Wextra -Wno-unused-parameter -Wno-misleading-indentation -Wno-unused-function
|
|
LDFLAGS = -lm -fopenmp
|
|
endif
|
|
|
|
all: glm
|
|
|
|
glm: glm.c st.h json.h tok.h tok_unicode.h compat.h
|
|
$(CC) $(CFLAGS) glm.c -o glm $(LDFLAGS)
|
|
|
|
olmoe: olmoe.c st.h json.h
|
|
$(CC) $(CFLAGS) olmoe.c -o olmoe $(LDFLAGS)
|
|
|
|
# binario portabile da distribuire su altre macchine x86-64
|
|
portable:
|
|
$(MAKE) glm ARCH=x86-64-v3
|
|
|
|
clean:
|
|
rm -f olmoe glm
|