Skip to content
This repository has been archived by the owner on Jul 2, 2024. It is now read-only.

Commit

Permalink
Add optimization option to Makefile. (#283)
Browse files Browse the repository at this point in the history
  • Loading branch information
theclashingfritz authored Feb 19, 2023
1 parent 3bc0b13 commit eac1683
Showing 1 changed file with 32 additions and 8 deletions.
40 changes: 32 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ DISCORDRPC ?= 0
DISCORD_SDK ?= 1
# Enable docker build workarounds
DOCKERBUILD ?= 0
# Sets your optimization level for building.
# A choose is chosen by default for you.
OPT_LEVEL ?= -1
# Enable compiling with more debug info.
DEBUG_INFO_LEVEL ?= 2
# Enable profiling
Expand Down Expand Up @@ -199,16 +202,37 @@ else ifeq ($(VERSION),sh)
endif

# Determine our optimization level.
ifeq ($(DEBUG),0)
# Can't use O2 or higher right now for auto-builders, coop-compiler produces strange graphical errors
# likely due to undefined behavior somewhere
#ifeq ($(WINDOWS_AUTO_BUILDER),1)
# OPT_FLAGS := -O1
#else
# Optimization Levels 0 through 5 optimize for speed,
# While optimization levels 6, and 7 optimize for size.
# If no optimization is specified, A default is chosen.
ifeq ($(OPT_LEVEL),0) # No optimization
OPT_FLAGS := -O0
else ifeq ($(OPT_LEVEL),1) # Debugging optimization
OPT_FLAGS := -Og
else ifeq ($(OPT_LEVEL),2) # Level 1 Optimization
OPT_FLAGS := -O1
else ifeq ($(OPT_LEVEL),3) # Level 2 Optimization
OPT_FLAGS := -O2
#endif
else ifeq ($(OPT_LEVEL),4) # Level 3 Optimization
OPT_FLAGS := -O3
else ifeq ($(OPT_LEVEL),5) # Fastest Optimization
OPT_FLAGS := -Ofast
else ifeq ($(OPT_LEVEL),6) # Size Optimization
OPT_FLAGS := -Os
else ifeq ($(OPT_LEVEL),7) # Aggresive Size Optimization
OPT_FLAGS := -Oz
else
OPT_FLAGS := -O0
ifeq ($(DEBUG),0)
# Can't use O2 or higher right now for auto-builders, coop-compiler produces strange graphical errors
# likely due to undefined behavior somewhere
#ifeq ($(WINDOWS_AUTO_BUILDER),1)
# OPT_FLAGS := -O1
#else
OPT_FLAGS := -O2
#endif
else
OPT_FLAGS := -O0
endif
endif

# Set our level of debug symbol info,
Expand Down

0 comments on commit eac1683

Please sign in to comment.