GNUmakefile 7.33 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
os      :=	$(shell echo $(os) | awk '/.*/ { print tolower($$1)}')
48

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

57
58
59
LIBODIR :=	$(CCPRE).$(os).lib
EXEODIR :=	$(CCPRE).$(os).exe

60
DELETE	=	rm -f -v
61

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

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

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

81
ifdef DEBUG
82
83
84
85
86
87
88
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
    else
     $(warning JavaScript library path for '$(os)' not defined.)
    endif
   endif
  endif
 endif

109
else # RELEASE
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
 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
129
130
endif

rswindell's avatar
rswindell committed
131
132
133
134
include targets.mk		# defines all targets
include objects.mk		# defines $(OBJS)
include headers.mk		# defines $(HEADERS)
include sbbsdefs.mk		# defines $(SBBSDEFS)
135
136

SBBSLIB	=	$(LIBODIR)/sbbs.a
137

rswindell's avatar
rswindell committed
138
vpath %.c $(XPDEV) $(UIFC)
rswindell's avatar
rswindell committed
139

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

# Implicit C Compile Rule for SBBS
$(LIBODIR)/%.o : %.c
149
   ifndef bcc
150
	@echo Compiling $<
151
   endif
152
	@$(CC) $(CFLAGS) $(SBBSDEFS) -o $@ -c $<
153
154
155

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

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

$(EXEODIR):
	mkdir $(EXEODIR)

168
169
CON_OBJS	= $(EXEODIR)/sbbscon.o $(EXEODIR)/conwrap.o \
		  $(EXEODIR)/ini_file.o $(EXEODIR)/sbbs_ini.o
170
FTP_OBJS	= $(LIBODIR)/ftpsrvr.o
171
MAIL_OBJS	= $(LIBODIR)/mailsrvr.o $(LIBODIR)/mxlookup.o \
rswindell's avatar
rswindell committed
172
173
 		  $(LIBODIR)/mime.o
WEB_OBJS	= $(LIBODIR)/websrvr.o $(LIBODIR)/sockwrap.o
174
175
SERVICE_OBJS= $(LIBODIR)/services.o

rswindell's avatar
rswindell committed
176
177
MONO_OBJS	= $(CON_OBJS) $(FTP_OBJS) $(WEB_OBJS) \
			$(MAIL_OBJS) $(SERVICE_OBJS)
178
179

# Monolithic Synchronet executable Build Rule
180
$(SBBSMONO): $(MONO_OBJS) $(OBJS) $(LIBS) $(LIBODIR)/ver.o 
181
	@echo Linking $@
182
	@$(CCPP) -o $@ $(LFLAGS) $^
183
184

# Synchronet BBS library Link Rule
185
$(SBBS): $(OBJS) $(LIBS) $(LIBODIR)/ver.o
186
187
188
	$(LD) $(LFLAGS) -S -o $(SBBS) $^ $(LIBS) -o $@

# FTP Server Link Rule
189
$(FTPSRVR): $(LIBODIR)/ftpsrvr.o $(SBBSLIB)
190
191
192
	$(LD) $(LFLAGS) -S $^ $(LIBS) -o $@ 

# Mail Server Link Rule
193
$(MAILSRVR): $(MAIL_OBJS) $(SBBSLIB)
194
195
196
	$(LD) $(LFLAGS) -S $^ $(LIBS) -o $@

# Synchronet Console Build Rule
197
$(SBBSCON): $(CON_OBJS) $(SBBSLIB)
198
	@$(CC) $(CFLAGS) -o $@ $^
199
200
201
202

# Specifc Compile Rules
$(LIBODIR)/ftpsrvr.o: ftpsrvr.c ftpsrvr.h
	@echo Compiling $<
203
	@$(CC) $(CFLAGS) -DFTPSRVR_EXPORTS -o $@ -c $<
204
205
206

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

$(LIBODIR)/mxlookup.o: mxlookup.c
	@echo Compiling $<
211
	@$(CC) $(CFLAGS) -DMAILSRVR_EXPORTS -o $@ -c $<
212
213
214

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

rswindell's avatar
rswindell committed
217
218
219
220
$(LIBODIR)/websrvr.o: websrvr.c websrvr.h
	@echo Compiling $<
	@$(CC) $(CFLAGS) -DWEBSRVR_EXPORTS -o $@ -c $<

