-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
59 lines (44 loc) · 1.55 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
47
48
49
50
51
52
53
54
55
56
57
58
59
##
## Copyright (c) 2018-2024 Stéphane Micheloud
##
## Licensed under the MIT License.
##
##############################################################################
include ../Makefile.inc
##############################################################################
## main rules
DEBUG ?= false
SOURCE_FILES = $(wildcard src/main/cpp/*.cpp)
PROGRAM_NAME = add
CONFIG = $(shell $(LLVM_CONFIG) --cxxflags --ldflags --system-libs --libs core)
all: build
build: $(SOURCE_FILES)
$(DEBUG) && @$(ECHO) "\"$(CXX)\" -g -O3 $(CONFIG) -o main $<"
"$(CXX)" -g -O3 $(CONFIG) -o main $<
executable: build
./main
"$(LLC)" -filetype=obj $(PROGRAM_NAME).ll -o $(PROGRAM_NAME).o
"$(CXX)" $(PROGRAM_NAME).o -o $(PROGRAM_NAME)
@$(ECHO) "'$(PROGRAM_NAME)' created!"
run: executable
./$(PROGRAM_NAME)
clean:
[ -f "main" ] && "$(RM)" -f main
[ -d "main.dSYM" ] && "$(RM)" -rf main.dSYM
[ -f "$(PROGRAM_NAME).ll" ] && $(RM) -f $(PROGRAM_NAME).ll
[ -f "$(PROGRAM_NAME).o" ] && $(RM) -f $(PROGRAM_NAME).o
[ -f "$(PROGRAM_NAME)" ] && $(RM) -f $(PROGRAM_NAME)
help:
@$(ECHO) "Usage: make all|build|clean|executable|help|run"
@$(ECHO) ""
@$(ECHO) " Subcommands:"
@$(ECHO) " all alias for build"
@$(ECHO) " build compile C++ source files"
@$(ECHO) " clean delete generated files"
@$(ECHO) " help print this help message"
@$(ECHO) " run execute main program \"$(PROGRAM_NAME)\""
##############################################################################
## phony
.PHONY: all build clean executable help run
.SUFFIXES:
.SUFFIXES: .c .cpp .o .obj .exe