GNUmakefile 7.72 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
145
include targets.mk		# defines all targets
include objects.mk		# defines $(OBJS)
include headers.mk		# defines $(HEADERS)
include sbbsdefs.mk		# defines $(SBBSDEFS)
146
147

SBBSLIB	=	$(LIBODIR)/sbbs.a
148

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

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

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

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

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

$(EXEODIR):
	mkdir $(EXEODIR)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

337
338
339
# Auto-dependency files
-include $(LIBODIR)/*.d
-include $(EXEODIR)/*.d