GNUmakefile 7.69 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

23
ifdef DEBUG
24
 BUILD	=	debug
25
else
26
 BUILD	=	release
27
28
endif

29
ifdef bcc
30
31
32
33
 CC		=	bc++ -q
 CCPRE	:=	bcc
 CCPP	=	bc++ -q
 LD		=	ilink -q
34
 CFLAGS +=	-mm -md -D__unix__ -w-csu -w-pch -w-ccc -w-rch -w-par -w-aus
35
else
36
37
38
39
 CC		=	gcc
 CCPRE	:=	gcc
 CCPP	=	g++
 LD		=	ld
40
 CFLAGS	+=	-MMD -Wall
41
endif
42
43
44
45
SLASH	=	/
OFILE	=	o

LIBFILE	=	.a
rswindell's avatar
rswindell committed
46
UIFC	=	../uifc/
47
XPDEV	=	../xpdev/
48

49
50
51
ifndef os
 os		:=	$(shell uname)
 $(warning OS not specified on command line, setting to '$(os)'.)
52
endif
53
54
55
# 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)}')
56

57
58
ifeq ($(os),freebsd)
 BSD	=	1
59
else
60
61
62
 ifeq ($(os),openbsd)
  BSD	=	1
 endif
63
endif
64

65
66
LIBODIR :=	$(CCPRE).$(os).lib.$(BUILD)
EXEODIR :=	$(CCPRE).$(os).exe.$(BUILD)
67

68
DELETE	=	rm -f
69

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

72
73
74
75
ifdef BSD	# BSD
 CFLAGS	+=	-D_THREAD_SAFE
 # Math libraries needed and uses pthread
 LFLAGS	:=	-lm -pthread -lutil
76
else			# Linux / Other UNIX
77
78
79
80
81
82
 # Math and pthread libraries needed
 ifdef bcc
  LFLAGS	:=	libpthread.so
 else
  LFLAGS	:=	-lm -lpthread -lutil
 endif
83
endif
84

85
86
ifeq ($(os),linux)    # Linux
 CFLAGS	+= -D_THREAD_SUID_BROKEN
87
88
endif

89
90
91
92
93
ifeq ($(os),sunos)    # Solaris
 CFLAGS	+= -D_REENTRANT -D__solaris__ -DNEEDS_DAEMON -D_POSIX_PTHREAD_SEMANTICS -DNEEDS_FORKPTY
 LFLAGS := -lm -lpthread -lsocket -lnsl -lrt
endif

94
ifdef DEBUG
95
96
97
98
99
100
 ifdef bcc
  CFLAGS	+=	-y -v -Od
 else
  CFLAGS	+=	-ggdb
 endif
 CFLAGS  +=	-D_DEBUG
101
endif
102

103
104
105
106
ifdef JSLIB
 LIBS	+=	$(JSLIB)
else
 LIBS	+=	../../lib/mozilla/js/$(os).$(BUILD)/libjs.a
107
108
endif

109
# The following are needed for echocfg
110
111
112
113
114
ifdef USE_FLTK
 CFLAGS += -DUSE_CURSES -DUSE_FLTK -I../../include/fltk
 LFLAGS_FLTK = -L../../lib/fltk/$(os) -L/usr/X11R6/lib -lfltk -lX11 -lcurses
 UIFC_FLTK = $(EXEODIR)/uifcfltk.o
endif
115

rswindell's avatar
rswindell committed
116
117
118
include targets.mk		# defines all targets
include objects.mk		# defines $(OBJS)
include sbbsdefs.mk		# defines $(SBBSDEFS)
119
120

SBBSLIB	=	$(LIBODIR)/sbbs.a
121

rswindell's avatar
rswindell committed
122
vpath %.c $(XPDEV) $(UIFC)
123
vpath %.cpp $(UIFC)
rswindell's avatar
rswindell committed
124

125
126
# Implicit C Compile Rule for utils
$(EXEODIR)/%.o : %.c
127
   ifndef bcc
128
	@echo Compiling $<
129
   endif
130
	@$(CC) $(CFLAGS) -o $@ -c $<
131

132
133
134
135
136
# Implicit C++ Compile Rule for utils
$(EXEODIR)/%.o : %.cpp
   ifndef bcc
	@echo Compiling $<
   endif
137
	@$(CCPP) $(CFLAGS) -o $@ -c $<
138

139
140
# Implicit C Compile Rule for SBBS
$(LIBODIR)/%.o : %.c
141
   ifndef bcc
142
	@echo Compiling $<
