GNUmakefile 8.36 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
41
42
43
 CC		=	gcc
 CCPRE	:=	gcc
 CCPP	=	g++
 LD		=	ld
44
 CFLAGS	+=	-MMD -Wall
45
endif
46
47
48
49
SLASH	=	/
OFILE	=	o

LIBFILE	=	.a
rswindell's avatar
rswindell committed
50
UIFC	=	../uifc/
51
XPDEV	=	../xpdev/
52

53
54
ifndef os
 os		:=	$(shell uname)
55
endif
56
57
58
# 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)}')
59
60
# remove '/' from "os/2"
os      :=  $(shell echo $(os) | tr -d "/")
61

62
63
ifeq ($(os),freebsd)
 BSD	=	1
64
else
65
66
67
 ifeq ($(os),openbsd)
  BSD	=	1
 endif
68
endif
69

70
71
LIBODIR :=	$(CCPRE).$(os).lib.$(BUILD)
EXEODIR :=	$(CCPRE).$(os).exe.$(BUILD)
72

73
DELETE	=	rm -f
74

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

77
78
79
80
ifdef BSD	# BSD
 CFLAGS	+=	-D_THREAD_SAFE
 # Math libraries needed and uses pthread
 LFLAGS	:=	-lm -pthread -lutil
81
else			# Linux / Other UNIX
82
83
84
85
86
87
 # Math and pthread libraries needed
 ifdef bcc
  LFLAGS	:=	libpthread.so
 else
  LFLAGS	:=	-lm -lpthread -lutil
 endif
88
endif
89

90
91
ifeq ($(os),linux)    # Linux
 CFLAGS	+= -D_THREAD_SUID_BROKEN
92
93
endif

94
95
96
97
98
ifeq ($(os),sunos)    # Solaris
 CFLAGS	+= -D_REENTRANT -D__solaris__ -DNEEDS_DAEMON -D_POSIX_PTHREAD_SEMANTICS -DNEEDS_FORKPTY
 LFLAGS := -lm -lpthread -lsocket -lnsl -lrt
endif

99
ifdef DEBUG
100
101
102
103
104
105
 ifdef bcc
  CFLAGS	+=	-y -v -Od
 else
  CFLAGS	+=	-ggdb
 endif
 CFLAGS  +=	-D_DEBUG
106
107
else
 CFLAGS	+= -O3
108
endif
109

110
111
112
113
ifdef JSLIB
 LIBS	+=	$(JSLIB)
else
 LIBS	+=	../../lib/mozilla/js/$(os).$(BUILD)/libjs.a
114
115
endif

116
117
# The following are needed for echocfg (uses UIFC)
UIFC_OBJS =	$(EXEODIR)/uifcx.o
118
ifdef USE_FLTK
119
120
121
 CFLAGS +=	-DUSE_FLTK -I../../include/fltk
 UIFC_LFLAGS += -L../../lib/fltk/$(os) -L/usr/X11R6/lib -lm -lfltk -lX11
 UIFC_OBJS+=	$(EXEODIR)/uifcfltk.o
122
endif
deuce's avatar
deuce committed
123
ifdef USE_CURSES
124
125
126
 CFLAGS +=	-DUSE_CURSES
 UIFC_LFLAGS += -lcurses
 UIFC_OBJS +=	$(EXEODIR)/uifcc.o
deuce's avatar
deuce committed
127
endif
128

rswindell's avatar
rswindell committed
129
130
131
include targets.mk		# defines all targets
include objects.mk		# defines $(OBJS)
include sbbsdefs.mk		# defines $(SBBSDEFS)
132

deuce's avatar
deuce committed
133
134
135
136
137
ifeq ($(os),gnu)
 CFLAGS += -D_NEED_SEM -DNEEDS_FORKPTY -D_POSIX_THREADS
 OBJS	+= $(LIBODIR)$(SLASH)sem.$(OFILE)
endif

138
SBBSLIB	=	$(LIBODIR)/sbbs.a
139

rswindell's avatar
rswindell committed
140
vpath %.c $(XPDEV) $(UIFC)
141
vpath %.cpp $(UIFC)
rswindell's avatar
rswindell committed
142

143
144
# Implicit C Compile Rule for utils
$(EXEODIR)/%.o : %.c
145
   ifndef bcc
146
	@echo Compiling $<
147
   endif
148
	@$(CC) $(CFLAGS) -o $@ -c $<
149

150
151
152
153
154
# Implicit C++ Compile Rule for utils
$(EXEODIR)/%.o : %.cpp
   ifndef bcc
	@echo Compiling $<
   endif
155
	@$(CCPP) $(CFLAGS) -o $@ -c $<
156

157
158
# Implicit C Compile Rule for SBBS
$(LIBODIR)/%.o : %.c
159
   ifndef bcc
160
	@echo Compiling $<
161
   endif
162
	@$(CC) $(CFLAGS) $(SBBSDEFS) -o $@ -c $<
