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

rswindell's avatar
rswindell committed
109
110
111
include targets.mk		# defines all targets
include objects.mk		# defines $(OBJS)
include sbbsdefs.mk		# defines $(SBBSDEFS)
112
113

SBBSLIB	=	$(LIBODIR)/sbbs.a
114

rswindell's avatar
rswindell committed
115
vpath %.c $(XPDEV) $(UIFC)
116
vpath %.cpp $(UIFC)
rswindell's avatar
rswindell committed
117

118
119
# Implicit C Compile Rule for utils
$(EXEODIR)/%.o : %.c
120
   ifndef bcc
121
	@echo Compiling $<
122
   endif
123
	@$(CC) $(CFLAGS) -o $@ -c $<
124

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

132
133
# Implicit C Compile Rule for SBBS
$(LIBODIR)/%.o : %.c
134
   ifndef bcc
135
	@echo Compiling $<
136
   endif
137
	@$(CC) $(CFLAGS) $(SBBSDEFS) -o $@ -c $<
138
139
140

# Implicit C++ Compile Rule for SBBS
$(LIBODIR)/%.o : %.cpp
141
   ifndef bcc
142
	@echo Compiling $<
143
   endif
144
	@$(CCPP) $(CFLAGS) $(SBBSDEFS) -o $@ -c $<
145
146
147
148
149
150
151
152

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

$(EXEODIR):
	mkdir $(EXEODIR)

153
154
CON_OBJS	= $(EXEODIR)/sbbscon.o $(EXEODIR)/conwrap.o \
		  $(EXEODIR)/ini_file.o $(EXEODIR)/sbbs_ini.o
155
FTP_OBJS	= $(LIBODIR)/ftpsrvr.o
156
MAIL_OBJS	= $(LIBODIR)/mailsrvr.o $(LIBODIR)/mxlookup.o \
rswindell's avatar
rswindell committed
157
158
 		  $(LIBODIR)/mime.o
WEB_OBJS	= $(LIBODIR)/websrvr.o $(LIBODIR)/sockwrap.o
159
160
SERVICE_OBJS= $(LIBODIR)/services.o

rswindell's avatar
rswindell committed
161
162
MONO_OBJS	= $(CON_OBJS) $(FTP_OBJS) $(WEB_OBJS) \
			$(MAIL_OBJS) $(SERVICE_OBJS)
163
164

# Monolithic Synchronet executable Build Rule
165
$(SBBSMONO): $(MONO_OBJS) $(OBJS) $(LIBS) $(LIBODIR)/ver.o 
166
	@echo Linking $@
167
	@$(CCPP) -o $@ $(LFLAGS) $^
168
169

# Synchronet BBS library Link Rule
170
$(SBBS): $(OBJS) $(LIBS) $(LIBODIR)/ver.o
171
172
173
	$(LD) $(LFLAGS) -S -o $(SBBS) $^ $(LIBS) -o $@

# FTP Server Link Rule
174
$(FTPSRVR): $(LIBODIR)/ftpsrvr.o $(SBBSLIB)
175
176
177
	$(LD) $(LFLAGS) -S $^ $(LIBS) -o $@ 

# Mail Server Link Rule
178
$(MAILSRVR): $(MAIL_OBJS) $(SBBSLIB)
179
180
181
	$(LD) $(LFLAGS) -S $^ $(LIBS) -o $@

# Synchronet Console Build Rule
182
$(SBBSCON): $(CON_OBJS) $(SBBSLIB)
183
	@$(CC) $(CFLAGS) -o $@ $^
184
185
186
187

# Specifc Compile Rules
$(LIBODIR)/ftpsrvr.o: ftpsrvr.c ftpsrvr.h
	@echo Compiling $<
188
	@$(CC) $(CFLAGS) -DFTPSRVR_EXPORTS -o $@ -c $<
189
190
191

$(LIBODIR)/mailsrvr.o: mailsrvr.c mailsrvr.h
	@echo Compiling $<
192
	@$(CC) $(CFLAGS) -DMAILSRVR_EXPORTS -o $@ -c $<
193
194
195

$(LIBODIR)/mxlookup.o: mxlookup.c
	@echo Compiling $<
196
	@$(CC) $(CFLAGS) -DMAILSRVR_EXPORTS -o $@ -c $<
197
198
199

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

rswindell's avatar
rswindell committed
202
203
204
205
$(LIBODIR)/websrvr.o: websrvr.c websrvr.h
	@echo Compiling $<
	@$(CC) $(CFLAGS) -DWEBSRVR_EXPORTS -o $@ -c $<

