GNUmakefile 9.81 KB
Newer Older
1
# GNUmakefile
2
3

#########################################################################
4
# Makefile for Synchronet BBS for Unix									#
5
# For use with GNU make and GNU C Compiler or Borland Kylix C++			#
6
7
# @format.tab-size 4, @format.use-tabs true								#
#																		#
8
9
# gcc: gmake															#
# Borland (still in testing/debuging stage): gmake bcc=1				#
10
11
12
13
14
15
16
#																		#
# Optional build targets: dlls, utils, mono, all (default)				#
#########################################################################

# $Id$

# Macros
17
18
19
20
21
22
ifndef DEBUG
 ifndef RELEASE
  DEBUG	:=	1
 endif
endif

deuce's avatar
deuce committed
23
#USE_DIALOG =   1       # Dialog vesrion of UIFC
24
#USE_FLTK =     1       # Use Windowed version
deuce's avatar
deuce committed
25
26
USE_CURSES      =       1       # Curses version of UIFC

27
ifdef DEBUG
28
 BUILD	=	debug
29
else
30
 BUILD	=	release
31
32
endif

33
ifdef bcc
34
35
36
37
 CC		=	bc++ -q
 CCPRE	:=	bcc
 CCPP	=	bc++ -q
 LD		=	ilink -q
38
 CFLAGS +=	-mm -md -D__unix__ -w-csu -w-pch -w-ccc -w-rch -w-par -w-aus
39
else
40
 CCPRE	:=	gcc
41
 CFLAGS	+=	-MMD -Wall
42
43
44
45
46
47
48
 ifdef BUILD_DEPENDS
  CC		=	../build/mkdep -a
  CCPP	=	../build/mkdep -a
  LD		=	echo
  COMPILE_MSG	:= Depending
 else
  CC		=	gcc
deuce's avatar
deuce committed
49
  CCPP	=	g++
50
51
52
  LD		=	ld
  COMPILE_MSG	:= Compiling
 endif
53
endif
54
55
56
57
SLASH	=	/
OFILE	=	o

LIBFILE	=	.a
rswindell's avatar
rswindell committed
58
UIFC	=	../uifc/
59
XPDEV	=	../xpdev/
60

61
62
ifndef os
 os		:=	$(shell uname)
63
endif
64
65
66
# this line wont work with solaris unless awk in path is actually gawk 
os      :=	$(shell echo $(os) | tr "[A-Z]" "[a-z]")
#os      :=	$(shell echo $(os) | awk '/.*/ { print tolower($$1)}')
67
68
# remove '/' from "os/2"
os      :=  $(shell echo $(os) | tr -d "/")
69

70
71
ifeq ($(os),freebsd)
 BSD	=	1
72
else
73
74
75
 ifeq ($(os),openbsd)
  BSD	=	1
 endif
76
endif
77

78
79
LIBODIR :=	$(CCPRE).$(os).lib.$(BUILD)
EXEODIR :=	$(CCPRE).$(os).exe.$(BUILD)
80

81
DELETE	=	rm -f
82

83
CFLAGS	+=	-DJAVASCRIPT -I../../include/mozilla/js -I$(XPDEV) -I$(UIFC)
84

85
86
87
ifdef BSD	# BSD
 # Math libraries needed and uses pthread
 LFLAGS	:=	-lm -pthread -lutil
88
else			# Linux / Other UNIX
89
90
91
92
93
94
 # Math and pthread libraries needed
 ifdef bcc
  LFLAGS	:=	libpthread.so
 else
  LFLAGS	:=	-lm -lpthread -lutil
 endif
95
endif
96

97
98
ifeq ($(os),linux)    # Linux
 CFLAGS	+= -D_THREAD_SUID_BROKEN
99
100
endif

101
102
103
104
105
ifeq ($(os),sunos)    # Solaris
 CFLAGS	+= -D_REENTRANT -D__solaris__ -DNEEDS_DAEMON -D_POSIX_PTHREAD_SEMANTICS -DNEEDS_FORKPTY
 LFLAGS := -lm -lpthread -lsocket -lnsl -lrt
endif

106
ifeq ($(os),netbsd)
107
 CFLAGS += -D_REENTRANT -D__unix__ -I/usr/pkg/include -DNEEDS_FORKPTY
108
109
110
 LFLAGS := -lm -lpthread -L/usr/pkg/lib
endif

111
# So far, only QNX has sem_timedwait()
112
113
ifeq ($(os),qnx)
 LFLAGS := -lm -lsocket