221
222
$(LIBODIR)/services.o: services.c services.h
	@echo Compiling $<
223
	@$(CC) $(CFLAGS) -DSERVICES_EXPORTS -o $@ -c $<
224
225

# Baja Utility
226
227
$(BAJA): $(EXEODIR)/baja.o $(EXEODIR)/ars.o $(EXEODIR)/crc32.o \
	$(EXEODIR)/genwrap.o $(EXEODIR)/filewrap.o
228
	@echo Linking $@
229
	@$(CC) -o $@ $^
230
231

# Node Utility
rswindell's avatar
rswindell committed
232
$(NODE): $(EXEODIR)/node.o $(EXEODIR)/genwrap.o $(EXEODIR)/filewrap.o
233
	@echo Linking $@
234
	@$(CC) -o $@ $^ 
235

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

238
# FIXSMB Utility
239
$(FIXSMB): $(EXEODIR)/fixsmb.o $(SMBLIB) $(EXEODIR)/genwrap.o
240
	@echo Linking $@
241
	@$(CC) -o $@ $^
242
243

# CHKSMB Utility
rob's avatar
rob committed
244
$(CHKSMB): $(EXEODIR)/chksmb.o $(SMBLIB) $(EXEODIR)/conwrap.o $(EXEODIR)/dirwrap.o $(EXEODIR)/genwrap.o
245
	@echo Linking $@
246
	@$(CC) -o $@ $^
247
248

# SMB Utility
249
$(SMBUTIL): $(EXEODIR)/smbutil.o $(SMBLIB) $(EXEODIR)/conwrap.o $(EXEODIR)/dirwrap.o \
250
251
	$(EXEODIR)/genwrap.o $(EXEODIR)/smbtxt.o $(EXEODIR)/crc32.o $(EXEODIR)/lzh.o \
	$(EXEODIR)/date_str.o $(EXEODIR)/str_util.o
252
	@echo Linking $@
253
	@$(CC) -o $@ $^
254

rswindell's avatar
rswindell committed
255
256
257
258
259
260
261
262
263
# 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 \
264
265
	$(EXEODIR)/nopen.o \
	$(EXEODIR)/str_util.o \
266
	$(EXEODIR)/dat_rec.o \
rswindell's avatar
rswindell committed
267
268
	$(EXEODIR)/userdat.o \
	$(EXEODIR)/rechocfg.o \
269
	$(EXEODIR)/conwrap.o \
rswindell's avatar
rswindell committed
270
271
272
273
	$(EXEODIR)/dirwrap.o \
	$(EXEODIR)/genwrap.o \
	$(SMBLIB) \
	$(EXEODIR)/smbtxt.o \
274
	$(EXEODIR)/lzh.o
rswindell's avatar
rswindell committed
275
	@echo Linking $@
276
	@$(CC) -o $@ $^
rswindell's avatar
rswindell committed
277

rswindell's avatar
rswindell committed
278
279
280
281
# SBBSecho Configuration Program
$(ECHOCFG): \
	$(EXEODIR)/echocfg.o \
	$(EXEODIR)/rechocfg.o \
282
	$(EXEODIR)/uifcx.o \
rswindell's avatar
rswindell committed
283
	$(EXEODIR)/nopen.o \
284
285
286
	$(EXEODIR)/str_util.o \
	$(EXEODIR)/filewrap.o \
	$(EXEODIR)/genwrap.o
rswindell's avatar
rswindell committed
287
288
289
	@echo Linking $@
	@$(CC) -o $@ $^

rswindell's avatar
rswindell committed
290
291
292
293
294
295
296
297
298
299
# 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 \
300
	$(EXEODIR)/dat_rec.o \
rswindell's avatar
rswindell committed
301
302
303
304
305
306
307
	$(EXEODIR)/filedat.o \
	$(EXEODIR)/filewrap.o \
	$(EXEODIR)/dirwrap.o \
	$(EXEODIR)/genwrap.o
	@echo Linking $@
	@$(CC) -o $@ $^

308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
# 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 $@ $^

326
327
328
# Auto-dependency files
-include $(LIBODIR)/*.d
-include $(EXEODIR)/*.d