GNUmakefile 4.48 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															#
9
# FreeBSD: gmake os=FreeBSD												#
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#																		#
# Optional build targets: dlls, utils, mono, all (default)				#
#########################################################################

# $Id$

# Macros
DEBUG	=	1		# Comment out for release (non-debug) version
CC		=	gcc
SLASH	=	/
OFILE	=	o

LD		=	ld
LIBFILE	=	.a
24
XPDEV	=	../xpdev/
25

26
27
28
29
30
31
ifndef $(os)
os		=	$(shell uname)
$(warning OS not specified on command line, setting to '$(os)'.)
endif

ifeq ($(os),FreeBSD)	# FreeBSD
32
33
34
35
36
37
38
39
40
LIBODIR	:=	gcc.freebsd.lib
EXEODIR	:=	gcc.freebsd.exe
else                    # Linux
LIBODIR	:=	gcc.linux.lib
EXEODIR	:=	gcc.linux.exe
endif

DELETE	=	rm -fv

41
CFLAGS	=	-Wall -DJAVASCRIPT -I../mozilla/js/src -I$(XPDEV)
42

43
ifeq ($(os),FreeBSD)	# FreeBSD
rswindell's avatar
rswindell committed
44
45
46
CFLAGS	+= -D_THREAD_SAFE
# Math libraries needed and uses pthread
LFLAGS	:=	-lm -pthread
47
48
49
else			# Linux / Other UNIX
# Math and pthread libraries needed
LFLAGS	:=	-lm -lpthread
rswindell's avatar
rswindell committed
50
51
endif

52
53
54

ifdef DEBUG
CFLAGS	+=	-g -O0 -D_DEBUG 
55
56
LIBODIR	:=	$(LIBODIR).debug
EXEODIR	:=	$(EXEODIR).debug
57
ifeq ($(os),FreeBSD)	# FreeBSD
58
59
60
61
62
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
63
64
LIBODIR	:=	$(LIBODIR).release
EXEODIR	:=	$(EXEODIR).release
65
ifeq ($(os),FreeBSD)	# FreeBSD
66
67
68
69
70
71
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
72
73
74
75
include targets.mk		# defines all targets
include objects.mk		# defines $(OBJS)
include headers.mk		# defines $(HEADERS)
include sbbsdefs.mk		# defines $(SBBSDEFS)
76
77

SBBSLIB	=	$(LIBODIR)/sbbs.a
78

rswindell's avatar
rswindell committed
79
80
vpath %.c $(XPDEV)

81
82
83
84
# Implicit C Compile Rule for utils
$(EXEODIR)/%.o : %.c
	@echo Compiling $<
	@$(CC) $(CFLAGS) -c $< -o $@
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107

# Implicit C Compile Rule for SBBS
$(LIBODIR)/%.o : %.c
	@echo Compiling $<
	@$(CC) $(CFLAGS) -c $(SBBSDEFS) $< -o $@

# Implicit C++ Compile Rule for SBBS
$(LIBODIR)/%.o : %.cpp
	@echo Compiling $<
	@$(CC) $(CFLAGS) -c $(SBBSDEFS) $< -o $@

# 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

108
MONO_OBJS	= $(CON_OBJS) $(FTP_OBJS) $(MAIL_OBJS) $(SERVICE_OBJS)
109
110

# Monolithic Synchronet executable Build Rule
111
$(SBBSMONO): $(MONO_OBJS) $(OBJS) $(LIBS) $(LIBODIR)/ver.o 
112
113
114
115
	@echo Linking $@
	@$(CC) $(LFLAGS) $^ -o $@

# Synchronet BBS library Link Rule
116
$(SBBS): $(OBJS) $(LIBS) $(LIBODIR)/ver.o
117
118
119
	$(LD) $(LFLAGS) -S -o $(SBBS) $^ $(LIBS) -o $@

# FTP Server Link Rule
120
$(FTPSRVR): $(LIBODIR)/ftpsrvr.o $(SBBSLIB)
121
122
123
	$(LD) $(LFLAGS) -S $^ $(LIBS) -o $@ 

# Mail Server Link Rule
124
$(MAILSRVR): $(MAIL_OBJS) $(SBBSLIB)
125
126
127
	$(LD) $(LFLAGS) -S $^ $(LIBS) -o $@

# Synchronet Console Build Rule
128
$(SBBSCON): $(CON_OBJS) $(SBBSLIB)
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
	$(CC) $(CFLAGS) -o $@ $^

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

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

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

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

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

# Baja Utility
153
154
$(BAJA): $(EXEODIR)/baja.o $(EXEODIR)/ars.o $(EXEODIR)/crc32.o \
	$(EXEODIR)/genwrap.o $(EXEODIR)/filewrap.o
155
156
157
158
	@echo Linking $@
	@$(CC) $^ -o $@

# Node Utility
rswindell's avatar
rswindell committed
159
$(NODE): $(EXEODIR)/node.o $(EXEODIR)/genwrap.o $(EXEODIR)/filewrap.o
160
161
162
	@echo Linking $@
	@$(CC) $^ -o $@ 

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

165
# FIXSMB Utility
166
$(FIXSMB): $(EXEODIR)/fixsmb.o $(SMBLIB) $(EXEODIR)/genwrap.o
167
168
169
170
	@echo Linking $@
	@$(CC) $^ -o $@

# CHKSMB Utility
171
$(CHKSMB): $(EXEODIR)/chksmb.o $(SMBLIB) $(EXEODIR)/conwrap.o $(EXEODIR)/dirwrap.o
172
173
174
175
	@echo Linking $@
	@$(CC) $^ -o $@

# SMB Utility
176
$(SMBUTIL): $(EXEODIR)/smbutil.o $(SMBLIB) $(EXEODIR)/conwrap.o $(EXEODIR)/dirwrap.o \
177
	$(EXEODIR)/genwrap.o $(EXEODIR)/smbtxt.o $(EXEODIR)/crc32.o $(EXEODIR)/lzh.o 
178
179
180
	@echo Linking $@
	@$(CC) $^ -o $@

rswindell's avatar
rswindell committed
181
include depends.mk