Skip to content

Commit

Permalink
Makefile: fix target all msvc with specified OUTPUT (#142)
Browse files Browse the repository at this point in the history
* Fix a bug where `make all OUTPUT=some-custom-name` will fail
  * same for `make msvc OUTPUT=some-custom-name`
  • Loading branch information
eric15342335 authored Jun 16, 2024
1 parent ec3d2a7 commit bac788f
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ stocksim: main.o stock.o random_price.o events.o names.o \
$(CXX) $(INCLUDES) $(CXXFLAGS) $^ -o $(OUTPUT)

all: clean
$(MAKE) stocksim
$(MAKE) stocksim OUTPUT=$(OUTPUT)
./$(OUTPUT)

goto: stocksim
Expand Down Expand Up @@ -131,10 +131,16 @@ fix:
git commit -a -m "Formatting: Run clang-format" -m "From Makefile: make fix"
git push

ifeq ($(MAKECMDGOALS),msvc)
ifeq ($(OUTPUT),stocksim)
OUTPUT = stocksim-msvc.exe
endif
endif

msvc: src/*.cpp include/*.h clean
cl -std:c++17 -EHsc -utf-8 -Iinclude -W1 -WX -O1 -guard:cf -MP \
src/*.cpp -Fe:stocksim-msvc.exe
rm *.obj *.ilk || true
src/*.cpp -Fe:$(OUTPUT)
rm *.obj || true

format-check:
clang-format --dry-run --Werror src/*.cpp include/*.h
Expand Down

0 comments on commit bac788f

Please sign in to comment.