163
164
165

# Implicit C++ Compile Rule for SBBS
$(LIBODIR)/%.o : %.cpp
166
   ifndef bcc
167
	@echo Compiling $<
168
   endif
169
	@$(CCPP) $(CFLAGS) $(SBBSDEFS) -o $@ -c $<
170
171
172
173
174
175
176
177

# Create output directories
$(LIBODIR):
	mkdir $(LIBODIR)

$(EXEODIR):
	mkdir $(EXEODIR)

178
179
CON_OBJS	= $(EXEODIR)/sbbscon.o $(EXEODIR)/conwrap.o \
		  $(EXEODIR)/ini_file.o $(EXEODIR)/sbbs_ini.o
180
FTP_OBJS	= $(LIBODIR)/ftpsrvr.o
181
MAIL_OBJS	= $(LIBODIR)/mailsrvr.o $(LIBODIR)/mxlookup.o \
deuce's avatar
deuce committed
182
 		  $(LIBODIR)/mime.o $(LIBODIR)/base64.o
deuce's avatar
deuce committed
183
WEB_OBJS	= $(LIBODIR)/websrvr.o $(LIBODIR)/sockwrap.o $(LIBODIR)/base64.o
184
185
SERVICE_OBJS= $(LIBODIR)/services.o

rswindell's avatar
rswindell committed
186
187
MONO_OBJS	= $(CON_OBJS) $(FTP_OBJS) $(WEB_OBJS) \
			$(MAIL_OBJS) $(SERVICE_OBJS)
188
189

# Monolithic Synchronet executable Build Rule
190
$(SBBSMONO): $(MONO_OBJS) $(OBJS) $(LIBS) $(LIBODIR)/ver.o 
191
	@echo Linking $@
192
	@$(CCPP) -o $@ $(LFLAGS) $^
193
194

# Synchronet BBS library Link Rule
195
$(SBBS): $(OBJS) $(LIBS) $(LIBODIR)/ver.o
196
197
198
	$(LD) $(LFLAGS) -S -o $(SBBS) $^ $(LIBS) -o $@

# FTP Server Link Rule
199
$(FTPSRVR): $(LIBODIR)/ftpsrvr.o $(SBBSLIB)
200
201
202
	$(LD) $(LFLAGS) -S $^ $(LIBS) -o $@ 

# Mail Server Link Rule
203
$(MAILSRVR): $(MAIL_OBJS) $(SBBSLIB)
204
205
206
	$(LD) $(LFLAGS) -S $^ $(LIBS) -o $@

# Synchronet Console Build Rule
207
$(SBBSCON): $(CON_OBJS) $(SBBSLIB)
208
	@$(CC) $(CFLAGS) -o $@ $^
209
210
211
212

# Specifc Compile Rules
$(LIBODIR)/ftpsrvr.o: ftpsrvr.c ftpsrvr.h
	@echo Compiling $<
213
	@$(CC) $(CFLAGS) -DFTPSRVR_EXPORTS -o $@ -c $<
214
215
216

$(LIBODIR)/mailsrvr.o: mailsrvr.c mailsrvr.h
	@echo Compiling $<
217
	@$(CC) $(CFLAGS) -DMAILSRVR_EXPORTS -o $@ -c $<
218
219
220

$(LIBODIR)/mxlookup.o: mxlookup.c
	@echo Compiling $<
221
	@$(CC) $(CFLAGS) -DMAILSRVR_EXPORTS -o $@ -c $<
222
223
224

$(LIBODIR)/mime.o: mime.c
	@echo Compiling $<
225
	@$(CC) $(CFLAGS) -DMAILSRVR_EXPORTS -o $@ -c $<		
226

rswindell's avatar
rswindell committed
227
$(LIBODIR)/websrvr.o: websrvr.c websrvr.h
deuce's avatar
deuce committed
228
229
230
231
	@echo Compiling $<
	@$(CC) $(CFLAGS) -DWEBSRVR_EXPORTS -o $@ -c $<

$(LIBODIR)/base64.o: base64.c base64.h
rswindell's avatar
rswindell committed
232
233
234
	@echo Compiling $<
	@$(CC) $(CFLAGS) -DWEBSRVR_EXPORTS -o $@ -c $<

235
236
$(LIBODIR)/services.o: services.c services.h
	@echo Compiling $<
237
	@$(CC) $(CFLAGS) -DSERVICES_EXPORTS -o $@ -c $<
238
239

# Baja Utility
240
241
$(BAJA): $(EXEODIR)/baja.o $(EXEODIR)/ars.o $(EXEODIR)/crc32.o \
	$(EXEODIR)/genwrap.o $(EXEODIR)/filewrap.o
242
	@echo Linking $@
243
	@$(CC) -o $@ $^
244
245

# Node Utility
rswindell's avatar
rswindell committed
246
$(NODE): $(EXEODIR)/node.o $(EXEODIR)/genwrap.o $(EXEODIR)/filewrap.o
247
	@echo Linking $@
