-
-
Notifications
You must be signed in to change notification settings - Fork 21
/
Makefile
169 lines (135 loc) · 3.78 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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
# -*- tab-width : 4 -*-
#=======================================================================
# @file
# @brief RX prog Makefile
# @author 平松邦仁 (hira@rvf-rc45.net)
# @copyright Copyright (C) 2018 Kunihito Hiramatsu @n
# Released under the MIT license @n
# https://github.com/hirakuni45/RX/blob/master/LICENSE
#=======================================================================
TARGET = rx_prog
#ICON_RC = icon.rc
# 'debug' or 'release'
BUILD = release
VPATH =
CSOURCES =
PSOURCES = main.cpp \
file_io.cpp \
string_utils.cpp \
sjis_utf16.cpp
# Include path for each environment
ifeq ($(OS),Windows_NT)
SYSTEM := WIN
# LOCAL_PATH = /mingw64
LOCAL_PATH = /c/boost_1_74_0
CMD_EXT = exe
else
UNAME := $(shell uname -s)
ifeq ($(UNAME),Linux)
SYSTEM := LINUX
LOCAL_PATH = /usr/local
endif
ifeq ($(UNAME),Darwin)
SYSTEM := OSX
OSX_VER := $(shell sw_vers -productVersion | sed 's/^\([0-9]*.[0-9]*\).[0-9]*/\1/')
LOCAL_PATH = /opt/local
endif
CMD_EXT =
endif
STDLIBS =
OPTLIBS =
INC_SYS = $(LOCAL_PATH)
INC_LIB =
PINC_APP =
CINC_APP =
LIBDIR =
INC_S = $(addprefix -isystem , $(INC_SYS))
INC_L = $(addprefix -isystem , $(INC_LIB))
INC_P = $(addprefix -I, $(PINC_APP))
INC_C = $(addprefix -I, $(CINC_APP))
CINCS = $(INC_S) $(INC_L) $(INC_C)
PINCS = $(INC_S) $(INC_L) $(INC_P)
LIBS = $(addprefix -L, $(LIBDIR))
LIBN = $(addprefix -l, $(STDLIBS))
LIBN += $(addprefix -l, $(OPTLIBS))
#
# Compiler, Linker Options, Resource_compiler
#
CP = g++
CC = gcc
LK = g++
RC =
POPT = -O2 -std=gnu++17
COPT = -O2
LOPT =
PFLAGS = -DHAVE_STDINT_H
CFLAGS =
ifeq ($(BUILD),debug)
POPT += -g
COPT += -g
PFLAGS += -DDEBUG
CFLAGS += -DDEBUG
endif
ifeq ($(BUILD),release)
PFLAGS += -DNDEBUG
CFLAGS += -DNDEBUG
endif
# -static-libgcc -static-libstdc++
LFLAGS =
# -Wuninitialized -Wunused -Werror -Wshadow
CCWARN = -Wimplicit -Wreturn-type -Wswitch \
-Wformat
CPWARN = -Wall -Werror \
-Wno-unused-function
OBJECTS = $(addprefix $(BUILD)/,$(patsubst %.cpp,%.o,$(PSOURCES))) \
$(addprefix $(BUILD)/,$(patsubst %.c,%.o,$(CSOURCES)))
DEPENDS = $(patsubst %.o,%.d, $(OBJECTS))
ifdef ICON_RC
ICON_OBJ = $(addprefix $(BUILD)/,$(patsubst %.rc,%.o,$(ICON_RC)))
endif
.PHONY: all clean
.SUFFIXES :
.SUFFIXES : .rc .hpp .h .c .cpp .o
all: $(BUILD) $(TARGET)
$(TARGET): $(OBJECTS) $(ICON_OBJ) Makefile
$(LK) $(LFLAGS) $(LIBS) $(OBJECTS) $(ICON_OBJ) $(LIBN) -o $(TARGET)
$(BUILD)/%.o : %.c
mkdir -p $(dir $@); \
$(CC) -c $(COPT) $(CFLAGS) $(CINCS) $(CCWARN) -o $@ $<
$(BUILD)/%.o : %.cpp
mkdir -p $(dir $@); \
$(CP) -c $(POPT) $(PFLAGS) $(PINCS) $(CPWARN) -o $@ $<
$(ICON_OBJ): $(ICON_RC)
$(RC) -i $< -o $@
$(BUILD)/%.d : %.c
mkdir -p $(dir $@); \
$(CC) -MM -DDEPEND_ESCAPE $(COPT) $(CFLAGS) $(CINCS) $< \
| sed 's/$(notdir $*)\.o:/$(subst /,\/,$(patsubst %.d,%.o,$@) $@):/' > $@ ; \
[ -s $@ ] || rm -f $@
$(BUILD)/%.d : %.cpp
mkdir -p $(dir $@); \
$(CP) -MM -DDEPEND_ESCAPE $(POPT) $(PFLAGS) $(PINCS) $< \
| sed 's/$(notdir $*)\.o:/$(subst /,\/,$(patsubst %.d,%.o,$@) $@):/' > $@ ; \
[ -s $@ ] || rm -f $@
run:
./$(TARGET) -d RX64M -P COM11 --verbose --progress --erase --write --verify uart_sample.mot
run_verify:
./$(TARGET) -d RX64M -P COM11 --verbose --progress --verify uart_sample.mot
clean:
rm -rf $(BUILD) $(TARGET)
clean_depend:
rm -f $(DEPENDS)
dllname:
objdump -p $(TARGET) | grep "DLL Name"
tarball:
tar cfvz $(subst .exe,,$(TARGET))_$(shell date +%Y%m%d%H).tgz \
*.[hc]pp Makefile
bin_zip:
$(LK) $(LFLAGS) $(LIBS) $(OBJECTS) $(ICON_OBJ) $(LIBN) -mwindows -o $(TARGET)
rm -f $(subst .exe,,$(TARGET))_$(shell date +%Y%m%d%H)_bin.zip
zip $(subst .exe,,$(TARGET))_$(shell date +%Y%m%d%H)_bin.zip *.exe *.dll
install:
mkdir -p /usr/local/bin
cp $(TARGET).$(CMD_EXT) /usr/local/bin/.
cp $(TARGET).conf /usr/local/bin/.
-include $(DEPENDS)