206
207
$(LIBODIR)/services.o: services.c services.h
	@echo Compiling $<
208
	@$(CC) $(CFLAGS) -DSERVICES_EXPORTS -o $@ -c $<
209
210

# Baja Utility
211
212
$(BAJA): $(EXEODIR)/baja.o $(EXEODIR)/ars.o $(EXEODIR)/crc32.o \
	$(EXEODIR)/genwrap.o $(EXEODIR)/filewrap.o
213
	@echo Linking $@
214
	@$(CC) -o $@ $^
215
216

# Node Utility
rswindell's avatar
rswindell committed
217
$(NODE): $(EXEODIR)/node.o $(EXEODIR)/genwrap.o $(EXEODIR)/filewrap.o
218
	@echo Linking $@
219
	@$(CC) -o $@ $^ 
220

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

223
# FIXSMB Utility
224
$(FIXSMB): $(EXEODIR)/fixsmb.o $(SMBLIB) $(EXEODIR)/genwrap.o
225
	@echo Linking $@
226
	@$(CC) -o $@ $^
227
228

# CHKSMB Utility
rob's avatar
rob committed
229
$(CHKSMB): $(EXEODIR)/chksmb.o $(SMBLIB) $(EXEODIR)/conwrap.o $(EXEODIR)/dirwrap.o $(EXEODIR)/genwrap.o
230
	@echo Linking $@
231
	@$(CC) -o $@ $^
232
233

# SMB Utility
234
$(SMBUTIL): $(EXEODIR)/smbutil.o $(SMBLIB) $(EXEODIR)/conwrap.o $(EXEODIR)/dirwrap.o \
235
236
	$(EXEODIR)/genwrap.o $(EXEODIR)/smbtxt.o $(EXEODIR)/crc32.o $(EXEODIR)/lzh.o \
	$(EXEODIR)/date_str.o $(EXEODIR)/str_util.o
237
	@echo Linking $@
238
	@$(CC) -o $@ $^
239

rswindell's avatar
rswindell committed
240
241
242
243
244
245
246
247
248
# 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 \
249
250
	$(EXEODIR)/nopen.o \
	$(EXEODIR)/str_util.o \
251
	$(EXEODIR)/dat_rec.o \
rswindell's avatar
rswindell committed
252
253
	$(EXEODIR)/userdat.o \
	$(EXEODIR)/rechocfg.o \
254
	$(EXEODIR)/conwrap.o \
rswindell's avatar
rswindell committed
255
256
257
258
	$(EXEODIR)/dirwrap.o \
	$(EXEODIR)/genwrap.o \
	$(SMBLIB) \
	$(EXEODIR)/smbtxt.o \
259
	$(EXEODIR)/lzh.o
rswindell's avatar
rswindell committed
260
	@echo Linking $@
261
	@$(CC) -o $@ $^
rswindell's avatar
rswindell committed
262

rswindell's avatar
rswindell committed
263
264
265
266
# SBBSecho Configuration Program
$(ECHOCFG): \
	$(EXEODIR)/echocfg.o \
	$(EXEODIR)/rechocfg.o \
267
	$(EXEODIR)/uifcx.o \
268
269
	$(EXEODIR)/uifcc.o \
	$(EXEODIR)/uifcfltk.o \
rswindell's avatar
rswindell committed
270
	$(EXEODIR)/nopen.o \
271
272
	$(EXEODIR)/str_util.o \
	$(EXEODIR)/filewrap.o \
273
274
	$(EXEODIR)/genwrap.o \
	../../lib/fltk/$(os)/libfltk.a
rswindell's avatar
rswindell committed
275
	@echo Linking $@
276
	@$(CC) -DUSE_CURSES -DUSE_FLTK -I../../include/fltk -o $@ $^
rswindell's avatar
rswindell committed
277

rswindell's avatar
rswindell committed
278
279
280
281
282
283
284
285
286
287
# 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 \
288
	$(EXEODIR)/dat_rec.o \
rswindell's avatar
rswindell committed
289
290
291
292
293
294
295
	$(EXEODIR)/filedat.o \
	$(EXEODIR)/filewrap.o \
	$(EXEODIR)/dirwrap.o \
	$(EXEODIR)/genwrap.o
	@echo Linking $@
	@$(CC) -o $@ $^

296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
# 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 $@ $^

314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
# 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 $@ $^


333
334
# Auto-dependency files (should go in output dir, but gcc v2.9.5 puts in cwd)
-include ./*.d
335
336
-include $(LIBODIR)/*.d
-include $(EXEODIR)/*.d