GNUmakefile 10.4 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
 CFLAGS	+=	-MMD -Wall
deuce's avatar
deuce committed
41
 CCPRE	:=	gcc
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
ifeq ($(shell uname -m),ppc)
 os		:=	$(os)-ppc
endif
67
# this line wont work with solaris unless awk in path is actually gawk 
68
os      :=	$(shell echo $(os) | tr "[ A-Z]" "[\-a-z]")
69
70
# remove '/' from "os/2"
os      :=  $(shell echo $(os) | tr -d "/")
71

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

80
81
LIBODIR :=	$(CCPRE).$(os).lib.$(BUILD)
EXEODIR :=	$(CCPRE).$(os).exe.$(BUILD)
82

83
DELETE	=	rm -f
84

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

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

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

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

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

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

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

132
133
134
ifdef JSLIB
 LIBS	+=	$(JSLIB)
else
135
 LIBS	+=	../../lib/mozilla/js/$(os).$(BUILD)/libjs.a ../../lib/mozilla/nspr/$(os).$(BUILD)/libnspr4.a
136
137
endif

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

155
156
157
158
159
#The following is needed for nspr support on Linux
ifeq ($(os),linux)
 LFLAGS	+=	-ldl
endif

rswindell's avatar
rswindell committed
160
161
162
include targets.mk		# defines all targets
include objects.mk		# defines $(OBJS)
include sbbsdefs.mk		# defines $(SBBSDEFS)
163

164
165
ifeq ($(USE_XP_SEMAPHORES),1)
 OBJS	+=	$(LIBODIR)$(SLASH)xpsem.$(OFILE)
166
167
endif

168
SBBSLIB	=	$(LIBODIR)/sbbs.a
169

rswindell's avatar
rswindell committed
170
vpath %.c $(XPDEV) $(UIFC)
171
vpath %.cpp $(UIFC)
rswindell's avatar
rswindell committed
172

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

180
# Implicit C++ Compile Rule for utils
deuce's avatar
deuce committed
181
$(EXEODIR)/%.o : %.cpp $(BUILD_DEPENDS)
182
   ifndef bcc
183
	@echo $(COMPILE_MSG) $<
184
   endif
185
	@$(CCPP) $(CFLAGS) -o $@ -c $<
186

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

# Implicit C++ Compile Rule for SBBS
deuce's avatar
deuce committed
195
$(LIBODIR)/%.o : %.cpp $(BUILD_DEPENDS)
196
   ifndef bcc
197
	@echo $(COMPILE_MSG) $<
198
   endif
199
	@$(CCPP) $(CFLAGS) $(SBBSDEFS) -o $@ -c $<
200
201
202
203
204
205
206

$(LIBODIR):
	mkdir $(LIBODIR)

$(EXEODIR):
	mkdir $(EXEODIR)

207
CON_OBJS	= $(EXEODIR)/sbbscon.o $(EXEODIR)/conwrap.o \
208
		  $(EXEODIR)/sbbs_ini.o
209
FTP_OBJS	= $(LIBODIR)/ftpsrvr.o
210
MAIL_OBJS	= $(LIBODIR)/mailsrvr.o $(LIBODIR)/mxlookup.o \
deuce's avatar
deuce committed
211
 		  $(LIBODIR)/mime.o $(LIBODIR)/base64.o
deuce's avatar
deuce committed
212
WEB_OBJS	= $(LIBODIR)/websrvr.o $(LIBODIR)/sockwrap.o $(LIBODIR)/base64.o
213
214
SERVICE_OBJS= $(LIBODIR)/services.o

rswindell's avatar
rswindell committed
215
216
MONO_OBJS	= $(CON_OBJS) $(FTP_OBJS) $(WEB_OBJS) \
			$(MAIL_OBJS) $(SERVICE_OBJS)
217
218
219
220
221
SMBLIB_OBJS = \
	$(EXEODIR)/smblib.o \
	$(EXEODIR)/filewrap.o \
	$(EXEODIR)/crc16.o

222
223

# Monolithic Synchronet executable Build Rule
224
FORCE$(SBBSMONO): $(MONO_OBJS) $(OBJS) $(LIBS)
deuce's avatar
deuce committed
225

226
$(SBBSMONO): $(MONO_OBJS) $(OBJS) $(LIBS)
227
	@echo Linking $@
