GNUmakefile 5.78 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
20
ifdef bcc
CC		=	bc++ -q
LD		=	ilink -q
21
CFLAGS 	=	-D__unix__ -w-csu -w-pch -w-ccc -w-rch -w-par -w-aus
22
else
23
CC		=	gcc
24
LD		=	ld
25
CFLAGS	=	-Wall
26
endif
27
28
29
30
SLASH	=	/
OFILE	=	o

LIBFILE	=	.a
rswindell's avatar
rswindell committed
31
UIFC	=	../uifc/
32
XPDEV	=	../xpdev/
33

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

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

DELETE	=	rm -fv

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

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

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

75
ifdef DEBUG
76
ifdef bcc
77
CFLAGS	+=	-y -v -Od
78
79
80
81
else
CFLAGS	+=	-g
endif
CFLAGS  +=	-D_DEBUG
82
83
LIBODIR	:=	$(LIBODIR).debug
EXEODIR	:=	$(EXEODIR).debug
84
ifeq ($(os),FreeBSD)	# FreeBSD
85
86
87
88
89
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
90
91
LIBODIR	:=	$(LIBODIR).release
EXEODIR	:=	$(EXEODIR).release
92
ifeq ($(os),FreeBSD)	# FreeBSD
93
94
95
96
97
98
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
99
100
101
102
include targets.mk		# defines all targets
include objects.mk		# defines $(OBJS)
include headers.mk		# defines $(HEADERS)
include sbbsdefs.mk		# defines $(SBBSDEFS)
103
104

SBBSLIB	=	$(LIBODIR)/sbbs.a
105

rswindell's avatar
rswindell committed
106
vpath %.c $(XPDEV) $(UIFC)
rswindell's avatar
rswindell committed
107

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

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

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

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

$(EXEODIR):
	mkdir $(EXEODIR)

136
137
CON_OBJS	= $(EXEODIR)/sbbscon.o $(EXEODIR)/conwrap.o \
		  $(EXEODIR)/ini_file.o $(EXEODIR)/sbbs_ini.o
138
FTP_OBJS	= $(LIBODIR)/ftpsrvr.o
139
140
MAIL_OBJS	= $(LIBODIR)/mailsrvr.o $(LIBODIR)/mxlookup.o \
 		  $(LIBODIR)/mime.o 
141
142
SERVICE_OBJS= $(LIBODIR)/services.o

143
MONO_OBJS	= $(CON_OBJS) $(FTP_OBJS) $(MAIL_OBJS) $(SERVICE_OBJS)
144
145

# Monolithic Synchronet executable Build Rule
146
$(SBBSMONO): $(MONO_OBJS) $(OBJS) $(LIBS) $(LIBODIR)/ver.o 
147
	@echo Linking $@
148
	@$(CC) -o $@ $(LFLAGS) $^
149
150

# Synchronet BBS library Link Rule
151
$(SBBS): $(OBJS) $(LIBS) $(LIBODIR)/ver.o
152
153
154
	$(LD) $(LFLAGS) -S -o $(SBBS) $^ $(LIBS) -o $@

# FTP Server Link Rule
155
$(FTPSRVR): $(LIBODIR)/ftpsrvr.o $(SBBSLIB)
156
157
158
	$(LD) $(LFLAGS) -S $^ $(LIBS) -o $@ 

# Mail Server Link Rule
159
$(MAILSRVR): $(MAIL_OBJS) $(SBBSLIB)
160
161
162
	$(LD) $(LFLAGS) -S $^ $(LIBS) -o $@

# Synchronet Console Build Rule
163
$(SBBSCON): $(CON_OBJS) $(SBBSLIB)
164
165
166
167
168
	$(CC) $(CFLAGS) -o $@ $^

# Specifc Compile Rules
$(LIBODIR)/ftpsrvr.o: ftpsrvr.c ftpsrvr.h
	@echo Compiling $<
169
	@$(CC) $(CFLAGS) -DFTPSRVR_EXPORTS -o $@ -c $<
170
171
172

$(LIBODIR)/mailsrvr.o: mailsrvr.c mailsrvr.h
	@echo Compiling $<
173
	@$(CC) $(CFLAGS) -DMAILSRVR_EXPORTS -o $@ -c $<
174
175
176

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

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

$(LIBODIR)/services.o: services.c services.h
	@echo Compiling $<
185
	@$(CC) $(CFLAGS) -DSERVICES_EXPORTS -o $@ -c $<
186
187

# Baja Utility
188
189
$(BAJA): $(EXEODIR)/baja.o $(EXEODIR)/ars.o $(EXEODIR)/crc32.o \
	$(EXEODIR)/genwrap.o $(EXEODIR)/filewrap.o
190
	@echo Linking $@
191
	@$(CC) -o $@ $^
192
193

# Node Utility
rswindell's avatar
rswindell committed
194
$(NODE): $(EXEODIR)/node.o $(EXEODIR)/genwrap.o $(EXEODIR)/filewrap.o
195
	@echo Linking $@
196
	@$(CC) -o $@ $^ 
197

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

200
# FIXSMB Utility
201
$(FIXSMB): $(EXEODIR)/fixsmb.o $(SMBLIB) $(EXEODIR)/genwrap.o
202
	@echo Linking $@
203
	@$(CC) -o $@ $^
204
205

# CHKSMB Utility
rob's avatar
rob committed
206
$(CHKSMB): $(EXEODIR)/chksmb.o $(SMBLIB) $(EXEODIR)/conwrap.o $(EXEODIR)/dirwrap.o $(EXEODIR)/genwrap.o
207
	@echo Linking $@
208
	@$(CC) -o $@ $^
209
210

# SMB Utility
211
$(SMBUTIL): $(EXEODIR)/smbutil.o $(SMBLIB) $(EXEODIR)/conwrap.o $(EXEODIR)/dirwrap.o \
212
	$(EXEODIR)/genwrap.o $(EXEODIR)/smbtxt.o $(EXEODIR)/crc32.o $(EXEODIR)/lzh.o 
213
	@echo Linking $@
214
	@$(CC) -o $@ $^
215

rswindell's avatar
rswindell committed
216
217
218
219
220
221
222
223
224
# 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 \
225
226
	$(EXEODIR)/nopen.o \
	$(EXEODIR)/str_util.o \
rswindell's avatar
rswindell committed
227
228
	$(EXEODIR)/userdat.o \
	$(EXEODIR)/rechocfg.o \
229
	$(EXEODIR)/conwrap.o \
rswindell's avatar
rswindell committed
230
231
232
233
	$(EXEODIR)/dirwrap.o \
	$(EXEODIR)/genwrap.o \
	$(SMBLIB) \
	$(EXEODIR)/smbtxt.o \
234
	$(EXEODIR)/lzh.o
rswindell's avatar
rswindell committed
235
	@echo Linking $@
236
	@$(CC) -o $@ $^
rswindell's avatar
rswindell committed
237

rswindell's avatar
rswindell committed
238
239
240
241
# SBBSecho Configuration Program
$(ECHOCFG): \
	$(EXEODIR)/echocfg.o \
	$(EXEODIR)/rechocfg.o \
242
	$(EXEODIR)/uifcx.o \
rswindell's avatar
rswindell committed
243
	$(EXEODIR)/nopen.o \
244
245
246
	$(EXEODIR)/str_util.o \
	$(EXEODIR)/filewrap.o \
	$(EXEODIR)/genwrap.o
rswindell's avatar
rswindell committed
247
248
249
	@echo Linking $@
	@$(CC) -o $@ $^

rswindell's avatar
rswindell committed
250
include depends.mk