You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
shuffle3/Makefile

81 lines
1.8 KiB

4 years ago
SRC_C = $(wildcard src/*.c)
SRC_CXX = $(wildcard src/*.cpp)
SRC_CXX+= $(wildcard src/rng/*.cpp)
INCLUDE = include
5 years ago
4 years ago
PROJECT=shuffle3
5 years ago
4 years ago
COMMON_FLAGS = -Wall -pedantic $(addprefix -I,$(INCLUDE)) -fno-strict-aliasing
5 years ago
4 years ago
OPT_FLAGS?= -march=native -fgraphite -fopenmp -floop-parallelize-all -ftree-parallelize-loops=4 \
4 years ago
-floop-interchange -ftree-loop-distribution -floop-strip-mine -floop-block \
-fno-stack-check
4 years ago
4 years ago
CXX_OPT_FLAGS?= $(OPT_FLAGS) -felide-constructors
4 years ago
4 years ago
CFLAGS += $(COMMON_FLAGS) --std=gnu11
CXXFLAGS += $(COMMON_FLAGS) --std=gnu++20 -fno-exceptions
LDFLAGS +=
4 years ago
STRIP=strip
4 years ago
RELEASE_CFLAGS?= -O3 -flto $(OPT_FLAGS)
RELEASE_CXXFLAGS?= -O3 -flto $(CXX_OPT_FLAGS)
RELEASE_LDFLAGS?= -O3 -flto
DEBUG_CFLAGS?= -O0 -g -DDEBUG
DEBUG_CXXFLAGS?= $(DEBUG_CFLAGS)
DEBUG_LDFLAGS?=
# Objects
OBJ_C = $(addprefix obj/c/,$(SRC_C:.c=.o))
OBJ_CXX = $(addprefix obj/cxx/,$(SRC_CXX:.cpp=.o))
OBJ = $(OBJ_C) $(OBJ_CXX)
# Phonies
4 years ago
.PHONY: release
4 years ago
release: | dirs $(PROJECT)-release
4 years ago
.PHONY: debug
4 years ago
debug: | dirs $(PROJECT)-debug
.PHONY: test
test: test-all
4 years ago
# Targets
5 years ago
4 years ago
dirs:
4 years ago
@mkdir -p obj/c{,xx}/src
@mkdir -p obj/cxx/src/rng
4 years ago
4 years ago
obj/c/%.o: %.c
4 years ago
$(CC) -c $< $(CFLAGS) -o $@ $(LDFLAGS)
4 years ago
obj/cxx/%.o: %.cpp
$(CXX) -c $< $(CXXFLAGS) -o $@ $(LDFLAGS)
$(PROJECT)-release: CFLAGS+= $(RELEASE_CFLAGS)
$(PROJECT)-release: CXXFLAGS += $(RELEASE_CXXFLAGS)
$(PROJECT)-release: LDFLAGS += $(RELEASE_LDFLAGS)
$(PROJECT)-release: $(OBJ)
$(CXX) $^ $(CXXFLAGS) -o $@ $(LDFLAGS)
$(STRIP) $@
4 years ago
4 years ago
$(PROJECT)-debug: CFLAGS+= $(DEBUG_CFLAGS)
$(PROJECT)-debug: CXXFLAGS += $(DEBUG_CXXFLAGS)
$(PROJECT)-debug: LDFLAGS += $(DEBUG_LDFLAGS)
$(PROJECT)-debug: $(OBJ)
$(CXX) $^ $(CXXFLAGS) -o $@ $(LDFLAGS)
4 years ago
clean:
rm -rf obj
4 years ago
rm -f $(PROJECT)-{release,debug}
test-all:
@./test.sh ./$(PROJECT)-debug ./$(PROJECT)-release