228
	@$(CCPP) -o $@ $(LFLAGS) $^
229
230

# Synchronet BBS library Link Rule
231
FORCE$(SBBS): $(OBJS) $(LIBS)
deuce's avatar
deuce committed
232

233
$(SBBS): $(OBJS) $(LIBS)
234
235
236
	$(LD) $(LFLAGS) -S -o $(SBBS) $^ $(LIBS) -o $@

# FTP Server Link Rule
237
FORCE$(FTPSRVR): $(LIBODIR)/ftpsrvr.o $(SBBSLIB)
deuce's avatar
deuce committed
238
239

$(FTPSRVR): $(LIBODIR)/ftpsrvr.o $(SBBSLIB)
240
241
242
	$(LD) $(LFLAGS) -S $^ $(LIBS) -o $@ 

# Mail Server Link Rule
deuce's avatar
deuce committed
243
244
245
FORCE$(MAILSRVR): $(MAIL_OBJS) $(SBBSLIB)

$(MAILSRVR): $(MAIL_OBJS) $(SBBSLIB)
246
247
248
	$(LD) $(LFLAGS) -S $^ $(LIBS) -o $@

# Synchronet Console Build Rule
249
FORCE$(SBBSCON): $(CON_OBJS) $(SBBSLIB)
deuce's avatar
deuce committed
250
251

$(SBBSCON): $(CON_OBJS) $(SBBSLIB)
252
	@$(CC) $(CFLAGS) -o $@ $^
253
254

# Specifc Compile Rules
deuce's avatar
deuce committed
255
$(LIBODIR)/ftpsrvr.o: ftpsrvr.c ftpsrvr.h $(BUILD_DEPENDS)
256
	@echo $(COMPILE_MSG) $<
257
	@$(CC) $(CFLAGS) -DFTPSRVR_EXPORTS -o $@ -c $<
258

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

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

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

deuce's avatar
deuce committed
271
$(LIBODIR)/websrvr.o: websrvr.c websrvr.h $(BUILD_DEPENDS)
272
	@echo $(COMPILE_MSG) $<
deuce's avatar
deuce committed
273
274
	@$(CC) $(CFLAGS) -DWEBSRVR_EXPORTS -o $@ -c $<

deuce's avatar
deuce committed
275
$(LIBODIR)/base64.o: base64.c base64.h $(BUILD_DEPENDS)
276
	@echo $(COMPILE_MSG) $<
rswindell's avatar
rswindell committed
277
278
	@$(CC) $(CFLAGS) -DWEBSRVR_EXPORTS -o $@ -c $<

deuce's avatar
deuce committed
279
$(LIBODIR)/services.o: services.c services.h $(BUILD_DEPENDS)
280
	@echo $(COMPILE_MSG) $<
281
	@$(CC) $(CFLAGS) -DSERVICES_EXPORTS -o $@ -c $<
282
283

# Baja Utility
284
285
286
287
288
289
290
BAJA_OBJS = \
	$(EXEODIR)/baja.o \
	$(EXEODIR)/ars.o \
	$(EXEODIR)/crc32.o \
	$(EXEODIR)/genwrap.o \
	$(EXEODIR)/filewrap.o
FORCE$(BAJA): $(BAJA_OBJS)
deuce's avatar
deuce committed
291

292
$(BAJA): $(BAJA_OBJS)
293
	@echo Linking $@
294
	@$(CC) -o $@ $^
295
296

# Node Utility
297
298
299
300
301
NODE_OBJS = \
	$(EXEODIR)/node.o \
	$(EXEODIR)/genwrap.o \
	$(EXEODIR)/filewrap.o
FORCE$(NODE): $(NODE_OBJS)
deuce's avatar
deuce committed
302

303
$(NODE): $(NODE_OBJS)
304
	@echo Linking $@
305
	@$(CC) -o $@ $^ 
306
307

# FIXSMB Utility
308
309
310
311
312
313
314
315
FIXSMB_OBJS = \
	$(EXEODIR)/fixsmb.o \
	$(SMBLIB_OBJS) \
	$(EXEODIR)/genwrap.o \
	$(EXEODIR)/str_util.o
FORCE$(FIXSMB): $(FIXSMB_OBJS)
	
$(FIXSMB): $(FIXSMB_OBJS)
316
	@echo Linking $@
317
	@$(CC) -o $@ $^
318
319

