GNUmakefile 4.25 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
9
# Linux: gmake															#
# FreeBSD: gmake os=freebsd												#
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#																		#
# 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
EXEFILE	=	

ifeq ($(os),freebsd)	# FreeBSD
LIBODIR	:=	gcc.freebsd.lib
EXEODIR	:=	gcc.freebsd.exe
else                    # Linux
LIBODIR	:=	gcc.linux.lib
EXEODIR	:=	gcc.linux.exe
endif

DELETE	=	rm -fv

CFLAGS	=	-DJAVASCRIPT -I../mozilla/js/src

ifeq ($(os),freebsd)	# FreeBSD
rswindell's avatar
rswindell committed
39
40
41
CFLAGS	+= -D_THREAD_SAFE
# Math libraries needed and uses pthread
LFLAGS	:=	-lm -pthread
42
43
44
else			# Linux / Other UNIX
# Math and pthread libraries needed
LFLAGS	:=	-lm -lpthread
rswindell's avatar
rswindell committed
45
46
endif

47
48
49

ifdef DEBUG
CFLAGS	+=	-g -O0 -D_DEBUG 
50
51
LIBODIR	:=	$(LIBODIR).debug
EXEODIR	:=	$(EXEODIR).debug
52
53
54
55
56
57
ifeq ($(os),freebsd)	# FreeBSD
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
58
59
LIBODIR	:=	$(LIBODIR).release
EXEODIR	:=	$(EXEODIR).release
60
61
62
63
64
65
66
67
68
69
70
71
72
ifeq ($(os),freebsd)	# FreeBSD
LIBS	+=	../mozilla/js/src/FreeBSD4.3-RELEASE_OPT.OBJ/libjs.a
else
LIBS	+=	../mozilla/js/src/Linux_All_OPT.OBJ/libjs.a
endif
endif

include targets.mak		# defines all targets
include objects.mak		# defines $(OBJS)
include headers.mak		# defines $(HEADERS)
include sbbsdefs.mak	# defines $(SBBSDEFS)

SBBSLIB	=	$(LIBODIR)/sbbs.a
73
74
75
76
77

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

# 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

101
MONO_OBJS	= $(CON_OBJS) $(FTP_OBJS) $(MAIL_OBJS) $(SERVICE_OBJS)
102
103

# Monolithic Synchronet executable Build Rule
104
$(SBBSMONO): $(MONO_OBJS) $(OBJS) $(LIBS) $(LIBODIR)/ver.o 
105
106
107
108
	@echo Linking $@
	@$(CC) $(LFLAGS) $^ -o $@

# Synchronet BBS library Link Rule
109
$(SBBS): $(OBJS) $(LIBS) $(LIBODIR)/ver.o
110
111
112
	$(LD) $(LFLAGS) -S -o $(SBBS) $^ $(LIBS) -o $@

# FTP Server Link Rule
113
$(FTPSRVR): $(LIBODIR)/ftpsrvr.o $(SBBSLIB)
114
115
116
	$(LD) $(LFLAGS) -S $^ $(LIBS) -o $@ 

# Mail Server Link Rule
117
$(MAILSRVR): $(MAIL_OBJS) $(SBBSLIB)
118
119
120
	$(LD) $(LFLAGS) -S $^ $(LIBS) -o $@

# Synchronet Console Build Rule
121
$(SBBSCON): $(CON_OBJS) $(SBBSLIB)
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
	$(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
$(BAJA): $(EXEODIR)/baja.o $(EXEODIR)/ars.o $(EXEODIR)/smbwrap.o $(EXEODIR)/crc32.o
	@echo Linking $@
	@$(CC) $^ -o $@

# Node Utility
$(NODE): $(EXEODIR)/node.o $(EXEODIR)/smbwrap.o
	@echo Linking $@
	@$(CC) $^ -o $@ 

# FIXSMB Utility
$(FIXSMB): $(EXEODIR)/fixsmb.o $(EXEODIR)/smblib.o $(EXEODIR)/smbwrap.o
	@echo Linking $@
	@$(CC) $^ -o $@

# CHKSMB Utility
$(CHKSMB): $(EXEODIR)/chksmb.o $(EXEODIR)/smblib.o $(EXEODIR)/smbwrap.o $(EXEODIR)/conwrap.o
	@echo Linking $@
	@$(CC) $^ -o $@

# SMB Utility
$(SMBUTIL): $(EXEODIR)/smbutil.o $(EXEODIR)/smblib.o $(EXEODIR)/smbwrap.o $(EXEODIR)/conwrap.o $(EXEODIR)/smbtxt.o $(EXEODIR)/crc32.o $(EXEODIR)/lzh.o 
	@echo Linking $@
	@$(CC) $^ -o $@

include depends.mak