143
   endif
144
	@$(CC) $(CFLAGS) $(SBBSDEFS) -o $@ -c $<
145
146
147

# Implicit C++ Compile Rule for SBBS
$(LIBODIR)/%.o : %.cpp
148
   ifndef bcc
149
	@echo Compiling $<
150
   endif
151
	@$(CCPP) $(CFLAGS) $(SBBSDEFS) -o $@ -c $<
152
153
154
155
156
157
158
159

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

$(EXEODIR):
	mkdir $(EXEODIR)

160
161
CON_OBJS	= $(EXEODIR)/sbbscon.o $(EXEODIR)/conwrap.o \
		  $(EXEODIR)/ini_file.o $(EXEODIR)/sbbs_ini.o
162
FTP_OBJS	= $(LIBODIR)/ftpsrvr.o
163
MAIL_OBJS	= $(LIBODIR)/mailsrvr.o $(LIBODIR)/mxlookup.o \
rswindell's avatar
rswindell committed
164
165
 		  $(LIBODIR)/mime.o
WEB_OBJS	= $(LIBODIR)/websrvr.o $(LIBODIR)/sockwrap.o
166
167
SERVICE_OBJS= $(LIBODIR)/services.o

rswindell's avatar
rswindell committed
168
169
MONO_OBJS	= $(CON_OBJS) $(FTP_OBJS) $(WEB_OBJS) \
			$(MAIL_OBJS) $(SERVICE_OBJS)
170
171

# Monolithic Synchronet executable Build Rule
172
$(SBBSMONO): $(MONO_OBJS) $(OBJS) $(LIBS) $(LIBODIR)/ver.o 
173
	@echo Linking $@
174
	@$(CCPP) -o $@ $(LFLAGS) $^
175
176

# Synchronet BBS library Link Rule
177
$(SBBS): $(OBJS) $(LIBS) $(LIBODIR)/ver.o
178
179
180
	$(LD) $(LFLAGS) -S -o $(SBBS) $^ $(LIBS) -o $@

# FTP Server Link Rule
181
$(FTPSRVR): $(LIBODIR)/ftpsrvr.o $(SBBSLIB)
182
183
184
	$(LD) $(LFLAGS) -S $^ $(LIBS) -o $@ 

# Mail Server Link Rule
185
$(MAILSRVR): $(MAIL_OBJS) $(SBBSLIB)
186
187
188
	$(LD) $(LFLAGS) -S $^ $(LIBS) -o $@

# Synchronet Console Build Rule
189
$(SBBSCON): $(CON_OBJS) $(SBBSLIB)
190
	@$(CC) $(CFLAGS) -o $@ $^
191
192
193
194

# Specifc Compile Rules
$(LIBODIR)/ftpsrvr.o: ftpsrvr.c ftpsrvr.h
	@echo Compiling $<
195
	@$(CC) $(CFLAGS) -DFTPSRVR_EXPORTS -o $@ -c $<
196
197
198

$(LIBODIR)/mailsrvr.o: mailsrvr.c mailsrvr.h
	@echo Compiling $<
199
	@$(CC) $(CFLAGS) -DMAILSRVR_EXPORTS -o $@ -c $<
200
201
202

$(LIBODIR)/mxlookup.o: mxlookup.c
	@echo Compiling $<
203
	@$(CC) $(CFLAGS) -DMAILSRVR_EXPORTS -o $@ -c $<
204
205
206

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

rswindell's avatar
rswindell committed
209
210
211
212
$(LIBODIR)/websrvr.o: websrvr.c websrvr.h
	@echo Compiling $<
	@$(CC) $(CFLAGS) -DWEBSRVR_EXPORTS -o $@ -c $<

213
214
$(LIBODIR)/services.o: services.c services.h
	@echo Compiling $<
215
	@$(CC) $(CFLAGS) -DSERVICES_EXPORTS -o $@ -c $<
216
217

# Baja Utility
218
219
$(BAJA): $(EXEODIR)/baja.o $(EXEODIR)/ars.o $(EXEODIR)/crc32.o \
	$(EXEODIR)/genwrap.o $(EXEODIR)/filewrap.o
220
	@echo Linking $@
221
	@$(CC) -o $@ $^
222
223

# Node Utility
rswindell's avatar
rswindell committed
224
$(NODE): $(EXEODIR)/node.o $(EXEODIR)/genwrap.o $(EXEODIR)/filewrap.o
225
	@echo Linking $@
226
	@$(CC) -o $@ $^ 
227

