GNUmakefile 10.8 KB
Newer Older
1
# $Id: GNUmakefile,v 1.79 2020/05/07 22:17:44 rswindell Exp $
2 3 4 5
# Global GNU makefile for Synchronet
#
# Usage:
# ------
6
# [g]make install [variable=value]...
7 8 9 10 11 12
#
# variables:
# ----------
# DEBUG = Set to force a debug build
# RELEASE = Set to force a release build
# SYMLINK = Don't copy binaries, rather create symlinks in $(SBBSDIR)/exec
Rob Swindell's avatar
Rob Swindell committed
13
# SBBSDIR = Directory to do install to
14
# REPODIR = Directory where source files are cloned
15
# SETCAP = First portion of set file capabilities (setcap) command-line (e.g. /sbin/setcap)
16
# NOCAP = Set to defeat sbbs3 bind-capabilities (setcap) build target on Linux
17 18
# bcc = Set to use Borland compiler
# os = Set to the OS name (Not required)
19
# SBBSUSER = Owner for the installed files
20
# SBBSGROUP = Group for the installed files
deuce's avatar
deuce committed
21 22
# JSLIB = Library name of JavaScript library.
# JSLIBDIR = Full path to JavaScript library
23 24 25 26 27
# CRYPTLIBINCLUDE = Path to cryptlib header file(s)
# CRYPTLIBDIR = Path to libcl.*
# NSPRDIR = Path to nspr4 library
# NSPRINCLUDE = Path to NSPR header files
# SDL_CONFIG = Path to sdl-config program
Rob Swindell's avatar
Rob Swindell committed
28
# TAG = Git tag to checkout
29
# NO_X = Don't include build conio library (ciolib) for X
30
# NO_GTK = Don't build GTK-based sysop tools
deuce's avatar
deuce committed
31
# X_PATH = /path/to/X (if not /usr/X11R6)
32

33 34
# the magic bit:
MKFLAGS += MAKEFLAGS=
35 36
ifndef DEBUG
 ifndef RELEASE
37
  RELEASE	:=	1
38 39 40 41
 endif
endif

ifdef SYMLINK
rswindell's avatar
rswindell committed
42
 INSBIN	:=	ln -sf
43
else
44
 INSBIN	:=	cp -r
45 46 47 48 49 50
endif

ifdef bcc
 CCPRE	:=	bcc
 MKFLAGS	+=	bcc=1
else
51 52 53
 CC		?=	gcc
 CCPRE	?= ${shell if [ `echo __clang__ | $(CC) -E - | grep -v '^\#'` != __clang__ ] ; then echo clang ; elif [ `echo __INTEL_COMPILER | $(CC) -E - | grep -v '^\#'` != __INTEL_COMPILER ] ; then echo icc ; else echo gcc ; fi}
 CCPRE := $(lastword $(subst /, ,$(CCPRE)))
54 55
endif

56
SBBSUSER	?= $(USER)
57
SBBSGROUP	?= $(GROUP)
58
SBBSCHOWN	:= $(SBBSUSER):$(SBBSGROUP)
59

Rob Swindell's avatar
Rob Swindell committed
60 61
SBBSDIR	?=	$(shell pwd)
export SBBSDIR
62
REPODIR		= $(SBBSDIR)/repo
63

deuce's avatar
deuce committed
64 65 66 67
# Get OS
ifndef os
 os             =       $(shell uname)
endif
Rob Swindell's avatar
Rob Swindell committed
68
os      		:=      $(shell echo $(os) | tr '[A-Z]' '[a-z]' | tr ' ' '_')
deuce's avatar
deuce committed
69 70

machine         :=      $(shell if uname -m | egrep -v "(i[3456789]|x)86" > /dev/null; then uname -m | tr "[A-Z]" "[a-z]" | tr " " "_" ; fi)
Rob Swindell's avatar
Rob Swindell committed
71
machine			:=	$(shell if uname -m | egrep "64" > /dev/null; then uname -m | tr "[A-Z]" "[a-z]" | tr " " "_" ; else echo $(machine) ; fi)
72 73 74
ifeq ($(machine),x86_64)
 machine        := 	x64
endif
deuce's avatar
deuce committed
75 76 77 78 79
ifeq ($(machine),)
 machine        :=      $(os)
else
 machine        :=      $(os).$(machine)
endif
80 81 82

MKFLAGS	+=	os=$(os)

83
ifndef NOCAP
84
ifeq ($(os),linux)
85
	SETCAP 	:=	/sbin/setcap
