-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
46 lines (35 loc) · 1.09 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# recursive file search
rwildcard=$(foreach d,$(wildcard $(1:=/*)),$(call rwildcard,$d,$2) $(filter $(subst *,%,$2),$d))
SHELL := powershell.exe
.SHELLFLAGS := -NoProfile -Command
CMD=powershell -NoProfile -Command
CC=cl
CFLAGS=/nologo /EHsc /I header
LINK=link
LFLAGS=/nologo /SUBSYSTEM:CONSOLE /DEBUG:FULL
EXE=target.exe
BUILD=build
SRC=source
OBJ=artifacts
BIN=bin
CLOG=compile.log
LLOG=link.log
CFILES=$(call rwildcard,$(SRC),*.cpp) # search for *.cpp files
OFILES=$(CFILES:.cpp=.obj) # object file names
LSOBJ := $(CMD) "(ls $(OBJ) -Recurse -Include *.obj | Resolve-Path -Relative) -join ' '"
DELOBJ=del $$PSItem.FullName -Recurse
.ONESHELL:
%.obj : %.cpp
$(eval folder=$(subst $(SRC),$(OBJ),$(@D)))
$(eval result=$(folder)/$(@F))
@$(CMD) "if (-not (Test-Path $(folder))) { mkdir $(folder) }"
@$(CC) $(CFLAGS) /Fo$(result) /c $<
compile : $(OFILES)
link :
$(eval objects=$(shell $(LSOBJ)))
$(LINK) $(objects) $(LFLAGS) /OUT:$(EXE)
build : compile link
clean :
$(CMD) "if (Test-Path $(OBJ)) { del $(OBJ) -Recurse }"
$(CMD) "if (Test-Path $(EXE)) { del $(EXE) -Recurse }"
rebuild : clean build