rswindell's avatar
rswindell committed
228
229
SMBLIB = $(EXEODIR)/smblib.o $(EXEODIR)/filewrap.o

230
# FIXSMB Utility
231
$(FIXSMB): $(EXEODIR)/fixsmb.o $(SMBLIB) $(EXEODIR)/genwrap.o
232
	@echo Linking $@
233
	@$(CC) -o $@ $^
234
235

# CHKSMB Utility
rob's avatar
rob committed
236
$(CHKSMB): $(EXEODIR)/chksmb.o $(SMBLIB) $(EXEODIR)/conwrap.o $(EXEODIR)/dirwrap.o $(EXEODIR)/genwrap.o
237
	@echo Linking $@
238
	@$(CC) -o $@ $^
239
240

# SMB Utility
241
$(SMBUTIL): $(EXEODIR)/smbutil.o $(SMBLIB) $(EXEODIR)/conwrap.o $(EXEODIR)/dirwrap.o \
242
243
	$(EXEODIR)/genwrap.o $(EXEODIR)/smbtxt.o $(EXEODIR)/crc32.o $(EXEODIR)/lzh.o \
	$(EXEODIR)/date_str.o $(EXEODIR)/str_util.o
244
	@echo Linking $@
245
	@$(CC) -o $@ $^
246

rswindell's avatar
rswindell committed
247
248
249
250
251
252
253
254
255
# 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 \
256
257
	$(EXEODIR)/nopen.o \
	$(EXEODIR)/str_util.o \
258
	$(EXEODIR)/dat_rec.o \
rswindell's avatar
rswindell committed
259
260
	$(EXEODIR)/userdat.o \
	$(EXEODIR)/rechocfg.o \
261
	$(EXEODIR)/conwrap.o \
rswindell's avatar
rswindell committed
262
263
264
265
	$(EXEODIR)/dirwrap.o \
	$(EXEODIR)/genwrap.o \
	$(SMBLIB) \
	$(EXEODIR)/smbtxt.o \
266
	$(EXEODIR)/lzh.o
rswindell's avatar
rswindell committed
267
	@echo Linking $@
268
	@$(CC) -o $@ $^
rswindell's avatar
rswindell committed
269

rswindell's avatar
rswindell committed
270
271
272
273
# SBBSecho Configuration Program
$(ECHOCFG): \
	$(EXEODIR)/echocfg.o \
	$(EXEODIR)/rechocfg.o \
274
	$(EXEODIR)/uifcx.o \
275
	$(EXEODIR)/uifcc.o \
276
	$(UIFC_FLTK) \
rswindell's avatar
rswindell committed
277
	$(EXEODIR)/nopen.o \
278
279
	$(EXEODIR)/str_util.o \
	$(EXEODIR)/filewrap.o \
rswindell's avatar
rswindell committed
280
	$(EXEODIR)/genwrap.o
rswindell's avatar
rswindell committed
281
	@echo Linking $@
282
	@$(CC) -o $@ $^ $(LFLAGS_FLTK)
rswindell's avatar
rswindell committed
283

rswindell's avatar
rswindell committed
284
285
286
287
288
289
290
291
292
293
# 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 \
	$(EXEODIR)/str_util.o \
294
	$(EXEODIR)/dat_rec.o \
rswindell's avatar
rswindell committed
295
296
297
298
299
300
301
	$(EXEODIR)/filedat.o \
	$(EXEODIR)/filewrap.o \
	$(EXEODIR)/dirwrap.o \
	$(EXEODIR)/genwrap.o
	@echo Linking $@
	@$(CC) -o $@ $^

302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
# 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 \
	$(EXEODIR)/str_util.o \
	$(EXEODIR)/dat_rec.o \
	$(EXEODIR)/filedat.o \
	$(EXEODIR)/filewrap.o \
	$(EXEODIR)/dirwrap.o \
	$(EXEODIR)/genwrap.o
	@echo Linking $@
	@$(CC) -o $@ $^

320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
# 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 \
	$(EXEODIR)/str_util.o \
	$(EXEODIR)/dat_rec.o \
	$(EXEODIR)/userdat.o \
	$(EXEODIR)/filewrap.o \
	$(EXEODIR)/dirwrap.o \
	$(EXEODIR)/genwrap.o
	@echo Linking $@
	@$(CC) -o $@ $^


339
340
# Auto-dependency files (should go in output dir, but gcc v2.9.5 puts in cwd)
-include ./*.d
341
342
-include $(LIBODIR)/*.d
-include $(EXEODIR)/*.d