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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
|
# target type
#------------------
TARGET ?= quickchat
#TARGET ?= vypresschat
TARGET_DEBUG ?= 1
#TARGET_INSTALL_LOCATION = d:\\programs\\miranda-testing
TARGET_INSTALL_LOCATION = d:\\devel\\miranda\\miranda
# version stuff
#-----------------------
TARGET_VER_COPYRIGHT = (c) 2005 Saulius Menkevicius
TARGET_VER_MAJ0 = 0
TARGET_VER_MAJ1 = 9
TARGET_VER_MIN0 = 3
TARGET_VER_MIN1 = 0
#TARGET_CVS = 1
###########################################################
###########################################################
# target proto
#------------------------------
ifeq ($(TARGET), quickchat)
TARGET_PROTO=QUICKCHAT
endif
ifeq ($(TARGET), vypresschat)
TARGET_PROTO=VYPRESSCHAT
endif
# debug
#------------------------------
ifeq ($(TARGET_DEBUG), 1)
TARGET_DEBUG_OPT = -D_DEBUG -DMEMWATCH
TARGET_CC_OPTIMISE = -g -ggdb
else
TARGET_DEBUG_OPT = -DNDEBUG
TARGET_CC_OPTIMISE = -Os -pipe -march=pentium
endif
ifeq ($(TARGET_CVS), 1)
TARGET_VER_CVS = -cvs$(shell date +%y%m%d)
endif
ifeq ($(TARGET_DEBUG), 1)
TARGET_VER_NAME = $(TARGET_VER_CVS)-dbg
else
TARGET_VER_NAME = $(TARGET_VER_CVS)
endif
# version stuff
#-------------------------------
TARGET_DIST_NAME = $(TARGET)-$(TARGET_VER_MAJ0)-$(TARGET_VER_MAJ1)-$(TARGET_VER_MIN0)-$(TARGET_VER_MIN1)$(TARGET_VER_NAME)
# compiler defines
#-------------------------------
CC_OPT = $(TARGET_CC_OPTIMISE) $(TARGET_DEBUG_OPT) \
-Wall -mms-bitfields -mwindows -mno-cygwin
TARGET_VER_OPT = -D$(TARGET_PROTO)
CC = gcc $(CC_OPT) $(TARGET_VER_OPT)
CC_OPT_DLL_LINK = $(CC_OPT) -shared -Wl,--enable-auto-image-base -lws2_32 -lrpcrt4 \
-Lcontrib/ -lunicows -lcomctl32
WINDRES_OPT = $(TARGET_VER_OPT) $(TARGET_DEBUG_OPT)
# defines
#-------------------------------
OBJEXT = obj
TARGET_DIR = build/$(TARGET)
OBJFILES_MAIN = $(TARGET_DIR)/main.$(OBJEXT) $(TARGET_DIR)/service.$(OBJEXT) $(TARGET_DIR)/util.$(OBJEXT) \
$(TARGET_DIR)/msghandler.$(OBJEXT) $(TARGET_DIR)/msgloop.$(OBJEXT) $(TARGET_DIR)/pthread.$(OBJEXT) \
$(TARGET_DIR)/user.$(OBJEXT) $(TARGET_DIR)/contacts.$(OBJEXT) $(TARGET_DIR)/options.$(OBJEXT) \
$(TARGET_DIR)/chanlist.$(OBJEXT) $(TARGET_DIR)/chatroom.$(OBJEXT) $(TARGET_DIR)/userlist.$(OBJEXT) \
$(TARGET_DIR)/strhashfunc.$(OBJEXT) $(TARGET_DIR)/hashtable.$(OBJEXT) $(TARGET_DIR)/skin.$(OBJEXT) \
$(TARGET_DIR)/resource.$(OBJEXT) \
libvqproto/libvqproto.a
ifeq ($(TARGET_DEBUG), 1)
OBJFILES = $(OBJFILES_MAIN) $(TARGET_DIR)/memwatch.$(OBJEXT)
else
OBJFILES = $(OBJFILES_MAIN)
endif
HEADERS = main.h service.h resource.h miranda.h options.h \
main.h msgloop.h msghandler.h user.h contacts.h userlist.h \
chanlist.h chatroom.h util.h \
libvqproto/vqproto.h contrib/memwatch.h \
version.h # this file is generated dynamically
ICONPACK_ICONS = icons/$(TARGET).ico \
icons/$(TARGET)_online.ico \
icons/$(TARGET)_offline.ico \
icons/$(TARGET)_away.ico \
icons/$(TARGET)_dnd.ico \
icons/$(TARGET)_na.ico
TARGET_ICONPACK = proto_$(TARGET_PROTO)
# dependencies
#----------------------------
all: $(TARGET_DIR)/$(TARGET).dll $(TARGET_DIR)/$(TARGET_ICONPACK).dll
$(TARGET_DIR)/$(TARGET).dll: $(OBJFILES) $(TARGET_DIR)
$(CC) $(OBJFILES) -o $(TARGET_DIR)/$(TARGET).dll $(CC_OPT_DLL_LINK)
$(TARGET_DIR)/$(TARGET_ICONPACK).dll: $(TARGET_DIR)/iconpack.$(OBJEXT)
$(CC) $(TARGET_DIR)/iconpack.$(OBJEXT) -o $(TARGET_DIR)/$(TARGET_ICONPACK).dll $(CC_OPT_DLL_LINK)
$(TARGET_DIR)/iconpack.$(OBJEXT): iconpack.rc $(ICONPACK_ICONS) $(TARGET_DIR)
windres $(WINDRES_OPT) -i iconpack.rc -o $(TARGET_DIR)/iconpack.$(OBJEXT)
$(TARGET_DIR)/main.obj: main.c $(HEADERS) $(TARGET_DIR)
$(CC) -c main.c -o $(TARGET_DIR)/main.$(OBJEXT)
$(TARGET_DIR)/service.$(OBJEXT): service.c $(HEADERS) $(TARGET_DIR)
$(CC) -c service.c -o $(TARGET_DIR)/service.$(OBJEXT)
$(TARGET_DIR)/msghandler.$(OBJEXT): msghandler.c $(HEADERS) $(TARGET_DIR)
$(CC) -c msghandler.c -o $(TARGET_DIR)/msghandler.$(OBJEXT)
$(TARGET_DIR)/msgloop.$(OBJEXT): msgloop.c $(HEADERS) $(TARGET_DIR)
$(CC) -c msgloop.c -o $(TARGET_DIR)/msgloop.$(OBJEXT)
$(TARGET_DIR)/pthread.$(OBJEXT): pthread.c $(HEADERS) $(TARGET_DIR)
$(CC) -c pthread.c -o $(TARGET_DIR)/pthread.$(OBJEXT)
$(TARGET_DIR)/user.$(OBJEXT): user.c $(HEADERS) $(TARGET_DIR)
$(CC) -c user.c -o $(TARGET_DIR)/user.$(OBJEXT)
$(TARGET_DIR)/contacts.$(OBJEXT): contacts.c $(HEADERS) $(TARGET_DIR)
$(CC) -c contacts.c -o $(TARGET_DIR)/contacts.$(OBJEXT)
$(TARGET_DIR)/userlist.$(OBJEXT): userlist.c $(HEADERS) $(TARGET_DIR)
$(CC) -c userlist.c -o $(TARGET_DIR)/userlist.$(OBJEXT)
$(TARGET_DIR)/chatroom.$(OBJEXT): chatroom.c $(HEADERS) $(TARGET_DIR)
$(CC) -c chatroom.c -o $(TARGET_DIR)/chatroom.$(OBJEXT)
$(TARGET_DIR)/options.$(OBJEXT): options.c $(HEADERS) $(TARGET_DIR)
$(CC) -c options.c -o $(TARGET_DIR)/options.$(OBJEXT)
$(TARGET_DIR)/chanlist.$(OBJEXT): chanlist.c $(HEADERS) $(TARGET_DIR)
$(CC) -c chanlist.c -o $(TARGET_DIR)/chanlist.$(OBJEXT)
$(TARGET_DIR)/util.$(OBJEXT): util.c $(HEADERS) $(TARGET_DIR)
$(CC) -c util.c -o $(TARGET_DIR)/util.$(OBJEXT)
$(TARGET_DIR)/skin.$(OBJEXT): skin.c $(HEADERS) $(TARGET_DIR)
$(CC) -c skin.c -o $(TARGET_DIR)/skin.$(OBJEXT)
$(TARGET_DIR)/resource.$(OBJEXT): resource.rc $(HEADERS) $(TARGET_DIR)
windres $(WINDRES_OPT) -i resource.rc -o $(TARGET_DIR)/resource.$(OBJEXT)
$(TARGET_DIR)/memwatch.$(OBJEXT): contrib/memwatch.c contrib/memwatch.h $(TARGET_DIR)
$(CC) -c contrib/memwatch.c -o $(TARGET_DIR)/memwatch.$(OBJEXT)
$(TARGET_DIR)/strhashfunc.$(OBJEXT): contrib/strhashfunc.c contrib/strhashfunc.h $(TARGET_DIR)
$(CC) -c contrib/strhashfunc.c -o $(TARGET_DIR)/strhashfunc.$(OBJEXT)
$(TARGET_DIR)/hashtable.$(OBJEXT): contrib/hashtable.c contrib/hashtable.h $(TARGET_DIR)
$(CC) -c contrib/hashtable.c -o $(TARGET_DIR)/hashtable.$(OBJEXT)
libvqproto/libvqproto.a:
make -C libvqproto CC='gcc $(CC_OPT)'
version.h:
echo "/*" > version.h
echo " * This file is generated by 'make version.h'." >> version.h
echo " * Any changes you make here will be lost, please" >> version.h
echo " * modify the Makefile instead and run 'make version'." >> version.h
echo " */" >> version.h
echo "" >> version.h
echo "#ifndef __VERSION_H" >> version.h
echo "#define __VERSION_H" >> version.h
echo "#define VQCHAT_VER_MAJ0 $(TARGET_VER_MAJ0)" >> version.h
echo "#define VQCHAT_VER_MAJ1 $(TARGET_VER_MAJ1)" >> version.h
echo "#define VQCHAT_VER_MIN0 $(TARGET_VER_MIN0)" >> version.h
echo "#define VQCHAT_VER_MIN1 $(TARGET_VER_MIN1)" >> version.h
echo -n "#define VQCHAT_VER_FILEVERSION " >> version.h
echo -n "\"$(TARGET_VER_MAJ0), $(TARGET_VER_MAJ1), " >> version.h
echo "$(TARGET_VER_MIN0), $(TARGET_VER_MIN1) $(TARGET_VER_NAME)\\0\"" >> version.h
echo "#define VQCHAT_VER_COPYRIGHT \"$(TARGET_VER_COPYRIGHT)\"" >> version.h
echo "#endif /* __VERSION_H */" >> version.h
version:
rm -f version.h
make version.h
clean: $(TARGET_DIR)
make -C libvqproto clean
rm -f version.h
rm -f $(TARGET_DIR)/*.$(OBJEXT) $(TARGET_DIR)/*.dll
rm -rf build/$(TARGET_DIST_NAME) build/$(TARGET_DIST_NAME).zip
install: all
cp $(TARGET_DIR)/$(TARGET).dll $(TARGET_INSTALL_LOCATION)/Plugins/
cp $(TARGET_DIR)/$(TARGET_ICONPACK).dll $(TARGET_INSTALL_LOCATION)/Icons/
deinstall:
rm -f $(TARGET_INSTALL_LOCATION)/Plugins/$(TARGET).dll
rm -f $(TARGET_INSTALL_LOCATION)/Icons/$(TARGET_ICONPACK).dll
debug:
make install
gdb $(TARGET_INSTALL_LOCATION)/miranda32.exe
dist: all
rm -rf build/$(TARGET_DIST_NAME) build/$(TARGET_DIST_NAME).zip
mkdir build/$(TARGET_DIST_NAME)
mkdir build/$(TARGET_DIST_NAME)/Plugins build/$(TARGET_DIST_NAME)/Icons \
build/$(TARGET_DIST_NAME)/docs build/$(TARGET_DIST_NAME)/for-win95-98-me-only
cp contrib/unicows.dll build/$(TARGET_DIST_NAME)/for-win95-98-me-only
echo "Win95/98/ME users: place unicows.dll in the same dir as miranda32.exe" \
> build/$(TARGET_DIST_NAME)/for-win95-98-me-only/README
cp $(TARGET_DIR)/$(TARGET).dll build/$(TARGET_DIST_NAME)/Plugins
cp $(TARGET_DIR)/$(TARGET_ICONPACK).dll build/$(TARGET_DIST_NAME)/Icons
ifneq ($(TARGET_DEBUG), 1)
strip build/$(TARGET_DIST_NAME)/Plugins/$(TARGET).dll
strip build/$(TARGET_DIST_NAME)/Icons/$(TARGET_ICONPACK).dll
endif
cp docs/TODO docs/README docs/ChangeLog docs/AUTHORS \
docs/CREDITS docs/Copying docs/NEWS build/$(TARGET_DIST_NAME)\docs
cd build; pwd; zip -9 -r $(TARGET_DIST_NAME).zip $(TARGET_DIST_NAME)
rm -rf build/$(TARGET_DIST_NAME)
rebuild:
make clean
make
redist:
make TARGET_DEBUG=0 TARGET=vypresschat clean
make TARGET_DEBUG=0 TARGET=vypresschat dist
make TARGET_DEBUG=0 TARGET=quickchat clean
make TARGET_DEBUG=0 TARGET=quickchat dist
make clean
$(TARGET_DIR): build
mkdir $(TARGET_DIR)
build:
mkdir build
|