248
	@$(CC) -o $@ $^ 
249

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

252
# FIXSMB Utility
253
$(FIXSMB): $(EXEODIR)/fixsmb.o $(SMBLIB) $(EXEODIR)/genwrap.o $(EXEODIR)/str_util.o
254
	@echo Linking $@
255
	@$(CC) -o $@ $^
256
257

# CHKSMB Utility
rob's avatar
rob committed
258
$(CHKSMB): $(EXEODIR)/chksmb.o $(SMBLIB) $(EXEODIR)/conwrap.o $(EXEODIR)/dirwrap.o $(EXEODIR)/genwrap.o
259
	@echo Linking $@
260
	@$(CC) -o $@ $^
261
262

# SMB Utility
263
$(SMBUTIL): $(EXEODIR)/smbutil.o $(SMBLIB) $(EXEODIR)/conwrap.o $(EXEODIR)/dirwrap.o \
264
265
	$(EXEODIR)/genwrap.o $(EXEODIR)/smbtxt.o $(EXEODIR)/crc32.o $(EXEODIR)/lzh.o \
	$(EXEODIR)/date_str.o $(EXEODIR)/str_util.o
266
	@echo Linking $@
267
	@$(CC) -o $@ $^
268

rswindell's avatar
rswindell committed
269
270
271
272
273
274
275
276
277
# 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 \
278
279
	$(EXEODIR)/nopen.o \
	$(EXEODIR)/str_util.o \
280
	$(EXEODIR)/dat_rec.o \
rswindell's avatar
rswindell committed
281
282
	$(EXEODIR)/userdat.o \
	$(EXEODIR)/rechocfg.o \
283
	$(EXEODIR)/conwrap.o \
rswindell's avatar
rswindell committed
284
285
286
287
	$(EXEODIR)/dirwrap.o \
	$(EXEODIR)/genwrap.o \
	$(SMBLIB) \
	$(EXEODIR)/smbtxt.o \
288
	$(EXEODIR)/lzh.o
rswindell's avatar
rswindell committed
289
	@echo Linking $@
290
	@$(CC) -o $@ $^
rswindell's avatar
rswindell committed
291

rswindell's avatar
rswindell committed
292
293
294
295
# SBBSecho Configuration Program
$(ECHOCFG): \
	$(EXEODIR)/echocfg.o \
	$(EXEODIR)/rechocfg.o \
296
	$(UIFC_OBJS) \
rswindell's avatar
rswindell committed
297
	$(EXEODIR)/nopen.o \
298
	$(EXEODIR)/crc16.o \
299
300
	$(EXEODIR)/str_util.o \
	$(EXEODIR)/filewrap.o \
rswindell's avatar
rswindell committed
301
	$(EXEODIR)/genwrap.o \
302
	$(EXEODIR)/dirwrap.o
rswindell's avatar
rswindell committed
303
	@echo Linking $@
304
	@$(CC) -o $@ $^ $(UIFC_LFLAGS)
rswindell's avatar
rswindell committed
305

rswindell's avatar
rswindell committed
306
307
308
309
310
311
312
313
314
# 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 \
315
	$(EXEODIR)/crc16.o \
rswindell's avatar
rswindell committed
316
	$(EXEODIR)/str_util.o \
317
	$(EXEODIR)/dat_rec.o \
rswindell's avatar
rswindell committed
318
319
320
321
322
323
324
	$(EXEODIR)/filedat.o \
	$(EXEODIR)/filewrap.o \
	$(EXEODIR)/dirwrap.o \
	$(EXEODIR)/genwrap.o
	@echo Linking $@
	@$(CC) -o $@ $^

325
326
327
328
329
330
331
332
333
# 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 \
334
	$(EXEODIR)/crc16.o \
335
336
337
338
339
340
341
342
343
	$(EXEODIR)/str_util.o \
	$(EXEODIR)/dat_rec.o \
	$(EXEODIR)/filedat.o \
	$(EXEODIR)/filewrap.o \
	$(EXEODIR)/dirwrap.o \
	$(EXEODIR)/genwrap.o
	@echo Linking $@
	@$(CC) -o $@ $^

344
345
346
347
348
349
350
351
352
# 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 \
353
	$(EXEODIR)/crc16.o \
354
355
356
357
358
359
360
361
362
363
	$(EXEODIR)/str_util.o \
	$(EXEODIR)/dat_rec.o \
	$(EXEODIR)/userdat.o \
	$(EXEODIR)/filewrap.o \
	$(EXEODIR)/dirwrap.o \
	$(EXEODIR)/genwrap.o
	@echo Linking $@
	@$(CC) -o $@ $^


364
365
# Auto-dependency files (should go in output dir, but gcc v2.9.5 puts in cwd)
-include ./*.d
366
367
-include $(LIBODIR)/*.d
-include $(EXEODIR)/*.d