# CHKSMB Utility
320
321
322
323
324
325
326
CHKSMB_OBJS = \
	$(EXEODIR)/chksmb.o \
	$(SMBLIB_OBJS) \
	$(EXEODIR)/conwrap.o \
	$(EXEODIR)/dirwrap.o \
	$(EXEODIR)/genwrap.o
FORCE$(CHKSMB): $(CHKSMB_OBJS)
deuce's avatar
deuce committed
327

328
$(CHKSMB): $(CHKSMB_OBJS)
329
	@echo Linking $@
330
	@$(CC) -o $@ $^
331
332

# SMB Utility
333
334
335
SMBUTIL_OBJS = \
	$(EXEODIR)/smbutil.o \
	$(SMBLIB_OBJS) \
deuce's avatar
deuce committed
336
337
338
339
	$(EXEODIR)/conwrap.o \
	$(EXEODIR)/dirwrap.o \
	$(EXEODIR)/genwrap.o \
	$(EXEODIR)/smbtxt.o \
340
341
342
343
344
345
346
347
348
	$(EXEODIR)/crc32.o \
	$(EXEODIR)/lzh.o \
	$(EXEODIR)/date_str.o \
	$(EXEODIR)/str_util.o
FORCE$(SMBUTIL): $(SMBUTIL_OBJS)
	
$(SMBUTIL): $(SMBUTIL_OBJS)
	@echo Linking $@
	@$(CC) -o $@ $^
deuce's avatar
deuce committed
349

350
351
# SBBSecho (FidoNet Packet Tosser)
SBBSECHO_OBJS = \
rswindell's avatar
rswindell committed
352
353
354
355
356
357
358
	$(EXEODIR)/sbbsecho.o \
	$(EXEODIR)/ars.o \
	$(EXEODIR)/crc32.o \
	$(EXEODIR)/date_str.o \
	$(EXEODIR)/load_cfg.o \
	$(EXEODIR)/scfglib1.o \
	$(EXEODIR)/scfglib2.o \
359
360
	$(EXEODIR)/nopen.o \
	$(EXEODIR)/str_util.o \
361
	$(EXEODIR)/dat_rec.o \
rswindell's avatar
rswindell committed
362
363
	$(EXEODIR)/userdat.o \
	$(EXEODIR)/rechocfg.o \
364
	$(EXEODIR)/conwrap.o \
rswindell's avatar
rswindell committed
365
366
	$(EXEODIR)/dirwrap.o \
	$(EXEODIR)/genwrap.o \
367
	$(SMBLIB_OBJS) \
rswindell's avatar
rswindell committed
368
	$(EXEODIR)/smbtxt.o \
deuce's avatar
deuce committed
369
	$(EXEODIR)/lzh.o
370
371
372
373

FORCE$(SBBSECHO): $(SBBSECHO_OBJS)

$(SBBSECHO): $(SBBSECHO_OBJS)
rswindell's avatar
rswindell committed
374
	@echo Linking $@
375
	@$(CC) -o $@ $^
rswindell's avatar
rswindell committed
376

rswindell's avatar
rswindell committed
377
# SBBSecho Configuration Program
rswindell's avatar
rswindell committed
378
ECHOCFG_OBJS = \
deuce's avatar
deuce committed
379
380
381
382
383
384
385
386
387
388
	$(EXEODIR)/echocfg.o \
	$(EXEODIR)/rechocfg.o \
	$(UIFC_OBJS) \
	$(EXEODIR)/nopen.o \
	$(EXEODIR)/crc16.o \
	$(EXEODIR)/str_util.o \
	$(EXEODIR)/filewrap.o \
	$(EXEODIR)/genwrap.o \
	$(EXEODIR)/dirwrap.o

389
390
391
FORCE$(ECHOCFG): $(ECHOCFG_OBJS)

$(ECHOCFG): $(ECHOCFG_OBJS)
rswindell's avatar
rswindell committed
392
	@echo Linking $@
393
	@$(CC) -o $@ $^ $(UIFC_LFLAGS)
rswindell's avatar
rswindell committed
394

