-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
109 lines (88 loc) · 3.54 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#
# The purpose of the following lines is to extract the directory of the
# makefile. Essentially, this is done by
#
# $(dir $(realpath $(lastword $(MAKEFILE_LIST))))
#
# However, since dir doesn't operate correctly on paths containing spaces, the
# spaces are first replaced with double quotes, because double quotes cannot
# appear in paths on Windows. Once dir is invoked, the quotes are converted
# back to spaces.
#
# The directory is needed in order to call the supplementary script dircmd.bat
# which allows us to use the shell's internal commands mkdir and rmdir.
# Otherwise the makefile will have to depend on external programs for the
# purpose of creating and deleting directories.
#
esc=$(subst $(empty) $(empty),",$1)
unesc=$(subst ", ,$1)
MAKEFILE_DIR=$(call unesc,$(dir $(call esc, $(subst /,\,$(realpath $(lastword $(MAKEFILE_LIST)))))))
MKDIR=$(MAKEFILE_DIR)dircmd.bat mkdir
RMDIR=$(MAKEFILE_DIR)dircmd.bat rmdir
CC=gcc
CXX=g++
INCDIRS=-IE:\Develop\Libs\CPP\boost_1_58_0
CFLAGS+=$(INCDIRS) -Wall -pedantic
CXXFLAGS+=$(INCDIRS) -Wall -pedantic
LDFLAGS+=-LE:\Develop\Libs\CPP\boost_1_58_0\stage\lib
LDLIBS=-lgdi32 -lcomctl32 -lshell32
BIN_NAME=NppEventExec
ifndef CONFIGURATION
CONFIGURATION=Debug
endif
ifndef PLATFORM
PLATFORM=Win32
endif
ifneq ($(CONFIGURATION), Release)
ifneq ($(CONFIGURATION), Debug)
$(error Unknown configuration: $(CONFIGURATION). Supported configurations are Debug and Release.)
endif
endif
ifneq ($(PLATFORM), Win32)
ifneq ($(PLATFORM), x64)
$(error Unknown platform: $(PLATFORM). Supported platforms are Win32 and x64.)
endif
endif
BUILDDIR=Build
OUTDIR=$(BUILDDIR)\Mingw\$(CONFIGURATION)\$(PLATFORM)
BIN_EXE=$(OUTDIR)\$(BIN_NAME).exe
BIN_DLL=$(OUTDIR)\$(BIN_NAME).dll
BIN=$(BIN_DLL)
ifeq ($(CONFIGURATION), Debug)
CPPFLAGS += -g -DDEBUG
LDLIBS += -lboost_regex-mgw62-mt-sd-1_58
BIN += $(BIN_EXE)
else
CPPFLAGS += -O2 -DNDEBUG
LDLIBS += -lboost_regex-mgw62-mt-s-1_58
endif
CSRC=$(wildcard *.c)
CXXSRC=$(wildcard *.cpp)
RES=$(wildcard *.rc)
OBJ=$(addprefix $(OUTDIR)\, $(notdir $(CSRC:.c=.o) $(CXXSRC:.cpp=.o) $(RES:.rc=.res)))
all: $(OUTDIR) $(BIN)
$(OUTDIR)\about_dlg.o: mem.h plugin.h resource.h util.h Notepad_plus_msgs.h
$(OUTDIR)\csv.o: event_map.h mem.h util.h utf8.h plugin.h
$(OUTDIR)\edit_dlg.o: event_map.h match.h mem.h plugin.h resource.h rule.h util.h
$(OUTDIR)\event_map.o: Notepad_plus_msgs.h
$(OUTDIR)\exec.o: rule.h Scintilla.h exec_def.h Notepad_plus_msgs.h nppexec_msgs.h mem.h plugin.h queue_dlg.h resource.h util.h
$(OUTDIR)\plugin.o: csv.h mem.h match.h rule.h edit_dlg.h rules_dlg.h util.h Scintilla.h exec.h resource.h about_dlg.h queue_dlg.h PluginInterface.h nppexec_msgs.h
$(OUTDIR)\queue_dlg.o: exec_def.h mem.h plugin.h resource.h util.h
$(OUTDIR)\rule.o: event_map.h csv.h mem.h plugin.h util.h Notepad_plus_msgs.h
$(OUTDIR)\rules_dlg.o: event_map.h match.h mem.h plugin.h resource.h rule.h edit_dlg.h util.h Notepad_plus_msgs.h Scintilla.h exec.h queue_dlg.h
$(OUTDIR)\util.o: mem.h plugin.h
$(OUTDIR):
$(MKDIR) $@
$(OUTDIR)\\%.o: %.c %.h base.h
$(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $<
$(OUTDIR)\\%.o: %.cpp %.h base.h
$(CXX) -c $(CPPFLAGS) $(CXXFLAGS) -o $@ $<
$(OUTDIR)\\%.res: %.rc base.h resource.h $(wildcard resources\*)
windres -i $< --input-format=rc -o $@ -O coff
$(BIN_DLL): $(OBJ)
g++ $(LDFLAGS) -static-libgcc -static-libstdc++ -shared -o $@ $^ $(LDLIBS)
$(BIN_EXE): $(OBJ)
g++ $(LDFLAGS) -mconsole -o $@ $^ $(LDLIBS)
clean:
$(RMDIR) $(BUILDDIR)
.PHONY: all clean