GNUmakefile 6.42 KB
Newer Older
1
# GNUmakefile
2
3
4
5
6
7

#########################################################################
# Makefile for Synchronet BBS 											#
# For use with GNU make and GNU C Compiler								#
# @format.tab-size 4, @format.use-tabs true								#
#																		#
8
# Linux: gmake [bcc=1]													#
9
# FreeBSD: gmake os=FreeBSD												#
10
11
12
13
14
15
16
17
#																		#
# Optional build targets: dlls, utils, mono, all (default)				#
#########################################################################

# $Id$

# Macros
DEBUG	=	1		# Comment out for release (non-debug) version
18
19
ifdef bcc
CC		=	bc++ -q
20
CCPP	=	bc++ -q
21
LD		=	ilink -q
22
CFLAGS 	=	-D__unix__ -w-csu -w-pch -w-ccc -w-rch -w-par -w-aus
23
else
24
CC		=	gcc
25
CCPP	=	g++
26
LD		=	ld
27
CFLAGS	=	-Wall
28
endif
29
30
31
32
SLASH	=	/
OFILE	=	o

LIBFILE	=	.a
rswindell's avatar
rswindell committed
33
UIFC	=	../uifc/
34
XPDEV	=	../xpdev/
35

36
37
38
39
40
41
ifndef $(os)
os		=	$(shell uname)
$(warning OS not specified on command line, setting to '$(os)'.)
endif

ifeq ($(os),FreeBSD)	# FreeBSD
42
43
44
LIBODIR	:=	gcc.freebsd.lib
EXEODIR	:=	gcc.freebsd.exe
else                    # Linux
45
46
47
48
ifdef bcc
LIBODIR	:=	bcc.linux.lib
EXEODIR	:=	bcc.linux.exe
else
49
# -O doesn't work on FreeBSD (possible conflict with -g)
50
# CFLAGS	+=	-O
51
52
53
LIBODIR	:=	gcc.linux.lib
EXEODIR	:=	gcc.linux.exe
endif
54
endif
55
56
57

DELETE	=	rm -fv

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

60
ifeq ($(os),FreeBSD)	# FreeBSD
rswindell's avatar
rswindell committed
61
62
CFLAGS	+= -D_THREAD_SAFE
# Math libraries needed and uses pthread
63
LFLAGS	:=	-lm -pthread -lutil
64
65
else			# Linux / Other UNIX
# Math and pthread libraries needed
66
ifdef bcc
67
LFLAGS	:=	libpthread.so
68
else
69
LFLAGS	:=	-lm -lpthread -lutil
rswindell's avatar
rswindell committed
70
endif
71
endif
72

73
74
75
76
ifeq ($(os),Linux)    # Linux
CFLAGS	+= -D_THREAD_SUID_BROKEN
endif

77
ifdef DEBUG
78
ifdef bcc
79
CFLAGS	+=	-y -v -Od
80
81
82
83
else
CFLAGS	+=	-g
endif
CFLAGS  +=	-D_DEBUG
84
85
LIBODIR	:=	$(LIBODIR).debug
EXEODIR	:=	$(EXEODIR).debug
86
ifeq ($(os),FreeBSD)	# FreeBSD
87
88
89
90
91
LIBS	+=	../mozilla/js/src/FreeBSD4.3-RELEASE_DBG.OBJ/libjs.a
else			# Linux
LIBS	+=	../mozilla/js/src/Linux_All_DBG.OBJ/libjs.a
endif
else # RELEASE
92
93
LIBODIR	:=	$(LIBODIR).release
EXEODIR	:=	$(EXEODIR).release
94
ifeq ($(os),FreeBSD)	# FreeBSD
95
96
97
98
99
100
LIBS	+=	../mozilla/js/src/FreeBSD4.3-RELEASE_OPT.OBJ/libjs.a
else
LIBS	+=	../mozilla/js/src/Linux_All_OPT.OBJ/libjs.a
endif
endif