86 87 88
endif
endif

89
ifdef DEBUG
deuce's avatar
deuce committed
90
 BUILD  :=  debug
91 92
 MKFLAGS	+=	DEBUG=1
else
deuce's avatar
deuce committed
93
 BUILD  :=  release
94 95
 MKFLAGS	+=	RELEASE=1
endif
deuce's avatar
deuce committed
96
BUILDPATH	?=	$(BUILD)
97 98 99 100 101

ifdef JSLIB
 MKFLAGS	+=	JSLIB=$(JSLIB)
endif

deuce's avatar
deuce committed
102 103 104 105
ifdef JSLIBDIR
 MKFLAGS	+=	JSLIBDIR=$(JSLIBDIR)
endif

106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
ifdef CRYPTLIBINCLUDE
 MKFLAGS	+=	CRYPTLIBINCLUDE=$(CRYPTLIBINCLUDE)
endif

ifdef CRYPTLIBDIR
 MKFLAGS	+=	CRYPTLIBDIR=$(CRYPTLIBDIR)
endif

ifdef NSPRDIR
 MKFLAGS	+=	NSPRDIR=$(NSPRDIR)
endif

ifdef NSPRINCLUDE
 MKFLAGS	+=	NSPRINCLUDE=$(NSPRINCLUDE)
endif

ifdef SDL_CONFIG
 MKFLAGS	+=	SDL_CONFIG=$(SDL_CONFIG)
endif

126 127 128 129
ifdef NO_X
 MKFLAGS	+=	NO_X=$(NO_X)
endif

deuce's avatar
deuce committed
130 131
ifdef X_PATH
 MKFLAGS	+=	X_PATH=$(X_PATH)
132 133
endif

deuce's avatar
deuce committed
134 135 136
# Check for GLADE
ifndef NO_GTK
 ifeq ($(shell pkg-config libglade-2.0 --exists && echo YES),YES)
deuce's avatar
deuce committed
137 138 139
  ifeq ($(shell pkg-config gtk+-2.0 --atleast-version=2.6 && echo YES),YES)
    USE_GLADE	:=	YES
  endif
deuce's avatar
deuce committed
140 141 142
 endif
endif

143 144 145
all: localdefs binaries baja externals

localdefs: src
146
	echo $(MKFLAGS) | tr ' ' '\n' > $(REPODIR)/src/build/localdefs.mk
147

148
binaries:	sbbs3 gtkuseredit gtkchat gtkmonitor gtkuserlist syncview sexpots
149

150
externals:	sbj dpoker tbd
151

Rob Swindell's avatar
Rob Swindell committed
152
sbbs3:	src
153
	$(MAKE) -C $(REPODIR)/src/sbbs3 $(MKFLAGS) $(SETCAP)
154

deuce's avatar
deuce committed
155
sexpots:	src
156
	$(MAKE) -C $(REPODIR)/src/sexpots $(MKFLAGS)
deuce's avatar
deuce committed
157

158
baja:	run sbbs3
159
	$(MAKE) -C $(SBBSDIR)/exec $(MKFLAGS) BAJAPATH=$(REPODIR)/src/sbbs3/$(CCPRE).$(machine).exe.$(BUILDPATH)/baja
160

161
sbj:	run
162
	$(MAKE) -C $(SBBSDIR)/xtrn/sbj $(MKFLAGS) SRC_ROOT=$(REPODIR)/src XPDEV=$(REPODIR)/src/xpdev/
163

deuce's avatar
deuce committed
164
dpoker:	run
165
	$(MAKE) -C $(SBBSDIR)/xtrn/dpoker $(MKFLAGS) SRC_ROOT=$(REPODIR)/src XPDEV=$(REPODIR)/src/xpdev/
deuce's avatar
deuce committed
166

deuce's avatar
deuce committed
167
tbd:	run
168
	$(MAKE) -C $(SBBSDIR)/xtrn/tbd $(MKFLAGS) SRC_ROOT=$(REPODIR)/src XPDEV=$(REPODIR)/src/xpdev/
deuce's avatar
deuce committed
169

deuce's avatar
deuce committed
170 171
gtkuseredit:	src
ifdef USE_GLADE
172
	$(MAKE) -C $(REPODIR)/src/sbbs3/gtkuseredit $(MKFLAGS) SBBS_SRC=$(REPODIR)/src/sbbs3/ XPDEV=$(REPODIR)/src/xpdev/