114
115
116
else
 CFLAGS	+=	-DUSE_XP_SEMAPHORES
 USE_XP_SEMAPHORES	:=	1
117
118
endif

119
ifdef DEBUG
120
121
122
123
124
125
 ifdef bcc
  CFLAGS	+=	-y -v -Od
 else
  CFLAGS	+=	-ggdb
 endif
 CFLAGS  +=	-D_DEBUG
126
127
else
 CFLAGS	+= -O3
128
endif
129

130
131
132
133
ifdef JSLIB
 LIBS	+=	$(JSLIB)
else
 LIBS	+=	../../lib/mozilla/js/$(os).$(BUILD)/libjs.a
134
135
endif

136
137
# The following are needed for echocfg (uses UIFC)
UIFC_OBJS =	$(EXEODIR)/uifcx.o
138
ifdef USE_FLTK
139
140
141
 CFLAGS +=	-DUSE_FLTK -I../../include/fltk
 UIFC_LFLAGS += -L../../lib/fltk/$(os) -L/usr/X11R6/lib -lm -lfltk -lX11
 UIFC_OBJS+=	$(EXEODIR)/uifcfltk.o
142
endif
deuce's avatar
deuce committed
143
ifdef USE_CURSES
144
 CFLAGS +=	-DUSE_CURSES
145
146
147
148
149
 ifeq ($(os),qnx)
  UIFC_LFLAGS += -lncurses
 else
  UIFC_LFLAGS += -lcurses
 endif
150
 UIFC_OBJS +=	$(EXEODIR)/uifcc.o
deuce's avatar
deuce committed
151
endif
152

rswindell's avatar
rswindell committed
153
154
155
include targets.mk		# defines all targets
include objects.mk		# defines $(OBJS)
include sbbsdefs.mk		# defines $(SBBSDEFS)
156

157
158
ifeq ($(USE_XP_SEMAPHORES),1)
 OBJS	+=	$(LIBODIR)$(SLASH)xpsem.$(OFILE)
159
160
endif

161
SBBSLIB	=	$(LIBODIR)/sbbs.a
162

rswindell's avatar
rswindell committed
163
vpath %.c $(XPDEV) $(UIFC)
164
vpath %.cpp $(UIFC)
rswindell's avatar
rswindell committed
165

166
# Implicit C Compile Rule for utils
deuce's avatar
deuce committed
167
$(EXEODIR)/%.o : %.c $(BUILD_DEPENDS)
168
   ifndef bcc
169
	@echo $(COMPILE_MSG) $<
170
   endif
171
	@$(CC) $(CFLAGS) -o $@ -c $<
172

173
# Implicit C++ Compile Rule for utils
deuce's avatar
deuce committed
174
$(EXEODIR)/%.o : %.cpp $(BUILD_DEPENDS)
175
   ifndef bcc
176
	@echo $(COMPILE_MSG) $<
177
   endif
178
	@$(CCPP) $(CFLAGS) -o $@ -c $<
179

180
# Implicit C Compile Rule for SBBS
deuce's avatar
deuce committed
181
$(LIBODIR)/%.o : %.c $(BUILD_DEPENDS)
182
   ifndef bcc
183
	@echo $(COMPILE_MSG) $<
184
   endif
185
	@$(CC) $(CFLAGS) $(SBBSDEFS) -o $@ -c $<
186
187

# Implicit C++ Compile Rule for SBBS
deuce's avatar
deuce committed
188
$(LIBODIR)/%.o : %.cpp $(BUILD_DEPENDS)
189
   ifndef bcc
190
	@echo $(COMPILE_MSG) $<
191
   endif
192
	@$(CCPP) $(CFLAGS) $(SBBSDEFS) -o $@ -c $<
193
194
195
196
197
198
199

$(LIBODIR):
	mkdir $(LIBODIR)

$(EXEODIR):
	mkdir $(EXEODIR)

200
CON_OBJS	= $(EXEODIR)/sbbscon.o $(EXEODIR)/conwrap.o \
201
		  $(EXEODIR)/sbbs_ini.o
202
FTP_OBJS	= $(LIBODIR)/ftpsrvr.o
203
MAIL_OBJS	= $(LIBODIR)/mailsrvr.o $(LIBODIR)/mxlookup.o \
deuce's avatar
deuce committed
204
 		  $(LIBODIR)/mime.o $(LIBODIR)/base64.o
