GNUmakefile 5.62 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
61
CFLAGS	+= -D_THREAD_SAFE
# Math libraries needed and uses pthread
LFLAGS	:=	-lm -pthread
62
63
else			# Linux / Other UNIX
# Math and pthread libraries needed
64
ifdef bcc
65
LFLAGS	:=	libpthread.so
66
else
67
LFLAGS	:=	-lm -lpthread
rswindell's avatar
rswindell committed
68
endif
69
endif
70
71

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

SBBSLIB	=	$(LIBODIR)/sbbs.a
101

rswindell's avatar
rswindell committed
102
vpath %.c $(XPDEV) $(UIFC)
rswindell's avatar
rswindell committed
103

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

# Implicit C Compile Rule for SBBS
$(LIBODIR)/%.o : %.c
113
ifndef bcc
114
	@echo Compiling $<
115
116
endif
	@$(CC) $(CFLAGS) $(SBBSDEFS) -o $@ -c $<
117
118
119

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

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

$(EXEODIR):
	mkdir $(EXEODIR)

CON_OBJS	= $(EXEODIR)/sbbscon.o $(EXEODIR)/conwrap.o
FTP_OBJS	= $(LIBODIR)/ftpsrvr.o
MAIL_OBJS	= $(LIBODIR)/mailsrvr.o $(LIBODIR)/mxlookup.o $(LIBODIR)/mime.o 
SERVICE_OBJS= $(LIBODIR)/services.o

137
MONO_OBJS	= $(CON_OBJS) $(FTP_OBJS) $(MAIL_OBJS) $(SERVICE_OBJS)
138
139

# Monolithic Synchronet executable Build Rule
140
$(SBBSMONO): $(MONO_OBJS) $(OBJS) $(LIBS) $(LIBODIR)/ver.o 
141
	@echo Linking $@
142
	@$(CC) -o $@ $(LFLAGS) $^
143
144

# Synchronet BBS library Link Rule
145
$(SBBS): $(OBJS) $(LIBS) $(LIBODIR)/ver.o
146
147
148
	$(LD) $(LFLAGS) -S -o $(SBBS) $^ $(LIBS) -o $@

# FTP Server Link Rule
149
$(FTPSRVR): $(LIBODIR)/ftpsrvr.o $(SBBSLIB)
150
151
152
	$(LD) $(LFLAGS) -S $^ $(LIBS) -o $@ 

# Mail Server Link Rule
153
$(MAILSRVR): $(MAIL_OBJS) $(SBBSLIB)
154
155
156
	$(LD) $(LFLAGS) -S $^ $(LIBS) -o $@

# Synchronet Console Build Rule
157
$(SBBSCON): $(CON_OBJS) $(SBBSLIB)
158
159
160
161
162
	$(CC) $(CFLAGS) -o $@ $^

# Specifc Compile Rules
$(LIBODIR)/ftpsrvr.o: ftpsrvr.c ftpsrvr.h
	@echo Compiling $<
163
	@$(CC) $(CFLAGS) -DFTPSRVR_EXPORTS -o $@ -c $<
164
165
166

$(LIBODIR)/mailsrvr.o: mailsrvr.c mailsrvr.h
	@echo Compiling $<
167
	@$(CC) $(CFLAGS) -DMAILSRVR_EXPORTS -o $@ -c $<
168
169
170

$(LIBODIR)/mxlookup.o: mxlookup.c
	@echo Compiling $<
171
	@$(CC) $(CFLAGS) -DMAILSRVR_EXPORTS -o $@ -c $<
172
173
174

$(LIBODIR)/mime.o: mime.c
	@echo Compiling $<
175
	@$(CC) $(CFLAGS) -DMAILSRVR_EXPORTS -o $@ -c $<		
176
177
178

$(LIBODIR)/services.o: services.c services.h
	@echo Compiling $<
179
	@$(CC) $(CFLAGS) -DSERVICES_EXPORTS -o $@ -c $<
180
181

# Baja Utility
182
183
$(BAJA): $(EXEODIR)/baja.o $(EXEODIR)/ars.o $(EXEODIR)/crc32.o \
	$(EXEODIR)/genwrap.o $(EXEODIR)/filewrap.o
184
	@echo Linking $@
185
	@$(CC) -o $@ $^
186
187

# Node Utility
rswindell's avatar
rswindell committed
188
$(NODE): $(EXEODIR)/node.o $(EXEODIR)/genwrap.o $(EXEODIR)/filewrap.o
189
	@echo Linking $@
190
	@$(CC) -o $@ $^ 
191

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

194
# FIXSMB Utility
195
$(FIXSMB): $(EXEODIR)/fixsmb.o $(SMBLIB) $(EXEODIR)/genwrap.o
196
	@echo Linking $@
197
	@$(CC) -o $@ $^
198
199

# CHKSMB Utility
200
$(CHKSMB): $(EXEODIR)/chksmb.o $(SMBLIB) $(EXEODIR)/conwrap.o $(EXEODIR)/dirwrap.o
201
	@echo Linking $@
202
	@$(CC) -o $@ $^
203
204

# SMB Utility
205
$(SMBUTIL): $(EXEODIR)/smbutil.o $(SMBLIB) $(EXEODIR)/conwrap.o $(EXEODIR)/dirwrap.o \
206
	$(EXEODIR)/genwrap.o $(EXEODIR)/smbtxt.o $(EXEODIR)/crc32.o $(EXEODIR)/lzh.o 
207
	@echo Linking $@
208
	@$(CC) -o $@ $^
209

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

rswindell's avatar
rswindell committed
232
233
234
235
# SBBSecho Configuration Program
$(ECHOCFG): \
	$(EXEODIR)/echocfg.o \
	$(EXEODIR)/rechocfg.o \
236
	$(EXEODIR)/uifcx.o \
rswindell's avatar
rswindell committed
237
	$(EXEODIR)/nopen.o \
238
239
240
	$(EXEODIR)/str_util.o \
	$(EXEODIR)/filewrap.o \
	$(EXEODIR)/genwrap.o
rswindell's avatar
rswindell committed
241
242
243
	@echo Linking $@
	@$(CC) -o $@ $^

rswindell's avatar
rswindell committed
244
include depends.mk