GNUmakefile 9.87 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)
deuce's avatar
deuce committed
107
 CFLAGS += -D_REENTRANT -DUSE_XP_SEMAPHORES -D__unix__ -I/usr/pkg/include -DNEEDS_FORKPTY
108
109
110
111
112
113
114
 LFLAGS := -lm -lpthread -L/usr/pkg/lib
endif

ifeq ($(os),qnx)
 LFLAGS := -lm -lsocket
endif

115
ifdef DEBUG
116
117
118
119
120
121
 ifdef bcc
  CFLAGS	+=	-y -v -Od
 else
  CFLAGS	+=	-ggdb
 endif
 CFLAGS  +=	-D_DEBUG
122
123
else
 CFLAGS	+= -O3
124
endif
125

126
127
128
129
ifdef JSLIB
 LIBS	+=	$(JSLIB)
else
 LIBS	+=	../../lib/mozilla/js/$(os).$(BUILD)/libjs.a
130
131
endif

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

rswindell's avatar
rswindell committed
149
150
151
include targets.mk		# defines all targets
include objects.mk		# defines $(OBJS)
include sbbsdefs.mk		# defines $(SBBSDEFS)
152

deuce's avatar
deuce committed
153
ifeq ($(os),gnu)
deuce's avatar
deuce committed
154
 CFLAGS += -DUSE_XP_SEMAPHORES -DNEEDS_FORKPTY -D_POSIX_THREADS
deuce's avatar
deuce committed
155
156
157
 OBJS	+= $(LIBODIR)$(SLASH)sem.$(OFILE)
endif

158
ifeq ($(os),netbsd)
deuce's avatar
deuce committed
159
 OBJS	+= $(LIBODIR)$(SLASH)xpsem.$(OFILE)
160
161
endif

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

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

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

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

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

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

$(LIBODIR):
	mkdir $(LIBODIR)

$(EXEODIR):
	mkdir $(EXEODIR)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

rswindell's avatar
rswindell committed
312
313
314
315
316
317
318
319
320
# 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 \
321
322
	$(EXEODIR)/nopen.o \
	$(EXEODIR)/str_util.o \
323
	$(EXEODIR)/dat_rec.o \
rswindell's avatar
rswindell committed
324
325
	$(EXEODIR)/userdat.o \
	$(EXEODIR)/rechocfg.o \
326
	$(EXEODIR)/conwrap.o \
rswindell's avatar
rswindell committed
327
328
329
330
	$(EXEODIR)/dirwrap.o \
	$(EXEODIR)/genwrap.o \
	$(SMBLIB) \
	$(EXEODIR)/smbtxt.o \
deuce's avatar
deuce committed
331
	$(EXEODIR)/lzh.o $(BUILD_DEPENDS)
332
    ifndef BUILD_DEPENDS
rswindell's avatar
rswindell committed
333
	@echo Linking $@
334
	@$(CC) -o $@ $^
335
    endif
rswindell's avatar
rswindell committed
336

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

rswindell's avatar
rswindell committed
353
354
355
356
357
358
359
360
361
# 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 \
362
	$(EXEODIR)/crc16.o \
rswindell's avatar
rswindell committed
363
	$(EXEODIR)/str_util.o \
364
	$(EXEODIR)/dat_rec.o \
rswindell's avatar
rswindell committed
365
366
367
	$(EXEODIR)/filedat.o \
	$(EXEODIR)/filewrap.o \
	$(EXEODIR)/dirwrap.o \
deuce's avatar
deuce committed
368
	$(EXEODIR)/genwrap.o $(BUILD_DEPENDS)
369
    ifndef BUILD_DEPENDS
rswindell's avatar
rswindell committed
370
371
	@echo Linking $@
	@$(CC) -o $@ $^
372
    endif
rswindell's avatar
rswindell committed
373

374
375
376
377
378
379
380
381
382
# 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 \
383
	$(EXEODIR)/crc16.o \
384
385
386
387
388
	$(EXEODIR)/str_util.o \
	$(EXEODIR)/dat_rec.o \
	$(EXEODIR)/filedat.o \
	$(EXEODIR)/filewrap.o \
	$(EXEODIR)/dirwrap.o \
deuce's avatar
deuce committed
389
	$(EXEODIR)/genwrap.o $(BUILD_DEPENDS)
390
    ifndef BUILD_DEPENDS
391
392
	@echo Linking $@
	@$(CC) -o $@ $^
393
    endif
394

395
396
397
398
399
400
401
402
403
# 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 \
404
	$(EXEODIR)/crc16.o \
405
406
407
408
409
	$(EXEODIR)/str_util.o \
	$(EXEODIR)/dat_rec.o \
	$(EXEODIR)/userdat.o \
	$(EXEODIR)/filewrap.o \
	$(EXEODIR)/dirwrap.o \
deuce's avatar
deuce committed
410
	$(EXEODIR)/genwrap.o $(BUILD_DEPENDS)
411
    ifndef BUILD_DEPENDS
412
413
	@echo Linking $@
	@$(CC) -o $@ $^
414
    endif
415

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

$(BUILD_DEPENDS):
422

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