GNUmakefile 10.7 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
# NOCAP = Set to defeat sbbs3 bind-capabilities (setcap) build target on Linux
16 17
# bcc = Set to use Borland compiler
# os = Set to the OS name (Not required)
18
# SBBSUSER = Owner for the installed files
19
# SBBSGROUP = Group for the installed files
deuce's avatar
deuce committed
20 21
# JSLIB = Library name of JavaScript library.
# JSLIBDIR = Full path to JavaScript library
22 23 24 25 26
# 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
27
# TAG = Git tag to checkout
28
# NO_X = Don't include build conio library (ciolib) for X
29
# NO_GTK = Don't build GTK-based sysop tools
deuce's avatar
deuce committed
30
# X_PATH = /path/to/X (if not /usr/X11R6)
31

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

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

ifdef bcc
 CCPRE	:=	bcc
 MKFLAGS	+=	bcc=1
else
50 51 52
 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)))
53 54
endif

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

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

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

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
70
machine			:=	$(shell if uname -m | egrep "64" > /dev/null; then uname -m | tr "[A-Z]" "[a-z]" | tr " " "_" ; else echo $(machine) ; fi)
71 72 73
ifeq ($(machine),x86_64)
 machine        := 	x64
endif
deuce's avatar
deuce committed
74 75 76 77 78
ifeq ($(machine),)
 machine        :=      $(os)
else
 machine        :=      $(os).$(machine)
endif
79 80 81

MKFLAGS	+=	os=$(os)

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

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

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

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

105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124
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

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

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

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

142 143 144
all: localdefs binaries baja externals

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

147
binaries:	sbbs3 gtkuseredit gtkchat gtkmonitor gtkuserlist syncview sexpots
148

149
externals:	sbj dpoker tbd
150

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

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

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

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

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

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

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

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

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

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

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

192
install: all
193
	@echo Installing to $(SBBSDIR)
194 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
	$(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
222
	$(INSBIN) $(REPODIR)/src/sbbs3/$(CCPRE).$(machine).exe.$(BUILDPATH)/upgrade_to_v319 $(SBBSDIR)/exec/upgrade_to_v319
223 224 225 226 227
	$(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
228
ifdef USE_GLADE
229 230 231 232 233 234 235 236 237
	$(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
238
endif
239 240
	$(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
241 242
	-chown -R $(SBBSCHOWN) $(SBBSDIR)
	-chown -h $(SBBSCHOWN) $(SBBSDIR)/exec/*
243

244
$(REPODIR):
245 246
	git clone https://gitlab.com/SynchronetBBS/sbbs.git $(REPODIR) \
		|| git clone https://github.com/SynchronetBBS/sbbs.git $(REPODIR) \
247 248
		|| 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
249
ifdef TAG
250
	git -C $(REPODIR) checkout tags/$(TAG)
251 252
endif

253
src: $(REPODIR)
254

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

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

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

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

$(SBBSDIR)/node1: $(REPODIR)
268 269 270 271 272 273 274 275 276 277
	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 $@
278 279

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

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

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

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

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