deuce's avatar
deuce committed
173 174
endif

175 176
gtkchat:	src
ifdef USE_GLADE
177
	$(MAKE) -C $(REPODIR)/src/sbbs3/gtkchat $(MKFLAGS) SBBS_SRC=$(REPODIR)/src/sbbs3/ XPDEV=$(REPODIR)/src/xpdev/
178 179
endif

180 181
gtkmonitor:	src
ifdef USE_GLADE
182
	$(MAKE) -C $(REPODIR)/src/sbbs3/gtkmonitor $(MKFLAGS) SBBS_SRC=$(REPODIR)/src/sbbs3/ XPDEV=$(REPODIR)/src/xpdev/
183 184
endif

deuce's avatar
deuce committed
185 186
gtkuserlist:	src
ifdef USE_GLADE
187
	$(MAKE) -C $(REPODIR)/src/sbbs3/gtkuserlist $(MKFLAGS) SBBS_SRC=$(REPODIR)/src/sbbs3/ XPDEV=$(REPODIR)/src/xpdev/
deuce's avatar
deuce committed
188 189
endif

deuce's avatar
deuce committed
190
syncview:
191
	$(MAKE) -C $(REPODIR)/src/sbbs3/syncview $(MKFLAGS) SBBS_SRC=$(REPODIR)/src/sbbs3/ XPDEV=$(REPODIR)/src/xpdev/
deuce's avatar
deuce committed
192

193
install: all
194
	@echo Installing to $(SBBSDIR)
195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222
	$(INSBIN) $(REPODIR)/src/sbbs3/$(CCPRE).$(machine).exe.$(BUILDPATH)/showstat $(SBBSDIR)/exec/showstat
	$(INSBIN) $(REPODIR)/src/sbbs3/$(CCPRE).$(machine).exe.$(BUILDPATH)/readsauce $(SBBSDIR)/exec/readsauce
	$(INSBIN) $(REPODIR)/src/sbbs3/$(CCPRE).$(machine).exe.$(BUILDPATH)/dstsedit $(SBBSDIR)/exec/dstsedit
	$(INSBIN) $(REPODIR)/src/sbbs3/$(CCPRE).$(machine).exe.$(BUILDPATH)/smbactiv $(SBBSDIR)/exec/smbactiv
	$(INSBIN) $(REPODIR)/src/sbbs3/$(CCPRE).$(machine).exe.$(BUILDPATH)/dupefind $(SBBSDIR)/exec/dupefind
	$(INSBIN) $(REPODIR)/src/sbbs3/$(CCPRE).$(machine).exe.$(BUILDPATH)/delfiles $(SBBSDIR)/exec/delfiles
	$(INSBIN) $(REPODIR)/src/sbbs3/$(CCPRE).$(machine).exe.$(BUILDPATH)/allusers $(SBBSDIR)/exec/allusers
	$(INSBIN) $(REPODIR)/src/sbbs3/$(CCPRE).$(machine).exe.$(BUILDPATH)/qwknodes $(SBBSDIR)/exec/qwknodes
	$(INSBIN) $(REPODIR)/src/sbbs3/$(CCPRE).$(machine).exe.$(BUILDPATH)/asc2ans $(SBBSDIR)/exec/asc2ans
	$(INSBIN) $(REPODIR)/src/sbbs3/$(CCPRE).$(machine).exe.$(BUILDPATH)/ans2asc $(SBBSDIR)/exec/ans2asc
	$(INSBIN) $(REPODIR)/src/sbbs3/$(CCPRE).$(machine).exe.$(BUILDPATH)/jsexec $(SBBSDIR)/exec/jsexec
	$(INSBIN) $(REPODIR)/src/sbbs3/$(CCPRE).$(machine).exe.$(BUILDPATH)/baja $(SBBSDIR)/exec/baja
	$(INSBIN) $(REPODIR)/src/sbbs3/$(CCPRE).$(machine).exe.$(BUILDPATH)/unbaja $(SBBSDIR)/exec/unbaja
	$(INSBIN) $(REPODIR)/src/sbbs3/$(CCPRE).$(machine).exe.$(BUILDPATH)/slog $(SBBSDIR)/exec/slog
	$(INSBIN) $(REPODIR)/src/sbbs3/$(CCPRE).$(machine).exe.$(BUILDPATH)/node $(SBBSDIR)/exec/node
	$(INSBIN) $(REPODIR)/src/sbbs3/$(CCPRE).$(machine).exe.$(BUILDPATH)/chksmb $(SBBSDIR)/exec/chksmb
	$(INSBIN) $(REPODIR)/src/sbbs3/$(CCPRE).$(machine).exe.$(BUILDPATH)/fixsmb $(SBBSDIR)/exec/fixsmb
	$(INSBIN) $(REPODIR)/src/sbbs3/$(CCPRE).$(machine).exe.$(BUILDPATH)/addfiles $(SBBSDIR)/exec/addfiles
	$(INSBIN) $(REPODIR)/src/sbbs3/$(CCPRE).$(machine).exe.$(BUILDPATH)/makeuser $(SBBSDIR)/exec/makeuser
	$(INSBIN) $(REPODIR)/src/sbbs3/$(CCPRE).$(machine).exe.$(BUILDPATH)/smbutil $(SBBSDIR)/exec/smbutil
	$(INSBIN) $(REPODIR)/src/sbbs3/$(CCPRE).$(machine).exe.$(BUILDPATH)/sbbs $(SBBSDIR)/exec/sbbs
	$(INSBIN) $(REPODIR)/src/sbbs3/$(CCPRE).$(machine).exe.$(BUILDPATH)/sbbsecho $(SBBSDIR)/exec/sbbsecho
	$(INSBIN) $(REPODIR)/src/sbbs3/$(CCPRE).$(machine).exe.$(BUILDPATH)/sexyz $(SBBSDIR)/exec/sexyz
	$(INSBIN) $(REPODIR)/src/sbbs3/$(CCPRE).$(machine).exe.$(BUILDPATH)/echocfg $(SBBSDIR)/exec/echocfg
	$(INSBIN) $(REPODIR)/src/sbbs3/$(CCPRE).$(machine).exe.$(BUILDPATH)/filelist $(SBBSDIR)/exec/filelist
	$(INSBIN) $(REPODIR)/src/sbbs3/scfg/$(CCPRE).$(machine).exe.$(BUILDPATH)/scfg $(SBBSDIR)/exec/scfg
	$(INSBIN) $(REPODIR)/src/sbbs3/umonitor/$(CCPRE).$(machine).exe.$(BUILDPATH)/umonitor $(SBBSDIR)/exec/umonitor
	$(INSBIN) $(REPODIR)/src/sbbs3/uedit/$(CCPRE).$(machine).exe.$(BUILDPATH)/uedit $(SBBSDIR)/exec/uedit
