This's the actual thing, a shortened version of makefile of the famous chess engine: Stockfish which will, at bottom doc., be modified -MM -MF <depebdency file> from original -MM > <depebdency file> ( by using variable $@, this mod will be sent as Pull Request) one of -MM -MF will result file having only content of VPATH while -MM > result in complete dependency info #... ### Section 1. General Configuration ### ========================================================================== ### Executable name ifeq ($(COMP),mingw) EXE = stockfish.exe else EXE = stockfish endif ### Installation dir definitions PREFIX = /usr/local BINDIR = $(PREFIX)/bin ### Built-in benchmark for pgo-builds PGOBENCH = ./$(EXE) bench ### Source and object files SRCS = benchmark.cpp bitbase.cpp bitboard.cpp endgame.cpp evaluate.cpp main.cpp \ material.cpp misc.cpp movegen.cpp movepick.cpp pawns.cpp position.cpp psqt.cpp \ search.cpp thread.cpp timeman.cpp tt.cpp uci.cpp ucioption.cpp tune.cpp syzygy/tbprobe.cpp OBJS = $(notdir $(SRCS:.cpp=.o)) VPATH = syzygy ### Establish the operating system name KERNEL = $(shell uname -s) ifeq ($(KERNEL),Linux) OS = $(shell uname -o) endif ### ========================================================================== ### Section 2. High-level Configuration ### ========================================================================== ### 2.1. General and architecture defaults optimize = yes debug = no sanitize = no bits = 64 prefetch = no popcnt = no sse = no pext = no ### 2.2 Architecture specific ifeq ($(ARCH),general-32) arch = any bits = 32 endif ifeq ($(ARCH),x86-32-old) arch = i386 bits = 32 endif #... ### 3.8 Link Time Optimization ### This is a mix of compile and link time options because the lto link phase ### needs access to the optimization flags. ifeq ($(optimize),yes) ifeq ($(debug), no) ifeq ($(comp),$(filter $(comp),gcc clang)) CXXFLAGS += -flto LDFLAGS += $(CXXFLAGS) endif # To use LTO and static linking on windows, the tool chain requires a recent gcc: # gcc version 10.1 in msys2 or TDM-GCC version 9.2 are know to work, older might not. # So, only enable it for a cross from Linux by default. ifeq ($(comp),mingw) ifeq ($(KERNEL),Linux) CXXFLAGS += -flto LDFLAGS += $(CXXFLAGS) endif endif endif endif ### 3.9 Android 5 can only run position independent executables. Note that this ### breaks Android 4.0 and earlier. ifeq ($(OS), Android) CXXFLAGS += -fPIE LDFLAGS += -fPIE -pie endif ### ========================================================================== ### Section 4. Public Targets ### ========================================================================== help: @echo "" @echo "To compile stockfish, type: " @echo "" @echo "make target ARCH=arch [COMP=compiler] [COMPCXX=cxx]" @echo "" @echo "Supported targets:" @echo "" @echo "build > Standard build" @echo "profile-build > PGO build" @echo "strip > Strip executable" @echo "install > Install executable" @echo "clean > Clean up" @echo "" #... @echo "make profile-build ARCH=x86-64-bmi2 COMP=gcc COMPCXX=g++-4.8" @echo "" .PHONY: help build profile-build strip install clean objclean profileclean \ config-sanity icc-profile-use icc-profile-make gcc-profile-use gcc-profile-make \ clang-profile-use clang-profile-make build: config-sanity $(MAKE) ARCH=$(ARCH) COMP=$(COMP) all profile-build: config-sanity objclean profileclean @echo "" @echo "Step 1/4. Building instrumented executable ..." $(MAKE) ARCH=$(ARCH) COMP=$(COMP) $(profile_make) @echo "" @echo "Step 2/4. Running benchmark for pgo-build ..." $(PGOBENCH) > /dev/null @echo "" @echo "Step 3/4. Building optimized executable ..." $(MAKE) ARCH=$(ARCH) COMP=$(COMP) objclean $(MAKE) ARCH=$(ARCH) COMP=$(COMP) $(profile_use) @echo "" @echo "Step 4/4. Deleting profile data ..." $(MAKE) ARCH=$(ARCH) COMP=$(COMP) profileclean #... $(EXE): $(OBJS) $(CXX) -o $@ $(OBJS) $(LDFLAGS) clang-profile-make: $(MAKE) ARCH=$(ARCH) COMP=$(COMP) \ EXTRACXXFLAGS='-fprofile-instr-generate ' \ EXTRALDFLAGS=' -fprofile-instr-generate' \ all clang-profile-use: llvm-profdata merge -output=stockfish.profdata *.profraw $(MAKE) ARCH=$(ARCH) COMP=$(COMP) \ EXTRACXXFLAGS='-fprofile-instr-use=stockfish.profdata' \ EXTRALDFLAGS='-fprofile-use ' \ all gcc-profile-make: $(MAKE) ARCH=$(ARCH) COMP=$(COMP) \ EXTRACXXFLAGS='-fprofile-generate' \ EXTRALDFLAGS='-lgcov' \ all gcc-profile-use: $(MAKE) ARCH=$(ARCH) COMP=$(COMP) \ EXTRACXXFLAGS='-fprofile-use -fno-peel-loops -fno-tracer' \ EXTRALDFLAGS='-lgcov' \ all icc-profile-make: @mkdir -p profdir $(MAKE) ARCH=$(ARCH) COMP=$(COMP) \ EXTRACXXFLAGS='-prof-gen=srcpos -prof_dir ./profdir' \ all icc-profile-use: $(MAKE) ARCH=$(ARCH) COMP=$(COMP) \ EXTRACXXFLAGS='-prof_use -prof_dir ./profdir' \ all .depend: @$(CXX) $(DEPENDFLAGS) $(SRCS) -MM -MF $@ 2> /dev/null include .depend On 6/25/20, gcc-help-request@xxxxxxxxxxx <gcc-help-request@xxxxxxxxxxx> wrote: > Send Gcc-help mailing list submissions to > gcc-help@xxxxxxxxxxx > > To subscribe or unsubscribe via the World Wide Web, visit > http://gcc.gnu.org/mailman/listinfo/gcc-help > or, via email, send a message with subject or body 'help' to > gcc-help-request@xxxxxxxxxxx > > You can reach the person managing the list at > gcc-help-owner@xxxxxxxxxxx > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of Gcc-help digest..." >