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

LIBFILE	=	.a
31
XPDEV	=	../xpdev/
32

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

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

DELETE	=	rm -fv

55
CFLAGS	+=	-DJAVASCRIPT -I../mozilla/js/src -I$(XPDEV)
56

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

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

SBBSLIB	=	$(LIBODIR)/sbbs.a
100

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

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

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

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

# 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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

rswindell's avatar
rswindell committed
231
include depends.mk