rswindell's avatar
rswindell committed
101
102
103
104
include targets.mk		# defines all targets
include objects.mk		# defines $(OBJS)
include headers.mk		# defines $(HEADERS)
include sbbsdefs.mk		# defines $(SBBSDEFS)
105
106

SBBSLIB	=	$(LIBODIR)/sbbs.a
107

rswindell's avatar
rswindell committed
108
vpath %.c $(XPDEV) $(UIFC)
rswindell's avatar
rswindell committed
109

110
111
# Implicit C Compile Rule for utils
$(EXEODIR)/%.o : %.c
112
ifndef bcc
113
	@echo Compiling $<
114
115
endif
	@$(CC) $(CFLAGS) -o $@ -c $<
116
117
118

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

# Implicit C++ Compile Rule for SBBS
$(LIBODIR)/%.o : %.cpp
126
ifndef bcc
127
	@echo Compiling $<
128
endif
129
	@$(CCPP) $(CFLAGS) $(SBBSDEFS) -o $@ -c $<
130
131
132
133
134
135
136
137

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

$(EXEODIR):
	mkdir $(EXEODIR)

138
139
CON_OBJS	= $(EXEODIR)/sbbscon.o $(EXEODIR)/conwrap.o \
		  $(EXEODIR)/ini_file.o $(EXEODIR)/sbbs_ini.o
140
FTP_OBJS	= $(LIBODIR)/ftpsrvr.o
141
MAIL_OBJS	= $(LIBODIR)/mailsrvr.o $(LIBODIR)/mxlookup.o \
rswindell's avatar
rswindell committed
142
143
 		  $(LIBODIR)/mime.o
WEB_OBJS	= $(LIBODIR)/websrvr.o $(LIBODIR)/sockwrap.o
144
145
SERVICE_OBJS= $(LIBODIR)/services.o

rswindell's avatar
rswindell committed
146
147
MONO_OBJS	= $(CON_OBJS) $(FTP_OBJS) $(WEB_OBJS) \
			$(MAIL_OBJS) $(SERVICE_OBJS)
148
149

# Monolithic Synchronet executable Build Rule
150
$(SBBSMONO): $(MONO_OBJS) $(OBJS) $(LIBS) $(LIBODIR)/ver.o 
151
	@echo Linking $@
152
	@$(CCPP) -o $@ $(LFLAGS) $^
153
154

# Synchronet BBS library Link Rule
155
$(SBBS): $(OBJS) $(LIBS) $(LIBODIR)/ver.o
156
157
158
	$(LD) $(LFLAGS) -S -o $(SBBS) $^ $(LIBS) -o $@

# FTP Server Link Rule
159
$(FTPSRVR): $(LIBODIR)/ftpsrvr.o $(SBBSLIB)
160
161
162
	$(LD) $(LFLAGS) -S $^ $(LIBS) -o $@ 

# Mail Server Link Rule
163
$(MAILSRVR): $(MAIL_OBJS) $(SBBSLIB)
164
165
166
	$(LD) $(LFLAGS) -S $^ $(LIBS) -o $@

# Synchronet Console Build Rule
167
$(SBBSCON): $(CON_OBJS) $(SBBSLIB)
168
169
170
171
172
	$(CC) $(CFLAGS) -o $@ $^

# Specifc Compile Rules
$(LIBODIR)/ftpsrvr.o: ftpsrvr.c ftpsrvr.h
	@echo Compiling $<
173
	@$(CC) $(CFLAGS) -DFTPSRVR_EXPORTS -o $@ -c $<
174
175
176

$(LIBODIR)/mailsrvr.o: mailsrvr.c mailsrvr.h
	@echo Compiling $<
177
	@$(CC) $(CFLAGS) -DMAILSRVR_EXPORTS -o $@ -c $<
178
179
180

$(LIBODIR)/mxlookup.o: mxlookup.c
	@echo Compiling $<
181
	@$(CC) $(CFLAGS) -DMAILSRVR_EXPORTS -o $@ -c $<
182
183
184

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

