GNUmakefile 8.04 KB
Newer Older
1
# GNUmakefile
2
3
4

#########################################################################
# Makefile for Synchronet BBS 											#
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 bcc
24
25
26
27
 CC		=	bc++ -q
 CCPRE	:=	bcc
 CCPP	=	bc++ -q
 LD		=	ilink -q
28
 CFLAGS +=	-mm -md -D__unix__ -w-csu -w-pch -w-ccc -w-rch -w-par -w-aus
29
else
30
31
32
33
 CC		=	gcc
 CCPRE	:=	gcc
 CCPP	=	g++
 LD		=	ld
34
 CFLAGS	+=	-MMD -Wall
35
endif
36
37
38
39
SLASH	=	/
OFILE	=	o

LIBFILE	=	.a
rswindell's avatar
rswindell committed
40
UIFC	=	../uifc/
41
XPDEV	=	../xpdev/
42

43
44
45
ifndef os
 os		:=	$(shell uname)
 $(warning OS not specified on command line, setting to '$(os)'.)
46
endif
47
48
49
# 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)}')
50

51
52
ifeq ($(os),freebsd)
 BSD	=	1
53
else
54
55
56
 ifeq ($(os),openbsd)
  BSD	=	1
 endif
57
endif
58

59
60
61
LIBODIR :=	$(CCPRE).$(os).lib
EXEODIR :=	$(CCPRE).$(os).exe

62
DELETE	=	rm -f
63

rswindell's avatar
rswindell committed
64
CFLAGS	+=	-DJAVASCRIPT -I../mozilla/js/src -I$(XPDEV) -I$(UIFC)
65

66
67
68
69
ifdef BSD	# BSD
 CFLAGS	+=	-D_THREAD_SAFE
 # Math libraries needed and uses pthread
 LFLAGS	:=	-lm -pthread -lutil
70
else			# Linux / Other UNIX
71
72
73
74
75
76
 # Math and pthread libraries needed
 ifdef bcc
  LFLAGS	:=	libpthread.so
 else
  LFLAGS	:=	-lm -lpthread -lutil
 endif
77
endif
78

79
80
ifeq ($(os),linux)    # Linux
 CFLAGS	+= -D_THREAD_SUID_BROKEN
81
82
endif

83
84
85
86
87
ifeq ($(os),sunos)    # Solaris
 CFLAGS	+= -D_REENTRANT -D__solaris__ -DNEEDS_DAEMON -D_POSIX_PTHREAD_SEMANTICS -DNEEDS_FORKPTY
 LFLAGS := -lm -lpthread -lsocket -lnsl -lrt
endif

88
ifdef DEBUG
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
 ifdef bcc
  CFLAGS	+=	-y -v -Od
 else
  CFLAGS	+=	-ggdb
 endif
 CFLAGS  +=	-D_DEBUG
 LIBODIR	:=	$(LIBODIR).debug
 EXEODIR	:=	$(EXEODIR).debug

 ifdef JSLIB
  LIBS	+=	$(JSLIB)
 else
  ifeq ($(os),freebsd)
   LIBS	+=	../mozilla/js/src/FreeBSD4.3-RELEASE_DBG.OBJ/libjs.a
  else
   ifeq ($(os),openbsd)
    LIBS	+=	../mozilla/js/src/OpenBSD3.1_DBG.OBJ/libjs.a
   else
    ifeq ($(os),linux)
     LIBS	+=	../mozilla/js/src/Linux_All_DBG.OBJ/libjs.a
109
110
111
   else
    ifeq ($(os),sunos)
     LIBS	+=	../mozilla/js/src/SunOS5.8_i86pc_DBG.OBJ/libjs.a
112
113
114
115
116
117
    else
     $(warning JavaScript library path for '$(os)' not defined.)
    endif
   endif
  endif
 endif
118
endif
119

120
else # RELEASE
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
 LIBODIR	:=	$(LIBODIR).release
 EXEODIR	:=	$(EXEODIR).release
 ifdef JSLIB
  LIBS	+=	$(JSLIB)
 else
  ifeq ($(os),freebsd)
   LIBS	+=	../mozilla/js/src/FreeBSD4.3-RELEASE_OPT.OBJ/libjs.a
  else
   ifeq ($(os),openbsd)
    LIBS	+=	../mozilla/js/src/OpenBSD3.1_OPT.OBJ/libjs.a
   else
    ifeq ($(os),linux)
     LIBS	+=	../mozilla/js/src/Linux_All_OPT.OBJ/libjs.a
    else
     $(warning JavaScript library path for '$(os)' not defined.)
    endif
   endif
  endif
 endif