223
	$(INSBIN) $(REPODIR)/src/sbbs3/$(CCPRE).$(machine).exe.$(BUILDPATH)/upgrade_to_v319 $(SBBSDIR)/exec/upgrade_to_v319
224 225 226 227 228
	$(INSBIN) $(REPODIR)/src/sbbs3/$(CCPRE).$(machine).lib.$(BUILDPATH)/libsbbs.so $(SBBSDIR)/exec/libsbbs.so
	$(INSBIN) $(REPODIR)/src/sbbs3/$(CCPRE).$(machine).lib.$(BUILDPATH)/libftpsrvr.so $(SBBSDIR)/exec/libftpsrvr.so
	$(INSBIN) $(REPODIR)/src/sbbs3/$(CCPRE).$(machine).lib.$(BUILDPATH)/libmailsrvr.so $(SBBSDIR)/exec/libmailsrvr.so
	$(INSBIN) $(REPODIR)/src/sbbs3/$(CCPRE).$(machine).lib.$(BUILDPATH)/libservices.so $(SBBSDIR)/exec/libservices.so
	$(INSBIN) $(REPODIR)/src/sbbs3/$(CCPRE).$(machine).lib.$(BUILDPATH)/libwebsrvr.so $(SBBSDIR)/exec/libwebsrvr.so
