-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakefile
63 lines (49 loc) · 1.41 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
60
61
62
63
# gets workspace folder name (must not contain spaces)
mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST)))
ProjectName := $(notdir $(patsubst %/,%,$(dir $(mkfile_path))))
# compiler
CC = g++
# compile with c++11 standard and in debug mode
CFLAG = -std=c++11 -g -Wall
# path variables
BIN_DIR = build
INC_DIR = include
SRC_DIR = source
OBJ_DIR = obj
LIB_DIR = lib/wx
RSC_DIR = resources
# source files
SRCS := $(wildcard $(SRC_DIR)/*.cpp)
# object files
OBJS := $(patsubst $(SRC_DIR)/%.cpp,$(OBJ_DIR)/%.o, $(SRCS))
# library files
LIBS := $(patsubst $(LIB_DIR)/lib%.a,-l %, $(wildcard $(LIB_DIR)/*.a))
# windows resources
# RSC = $(OBJ_DIR)/icon.o
# rules
.PHONY: all run clean echo
all: $(BIN_DIR)/$(ProjectName)
echo:
@echo $(LIBS)
# build in debug mode
$(BIN_DIR)/$(ProjectName): $(OBJS) # $(RSC) # $< not working!
@echo bulding project:
$(CC) $(CFLAG) $(OBJS) $(RSC) -o $@ -I $(INC_DIR) -L $(LIB_DIR) $(LIBS) -mwindows
@echo done!
# static rule
# genetate .o files in obj_dir from source files
$(OBJS): $(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp
@echo creating object files:
$(CC) $(CFLAG) -c $< -I $(INC_DIR) -o $@
@echo done!
# compile resource file for windows app
# $(RSC): $(RSC_DIR)/*.rc
# windres $< -o $@
# runs output file in external console
# windows only
run: all
cmd /c start cmd /k "cd $(BIN_DIR) & $(ProjectName).exe & exit"
# windows only
clean:
del /f $(OBJ_DIR)\*.o $(BIN_DIR)\*.exe
@echo Clean Complete!