rswindell's avatar
rswindell committed
187
188
189
190
$(LIBODIR)/websrvr.o: websrvr.c websrvr.h
	@echo Compiling $<
	@$(CC) $(CFLAGS) -DWEBSRVR_EXPORTS -o $@ -c $<

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

# Baja Utility
196
197
$(BAJA): $(EXEODIR)/baja.o $(EXEODIR)/ars.o $(EXEODIR)/crc32.o \
	$(EXEODIR)/genwrap.o $(EXEODIR)/filewrap.o
198
	@echo Linking $@
199
	@$(CC) -o $@ $^
200
201

# Node Utility
rswindell's avatar
rswindell committed
202
$(NODE): $(EXEODIR)/node.o $(EXEODIR)/genwrap.o $(EXEODIR)/filewrap.o
203
	@echo Linking $@
204
	@$(CC) -o $@ $^ 
205

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

208
# FIXSMB Utility
209
$(FIXSMB): $(EXEODIR)/fixsmb.o $(SMBLIB) $(EXEODIR)/genwrap.o
210
	@echo Linking $@
211
	@$(CC) -o $@ $^
212
213

# CHKSMB Utility
rob's avatar
rob committed
214
$(CHKSMB): $(EXEODIR)/chksmb.o $(SMBLIB) $(EXEODIR)/conwrap.o $(EXEODIR)/dirwrap.o $(EXEODIR)/genwrap.o
215
	@echo Linking $@
216
	@$(CC) -o $@ $^
217
218

# SMB Utility
219
$(SMBUTIL): $(EXEODIR)/smbutil.o $(SMBLIB) $(EXEODIR)/conwrap.o $(EXEODIR)/dirwrap.o \
220
221
	$(EXEODIR)/genwrap.o $(EXEODIR)/smbtxt.o $(EXEODIR)/crc32.o $(EXEODIR)/lzh.o \
	$(EXEODIR)/date_str.o $(EXEODIR)/str_util.o
222
	@echo Linking $@
223
	@$(CC) -o $@ $^
224

rswindell's avatar
rswindell committed
225
226
227
228
229
230
231
232
233
# 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 \
234
235
	$(EXEODIR)/nopen.o \
	$(EXEODIR)/str_util.o \
236
	$(EXEODIR)/dat_rec.o \
rswindell's avatar
rswindell committed
237
238
	$(EXEODIR)/userdat.o \
	$(EXEODIR)/rechocfg.o \
239
	$(EXEODIR)/conwrap.o \
rswindell's avatar
rswindell committed
240
241
242
243
	$(EXEODIR)/dirwrap.o \
	$(EXEODIR)/genwrap.o \
	$(SMBLIB) \
	$(EXEODIR)/smbtxt.o \
244
	$(EXEODIR)/lzh.o
rswindell's avatar
rswindell committed
245
	@echo Linking $@
246
	@$(CC) -o $@ $^
rswindell's avatar
rswindell committed
247

rswindell's avatar
rswindell committed
248
249
250
251
# SBBSecho Configuration Program
$(ECHOCFG): \
	$(EXEODIR)/echocfg.o \
	$(EXEODIR)/rechocfg.o \
252
	$(EXEODIR)/uifcx.o \
rswindell's avatar
rswindell committed
253
	$(EXEODIR)/nopen.o \
254
255
256
	$(EXEODIR)/str_util.o \
	$(EXEODIR)/filewrap.o \
	$(EXEODIR)/genwrap.o
rswindell's avatar
rswindell committed
257
258
259
	@echo Linking $@
	@$(CC) -o $@ $^

rswindell's avatar
rswindell committed
260
261
262
263
264
265
266
267
268
269
# 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 \
270
	$(EXEODIR)/dat_rec.o \
rswindell's avatar
rswindell committed
271
272
273
274
275
276
277
	$(EXEODIR)/filedat.o \
	$(EXEODIR)/filewrap.o \
	$(EXEODIR)/dirwrap.o \
	$(EXEODIR)/genwrap.o
	@echo Linking $@
	@$(CC) -o $@ $^

rswindell's avatar
rswindell committed
278
include depends.mk