deuce's avatar
deuce committed
229
ifdef USE_GLADE
230 231 232 233 234 235 236 237 238
	$(INSBIN) $(REPODIR)/src/sbbs3/gtkuseredit/$(CCPRE).$(machine).exe.$(BUILDPATH)/gtkuseredit $(SBBSDIR)/exec/gtkuseredit
	$(INSBIN) $(REPODIR)/src/sbbs3/gtkuseredit/gtkuseredit.glade $(SBBSDIR)/exec/gtkuseredit.glade
	$(INSBIN) $(REPODIR)/src/sbbs3/gtkmonitor/$(CCPRE).$(machine).exe.$(BUILDPATH)/gtkmonitor $(SBBSDIR)/exec/gtkmonitor
	$(INSBIN) $(REPODIR)/src/sbbs3/gtkmonitor/gtkmonitor.glade $(SBBSDIR)/exec/gtkmonitor.glade
	$(INSBIN) $(REPODIR)/src/sbbs3/gtkmonitor/pixmaps/stock_help-chat.png $(SBBSDIR)/exec/stock_help-chat.png
	$(INSBIN) $(REPODIR)/src/sbbs3/gtkmonitor/pixmaps/stock_mail-send.png $(SBBSDIR)/exec/stock_mail-send.png
	$(INSBIN) $(REPODIR)/src/sbbs3/gtkchat/$(CCPRE).$(machine).exe.$(BUILDPATH)/gtkchat $(SBBSDIR)/exec/gtkchat
	$(INSBIN) $(REPODIR)/src/sbbs3/gtkuserlist/$(CCPRE).$(machine).exe.$(BUILDPATH)/gtkuserlist $(SBBSDIR)/exec/gtkuserlist
	$(INSBIN) $(REPODIR)/src/sbbs3/gtkuserlist/gtkuserlist.glade $(SBBSDIR)/exec/gtkuserlist.glade
deuce's avatar
deuce committed
239
endif
240 241
	$(INSBIN) $(REPODIR)/src/sbbs3/syncview/$(CCPRE).$(machine).exe.$(BUILDPATH)/syncview $(SBBSDIR)/exec/syncview
	$(INSBIN) $(REPODIR)/src/sexpots/$(CCPRE).$(machine).exe.$(BUILDPATH)/sexpots $(SBBSDIR)/exec/sexpots
242 243
	-chown -R $(SBBSCHOWN) $(SBBSDIR)
	-chown -h $(SBBSCHOWN) $(SBBSDIR)/exec/*
244

245
$(REPODIR):
246 247
	git clone https://gitlab.com/SynchronetBBS/sbbs.git $(REPODIR) \
		|| git clone https://github.com/SynchronetBBS/sbbs.git $(REPODIR) \
248 249
		|| git clone https://gitlab.synchro.net/main/sbbs.git $(REPODIR)
	git -C $(REPODIR) remote set-url origin https://gitlab.synchro.net/main/sbbs.git
Rob Swindell's avatar
Rob Swindell committed
250
ifdef TAG
251
	git -C $(REPODIR) checkout tags/$(TAG)
252 253
endif

254
src: $(REPODIR)
255

256 257
run: $(SBBSDIR)/ctrl $(SBBSDIR)/docs $(SBBSDIR)/exec $(SBBSDIR)/text $(SBBSDIR)/web $(SBBSDIR)/webv4 $(SBBSDIR)/xtrn \
	$(SBBSDIR)/node1 $(SBBSDIR)/node2 $(SBBSDIR)/node3 $(SBBSDIR)/node4
258 259

$(SBBSDIR)/ctrl: $(REPODIR)
260
	cp -r $(REPODIR)/ctrl $(SBBSDIR)
261 262

$(SBBSDIR)/docs: $(REPODIR)
263
	$(INSBIN) $(REPODIR)/docs $(SBBSDIR)
264 265

$(SBBSDIR)/exec: $(REPODIR)
266
	$(INSBIN) $(REPODIR)/exec $(SBBSDIR)
267 268

$(SBBSDIR)/node1: $(REPODIR)
269 270 271 272 273 274 275 276 277 278
	cp -r $(REPODIR)/node1 $@

$(SBBSDIR)/node2: $(REPODIR)
	cp -r $(REPODIR)/node1 $@

$(SBBSDIR)/node3: $(REPODIR)
	cp -r $(REPODIR)/node1 $@

$(SBBSDIR)/node4: $(REPODIR)
	cp -r $(REPODIR)/node1 $@
279 280

$(SBBSDIR)/text: $(REPODIR)
281
	$(INSBIN) $(REPODIR)/text $(SBBSDIR)
282 283

$(SBBSDIR)/web: $(REPODIR)
284 285 286 287
	$(INSBIN) $(REPODIR)/web $(SBBSDIR)

$(SBBSDIR)/webv4: $(REPODIR)
	$(INSBIN) $(REPODIR)/webv4 $(SBBSDIR)
288 289

$(SBBSDIR)/xtrn: $(REPODIR)
290
	$(INSBIN) $(REPODIR)/xtrn $(SBBSDIR)
291 292 293

$(SBBSDIR):
	@[ ! -e $(SBBSDIR) ] && mkdir $(SBBSDIR);