deuce's avatar
deuce committed
205
WEB_OBJS	= $(LIBODIR)/websrvr.o $(LIBODIR)/sockwrap.o $(LIBODIR)/base64.o
206
207
SERVICE_OBJS= $(LIBODIR)/services.o

rswindell's avatar
rswindell committed
208
209
MONO_OBJS	= $(CON_OBJS) $(FTP_OBJS) $(WEB_OBJS) \
			$(MAIL_OBJS) $(SERVICE_OBJS)
210
211

# Monolithic Synchronet executable Build Rule
deuce's avatar
deuce committed
212
$(SBBSMONO): $(MONO_OBJS) $(OBJS) $(LIBS) $(LIBODIR)/ver.o $(BUILD_DEPENDS)
213
    ifndef BUILD_DEPENDS
214
	@echo Linking $@
215
	@$(CCPP) -o $@ $(LFLAGS) $^
216
    endif
217
218

# Synchronet BBS library Link Rule
deuce's avatar
deuce committed
219
$(SBBS): $(OBJS) $(LIBS) $(LIBODIR)/ver.o $(BUILD_DEPENDS)
220
    ifndef BUILD_DEPENDS
221
	$(LD) $(LFLAGS) -S -o $(SBBS) $^ $(LIBS) -o $@
222
    endif
223
224

# FTP Server Link Rule
deuce's avatar
deuce committed
225
$(FTPSRVR): $(LIBODIR)/ftpsrvr.o $(SBBSLIB) $(BUILD_DEPENDS)
226
    ifndef BUILD_DEPENDS
227
	$(LD) $(LFLAGS) -S $^ $(LIBS) -o $@ 
228
    endif
229
230

# Mail Server Link Rule
deuce's avatar
deuce committed
231
$(MAILSRVR): $(MAIL_OBJS) $(SBBSLIB) $(BUILD_DEPENDS)
232
    ifndef BUILD_DEPENDS
233
	$(LD) $(LFLAGS) -S $^ $(LIBS) -o $@
234
    endif
235
236

# Synchronet Console Build Rule
deuce's avatar
deuce committed
237
$(SBBSCON): $(CON_OBJS) $(SBBSLIB) $(BUILD_DEPENDS)
238
    ifndef BUILD_DEPENDS
239
	@$(CC) $(CFLAGS) -o $@ $^
240
    endif
241
242

# Specifc Compile Rules
deuce's avatar
deuce committed
243
$(LIBODIR)/ftpsrvr.o: ftpsrvr.c ftpsrvr.h $(BUILD_DEPENDS)
244
	@echo $(COMPILE_MSG) $<
245
	@$(CC) $(CFLAGS) -DFTPSRVR_EXPORTS -o $@ -c $<
246

deuce's avatar
deuce committed
247
$(LIBODIR)/mailsrvr.o: mailsrvr.c mailsrvr.h $(BUILD_DEPENDS)
248
	@echo $(COMPILE_MSG) $<
249
	@$(CC) $(CFLAGS) -DMAILSRVR_EXPORTS -o $@ -c $<
250

deuce's avatar
deuce committed
251
$(LIBODIR)/mxlookup.o: mxlookup.c $(BUILD_DEPENDS)
252
	@echo $(COMPILE_MSG) $<
253
	@$(CC) $(CFLAGS) -DMAILSRVR_EXPORTS -o $@ -c $<
254

deuce's avatar
deuce committed
255
$(LIBODIR)/mime.o: mime.c $(BUILD_DEPENDS)
256
	@echo $(COMPILE_MSG) $<
257
	@$(CC) $(CFLAGS) -DMAILSRVR_EXPORTS -o $@ -c $<		
258

deuce's avatar
deuce committed
259
$(LIBODIR)/websrvr.o: websrvr.c websrvr.h $(BUILD_DEPENDS)
260
	@echo $(COMPILE_MSG) $<
deuce's avatar
deuce committed
261
262
	@$(CC) $(CFLAGS) -DWEBSRVR_EXPORTS -o $@ -c $<

deuce's avatar
deuce committed
263
$(LIBODIR)/base64.o: base64.c base64.h $(BUILD_DEPENDS)
264
	@echo $(COMPILE_MSG) $<
rswindell's avatar
rswindell committed
265
266
	@$(CC) $(CFLAGS) -DWEBSRVR_EXPORTS -o $@ -c $<

deuce's avatar
deuce committed
267
$(LIBODIR)/services.o: services.c services.h $(BUILD_DEPENDS)
268
	@echo $(COMPILE_MSG) $<
