#!/usr/bin/make -f # Target architecture for compilation ARCH = native # Optimization level O = 2 # Flags for the compiler # gnu11 to have clock_gettime because that is not strictly in c11 FLAGS = -std=gnu11 FLAGS += -O$(O) FLAGS += -march=$(ARCH) # Only override gcc default tuning if specified in make command line ifneq (, $(TUNE)) FLAGS += -mtune=$(TUNE) endif FLAGS += -pedantic FLAGS += -Wall FLAGS += -Wextra #FLAGS += -Werror #FLAGS += -Wconversion FLAGS += -Wmissing-prototypes FLAGS += -Wlogical-op FLAGS += -Wdisabled-optimization #FLAGS += -fanalyzer FLAGS += -flto FLAGS += -s FLAGS += -Wl,--gc-sections # Libraries used FLAGS += -lgmp FLAGS += -lrt # Directories where .o files and excecutables will be placed OBJDIR = obj OUTDIR = out MAIN = count # C compiler CC = cc .NOTINTERMEDIATE: # Messages to print during different steps in making MSG_LINKING = Linking: MSG_COMPILING = Compiling C: MSG_CLEANING = Cleaning: MSG_CLEANING_OBJ = Cleaning $(OBJDIR): MSG_CLEANING_OUT = Cleaning $(OUTDIR): # Compile and run the default UI target run: run_count run_%: $(OUTDIR)/%.elf ./$^ 4 # Compile the final excecutable $(OUTDIR)/%.elf: %.c @echo $(MSG_LINKING) $@ @mkdir -p $(@D) $(CC) $(FLAGS) -o $@ $^ # Remove all compilation output and intermediate files clean: @echo $(MSG_CLEANING) @echo $(MSG_CLEANING_OBJ) rm -f $(OBJDIR)/*.o @echo $(MSG_CLEANING_OUT) rm -f $(OUTDIR)/*.elf