rswindell's avatar
rswindell committed
395
# ADDFILES
396
ADDFILES_OBJS = \
deuce's avatar
deuce committed
397
398
399
400
401
402
403
404
405
406
	$(EXEODIR)/addfiles.o \
	$(EXEODIR)/ars.o \
	$(EXEODIR)/date_str.o \
	$(EXEODIR)/load_cfg.o \
	$(EXEODIR)/scfglib1.o \
	$(EXEODIR)/scfglib2.o \
	$(EXEODIR)/nopen.o \
	$(EXEODIR)/crc16.o \
	$(EXEODIR)/str_util.o \
	$(EXEODIR)/dat_rec.o \
407
	$(EXEODIR)/userdat.o \
deuce's avatar
deuce committed
408
409
410
411
412
	$(EXEODIR)/filedat.o \
	$(EXEODIR)/filewrap.o \
	$(EXEODIR)/dirwrap.o \
	$(EXEODIR)/genwrap.o

413
414
415
FORCE$(ADDFILES): $(ADDFILES_OBJS)

$(ADDFILES): $(ADDFILES_OBJS)
rswindell's avatar
rswindell committed
416
417
418
	@echo Linking $@
	@$(CC) -o $@ $^

419
# FILELIST
420
FILELIST_OBJS = \
deuce's avatar
deuce committed
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
	$(EXEODIR)/filelist.o \
	$(EXEODIR)/ars.o \
	$(EXEODIR)/date_str.o \
	$(EXEODIR)/load_cfg.o \
	$(EXEODIR)/scfglib1.o \
	$(EXEODIR)/scfglib2.o \
	$(EXEODIR)/nopen.o \
	$(EXEODIR)/crc16.o \
	$(EXEODIR)/str_util.o \
	$(EXEODIR)/dat_rec.o \
	$(EXEODIR)/filedat.o \
	$(EXEODIR)/filewrap.o \
	$(EXEODIR)/dirwrap.o \
	$(EXEODIR)/genwrap.o

436
437
438
FORCE$(FILELIST): $(FILELIST_OBJS)

$(FILELIST): $(FILELIST_OBJS)
439
440
441
	@echo Linking $@
	@$(CC) -o $@ $^

442
# MAKEUSER
443
MAKEUSER_OBJS = \
deuce's avatar
deuce committed
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
	$(EXEODIR)/makeuser.o \
	$(EXEODIR)/ars.o \
	$(EXEODIR)/date_str.o \
	$(EXEODIR)/load_cfg.o \
	$(EXEODIR)/scfglib1.o \
	$(EXEODIR)/scfglib2.o \
	$(EXEODIR)/nopen.o \
	$(EXEODIR)/crc16.o \
	$(EXEODIR)/str_util.o \
	$(EXEODIR)/dat_rec.o \
	$(EXEODIR)/userdat.o \
	$(EXEODIR)/filewrap.o \
	$(EXEODIR)/dirwrap.o \
	$(EXEODIR)/genwrap.o

459
460
461
FORCE$(MAKEUSER): $(MAKEUSER_OBJS)

$(MAKEUSER): $(MAKEUSER_OBJS)
462
463
	@echo Linking $@
	@$(CC) -o $@ $^
deuce's avatar
deuce committed
464

rswindell's avatar
rswindell committed
465
466
467
468
469
470
471
# JSEXEC
JSEXEC_OBJS = \
	$(EXEODIR)/jsexec.o \
	$(OBJS)

FORCE$(JSEXEC): $(JSEXEC_OBJS)

472
$(JSEXEC): $(JSEXEC_OBJS) $(LIBS)
rswindell's avatar
rswindell committed
473
	@echo Linking $@
474
	@$(CCPP) -o $@ $(LFLAGS) $^
rswindell's avatar
rswindell committed
475
476
	
# ANS2MSG
deuce's avatar
deuce committed
477
478
FORCE$(ANS2MSG): $(ANS2MSG).o

rswindell's avatar
rswindell committed
479
# MSG2NAS
deuce's avatar
deuce committed
480
FORCE$(MSG2ANS): $(MSG2ANS).o
481

482
483
484
depend:
	@$(DELETE) $(LIBODIR)/.depend
	@$(DELETE) $(EXEODIR)/.depend
deuce's avatar
deuce committed
485
	$(MAKE) BUILD_DEPENDS=FORCE
deuce's avatar
deuce committed
486

deuce's avatar
deuce committed
487
FORCE:
488

489
490
-include $(LIBODIR)/.depend
-include $(EXEODIR)/.depend
491
492
-include $(LIBODIR)/*.d
-include $(EXEODIR)/*.d