269
	@$(CC) $(CFLAGS) -DSERVICES_EXPORTS -o $@ -c $<
270
271

# Baja Utility
272
$(BAJA): $(EXEODIR)/baja.o $(EXEODIR)/ars.o $(EXEODIR)/crc32.o \
deuce's avatar
deuce committed
273
	$(EXEODIR)/genwrap.o $(EXEODIR)/filewrap.o $(BUILD_DEPENDS)
274
    ifndef BUILD_DEPENDS
275
	@echo Linking $@
276
	@$(CC) -o $@ $^
277
    endif
278
279

# Node Utility
deuce's avatar
deuce committed
280
$(NODE): $(EXEODIR)/node.o $(EXEODIR)/genwrap.o $(EXEODIR)/filewrap.o $(BUILD_DEPENDS)
281
    ifndef BUILD_DEPENDS
282
	@echo Linking $@
283
	@$(CC) -o $@ $^ 
284
    endif
285

286
SMBLIB = $(EXEODIR)/smblib.o $(EXEODIR)/filewrap.o $(EXEODIR)/crc16.o
rswindell's avatar
rswindell committed
287

288
# FIXSMB Utility
deuce's avatar
deuce committed
289
$(FIXSMB): $(EXEODIR)/fixsmb.o $(SMBLIB) $(EXEODIR)/genwrap.o $(EXEODIR)/str_util.o $(BUILD_DEPENDS)
290
    ifndef BUILD_DEPENDS
291
	@echo Linking $@
292
	@$(CC) -o $@ $^
293
    endif
294
295

# CHKSMB Utility
deuce's avatar
deuce committed
296
$(CHKSMB): $(EXEODIR)/chksmb.o $(SMBLIB) $(EXEODIR)/conwrap.o $(EXEODIR)/dirwrap.o $(EXEODIR)/genwrap.o $(BUILD_DEPENDS)
297
    ifndef BUILD_DEPENDS
298
	@echo Linking $@
299
	@$(CC) -o $@ $^
300
    endif
301
302

# SMB Utility
303
$(SMBUTIL): $(EXEODIR)/smbutil.o $(SMBLIB) $(EXEODIR)/conwrap.o $(EXEODIR)/dirwrap.o \
304
	$(EXEODIR)/genwrap.o $(EXEODIR)/smbtxt.o $(EXEODIR)/crc32.o $(EXEODIR)/lzh.o \
deuce's avatar
deuce committed
305
	$(EXEODIR)/date_str.o $(EXEODIR)/str_util.o $(BUILD_DEPENDS)
306
    ifndef BUILD_DEPENDS
307
	@echo Linking $@
308
	@$(CC) -o $@ $^
309
    endif
310

rswindell's avatar
rswindell committed
311
312
313
314
315
316
317
318
319
# SBBSecho (FidoNet Packet Tosser)
$(SBBSECHO): \
	$(EXEODIR)/sbbsecho.o \
	$(EXEODIR)/ars.o \
	$(EXEODIR)/crc32.o \
	$(EXEODIR)/date_str.o \
	$(EXEODIR)/load_cfg.o \
	$(EXEODIR)/scfglib1.o \
	$(EXEODIR)/scfglib2.o \
320
321
	$(EXEODIR)/nopen.o \
	$(EXEODIR)/str_util.o \
322
	$(EXEODIR)/dat_rec.o \
rswindell's avatar
rswindell committed
323
324
	$(EXEODIR)/userdat.o \
	$(EXEODIR)/rechocfg.o \
325
	$(EXEODIR)/conwrap.o \
rswindell's avatar
rswindell committed
326
327
328
329
	$(EXEODIR)/dirwrap.o \
	$(EXEODIR)/genwrap.o \
	$(SMBLIB) \
	$(EXEODIR)/smbtxt.o \
deuce's avatar
deuce committed
330
	$(EXEODIR)/lzh.o $(BUILD_DEPENDS)
331
    ifndef BUILD_DEPENDS
rswindell's avatar
rswindell committed
332
	@echo Linking $@
333
	@$(CC) -o $@ $^
334
    endif
rswindell's avatar
rswindell committed
335

rswindell's avatar
rswindell committed
336
337
338
339
# SBBSecho Configuration Program
$(ECHOCFG): \
	$(EXEODIR)/echocfg.o \
	$(EXEODIR)/rechocfg.o \