140
141
endif

rswindell's avatar
rswindell committed
142
143
144
include targets.mk		# defines all targets
include objects.mk		# defines $(OBJS)
include sbbsdefs.mk		# defines $(SBBSDEFS)
145
146

SBBSLIB	=	$(LIBODIR)/sbbs.a
147

rswindell's avatar
rswindell committed
148
vpath %.c $(XPDEV) $(UIFC)
rswindell's avatar
rswindell committed
149

150
151
# Implicit C Compile Rule for utils
$(EXEODIR)/%.o : %.c
152
   ifndef bcc
153
	@echo Compiling $<
154
   endif
155
	@$(CC) $(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 \
rswindell's avatar
rswindell committed
182
183
 		  $(LIBODIR)/mime.o
WEB_OBJS	= $(LIBODIR)/websrvr.o $(LIBODIR)/sockwrap.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
228
229
230
$(LIBODIR)/websrvr.o: websrvr.c websrvr.h
	@echo Compiling $<
	@$(CC) $(CFLAGS) -DWEBSRVR_EXPORTS -o $@ -c $<

231
232
$(LIBODIR)/services.o: services.c services.h
	@echo Compiling $<
233
	@$(CC) $(CFLAGS) -DSERVICES_EXPORTS -o $@ -c $<
234
235

# Baja Utility
236
237
$(BAJA): $(EXEODIR)/baja.o $(EXEODIR)/ars.o $(EXEODIR)/crc32.o \
	$(EXEODIR)/genwrap.o $(EXEODIR)/filewrap.o
238
	@echo Linking $@
239
	@$(CC) -o $@ $^
240
241

# Node Utility
rswindell's avatar
rswindell committed
242
$(NODE): $(EXEODIR)/node.o $(EXEODIR)/genwrap.o $(EXEODIR)/filewrap.o
243
	@echo Linking $@
244
	@$(CC) -o $@ $^ 
245

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

248
# FIXSMB Utility
249
$(FIXSMB): $(EXEODIR)/fixsmb.o $(SMBLIB) $(EXEODIR)/genwrap.o
250
	@echo Linking $@
251
	@$(CC) -o $@ $^
252
253

# CHKSMB Utility
rob's avatar
rob committed
254
$(CHKSMB): $(EXEODIR)/chksmb.o $(SMBLIB) $(EXEODIR)/conwrap.o $(EXEODIR)/dirwrap.o $(EXEODIR)/genwrap.o
255
	@echo Linking $@
256
	@$(CC) -o $@ $^
257
258

# SMB Utility
259
$(SMBUTIL): $(EXEODIR)/smbutil.o $(SMBLIB) $(EXEODIR)/conwrap.o $(EXEODIR)/dirwrap.o \
260
261
	$(EXEODIR)/genwrap.o $(EXEODIR)/smbtxt.o $(EXEODIR)/crc32.o $(EXEODIR)/lzh.o \
	$(EXEODIR)/date_str.o $(EXEODIR)/str_util.o
262
	@echo Linking $@
263
	@$(CC) -o $@ $^
264

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

rswindell's avatar
rswindell committed
288
289
290
291
# SBBSecho Configuration Program
$(ECHOCFG): \
	$(EXEODIR)/echocfg.o \
	$(EXEODIR)/rechocfg.o \
292
	$(EXEODIR)/uifcx.o \
rswindell's avatar
rswindell committed
293
	$(EXEODIR)/nopen.o \
294
295
296
	$(EXEODIR)/str_util.o \
	$(EXEODIR)/filewrap.o \
	$(EXEODIR)/genwrap.o
rswindell's avatar
rswindell committed
297
298
299
	@echo Linking $@
	@$(CC) -o $@ $^

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

318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
# 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 $@ $^

336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
# 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 $@ $^


355
356
357
# Auto-dependency files
-include $(LIBODIR)/*.d
-include $(EXEODIR)/*.d