-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathMakefile
106 lines (83 loc) · 2.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
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
#############################################################################
# #
# Makefile for building a MinGW IndentByFold.dll #
# #
#############################################################################
.SUFFIXES: .dll .o .c .cpp .rc .h
# For x64 build, ARCH=x86_64-w64-mingw32
ifeq ($(BITS),64)
ARCH = x86_64-w64-mingw32
else
ARCH = i686-w64-mingw32
endif
CC = $(ARCH)-gcc
CXX = $(ARCH)-g++
AR = $(ARCH)-ar
RANLIB = $(ARCH)-ranlib
WINDRES = $(ARCH)-windres
# The general compiler flags
CFLAGS = -c -DUNICODE
# Enable almost all warnings
CFLAGS += -W -Wall
CXXFLAGS = $(CFLAGS)
LIBS = -static -lshlwapi -lgdi32 -lcomdlg32 -lcomctl32
LDFLAGS = -Wl,--out-implib,$(TARGET) -shared
# Default target is RELEASE, otherwise DEBUG=1
DEBUG ?= 0
ifeq ($(DEBUG), 1)
# Add DEBUG define, debug info and specific optimizations
CFLAGS += -D_DEBUG -g -O0
CXXFLAGS += -D_DEBUG -g -O0
# Add dependencies flags
CFLAGS += -MMD -MP
CXXFLAGS += -MMD -MP
else
# Set the optimizations
OPT = -fexpensive-optimizations -Os -O2
# Strip the dll
LDOPT = -s
endif
# Silent/verbose commands. For verbose output of commands set V=1
V ?= 0
ifeq ($(V), 0)
SILENT = @
V_CC = @echo [CC] $@;
V_CXX = @echo [CXX] $@;
V_RES = @echo [WINDRES] $@;
endif
.c.o:
$(V_CC) $(CC) $(CFLAGS) -o $@ $<
.cpp.o:
$(V_CXX) $(CXX) $(CXXFLAGS) -o $@ $<
.rc.o:
$(V_RES) $(WINDRES) $(RESFLAGS) -o $@ -i $<
PROGRAM = IndentByFold
TARGET = $(PROGRAM).dll
now: $(TARGET)
all: clean now
PROGRAM_SRCS_CPP = \
IBFMenu.cpp \
IBFPlugin.cpp \
IndentByFold.cpp \
NppMessager.cpp \
NppPlugin.cpp \
NppPluginMenu.cpp \
SciMessager.cpp \
WaitCursor.cpp
PROGRAM_OBJS_CPP=$(PROGRAM_SRCS_CPP:.cpp=.o)
PROGRAM_RC=$(PROGRAM)_res.rc
PROGRAM_OBJS_RC=$(PROGRAM_RC:.rc=.o)
PROGRAM_DEP_CPP=$(PROGRAM_SRCS_CPP:.cpp=.d)
$(PROGRAM).dll: version_git.h $(PROGRAM_OBJS_CPP) $(PROGRAM_OBJS_RC)
$(V_CXX) $(CXX) -o $@ $(PROGRAM_OBJS_CPP) $(PROGRAM_OBJS_RC) $(LDFLAGS) $(LIBS)
version_git.h:
$(SILENT) ./version_git.sh
clean:
@echo Cleaning
$(SILENT) rm -f $(PROGRAM_OBJS_CPP) $(PROGRAM_OBJS_RC) $(PROGRAM_DEP_CPP) $(PROGRAM).dll $(PROGRAM).a version_git.h tags tags.sqlite
cppcheck:
@echo Running cppcheck
$(SILENT) cppcheck --quiet $(PROGRAM_SRCS_CPP)
### code dependencies ###
$(PROGRAM)_res.o: $(PROGRAM)_res.rc version_git.h
-include $(PROGRAM_DEP_CPP)