340
	$(UIFC_OBJS) \
rswindell's avatar
rswindell committed
341
	$(EXEODIR)/nopen.o \
342
	$(EXEODIR)/crc16.o \
343
344
	$(EXEODIR)/str_util.o \
	$(EXEODIR)/filewrap.o \
rswindell's avatar
rswindell committed
345
	$(EXEODIR)/genwrap.o \
deuce's avatar
deuce committed
346
	$(EXEODIR)/dirwrap.o $(BUILD_DEPENDS)
347
    ifndef BUILD_DEPENDS
rswindell's avatar
rswindell committed
348
	@echo Linking $@
349
	@$(CC) -o $@ $^ $(UIFC_LFLAGS)
350
    endif
rswindell's avatar
rswindell committed
351

rswindell's avatar
rswindell committed
352
353
354
355
356
357
358
359
360
# ADDFILES
$(ADDFILES): \
	$(EXEODIR)/addfiles.o \
	$(EXEODIR)/ars.o \
	$(EXEODIR)/date_str.o \
	$(EXEODIR)/load_cfg.o \
	$(EXEODIR)/scfglib1.o \
	$(EXEODIR)/scfglib2.o \
	$(EXEODIR)/nopen.o \
361
	$(EXEODIR)/crc16.o \
rswindell's avatar
rswindell committed
362
	$(EXEODIR)/str_util.o \
363
	$(EXEODIR)/dat_rec.o \
rswindell's avatar
rswindell committed
364
365
366
	$(EXEODIR)/filedat.o \
	$(EXEODIR)/filewrap.o \
	$(EXEODIR)/dirwrap.o \
deuce's avatar
deuce committed
367
	$(EXEODIR)/genwrap.o $(BUILD_DEPENDS)
368
    ifndef BUILD_DEPENDS
rswindell's avatar
rswindell committed
369
370
	@echo Linking $@
	@$(CC) -o $@ $^
371
    endif
rswindell's avatar
rswindell committed
372

373
374
375
376
377
378
379
380
381
# FILELIST
$(FILELIST): \
	$(EXEODIR)/filelist.o \
	$(EXEODIR)/ars.o \
	$(EXEODIR)/date_str.o \
	$(EXEODIR)/load_cfg.o \
	$(EXEODIR)/scfglib1.o \
	$(EXEODIR)/scfglib2.o \
	$(EXEODIR)/nopen.o \
382
	$(EXEODIR)/crc16.o \
383
384
385
386
387
	$(EXEODIR)/str_util.o \
	$(EXEODIR)/dat_rec.o \
	$(EXEODIR)/filedat.o \
	$(EXEODIR)/filewrap.o \
	$(EXEODIR)/dirwrap.o \
deuce's avatar
deuce committed
388
	$(EXEODIR)/genwrap.o $(BUILD_DEPENDS)
389
    ifndef BUILD_DEPENDS
390
391
	@echo Linking $@
	@$(CC) -o $@ $^
392
    endif
393

394
395
396
397
398
399
400
401
402
# MAKEUSER
$(MAKEUSER): \
	$(EXEODIR)/makeuser.o \
	$(EXEODIR)/ars.o \
	$(EXEODIR)/date_str.o \
	$(EXEODIR)/load_cfg.o \
	$(EXEODIR)/scfglib1.o \
	$(EXEODIR)/scfglib2.o \
	$(EXEODIR)/nopen.o \
403
	$(EXEODIR)/crc16.o \
404
405
406
407
408
	$(EXEODIR)/str_util.o \
	$(EXEODIR)/dat_rec.o \
	$(EXEODIR)/userdat.o \
	$(EXEODIR)/filewrap.o \
	$(EXEODIR)/dirwrap.o \
deuce's avatar
deuce committed
409
	$(EXEODIR)/genwrap.o $(BUILD_DEPENDS)
410
    ifndef BUILD_DEPENDS
411
412
	@echo Linking $@
	@$(CC) -o $@ $^
413
    endif
414

415
416
417
depend:
	@$(DELETE) $(LIBODIR)/.depend
	@$(DELETE) $(EXEODIR)/.depend
deuce's avatar
deuce committed
418
419
420
	$(MAKE) BUILD_DEPENDS=notarealfile

$(BUILD_DEPENDS):
421

422
423
-include $(LIBODIR)/.depend
-include $(EXEODIR)/.depend
424
425
-include $(LIBODIR)/*.d
-include $(EXEODIR)/*.d