Newer
Older

Andrew Price
committed
SVNVER = $(shell ( svnversion -c . 2>/dev/null | sed 's/Unversioned directory/exported/' || echo 0:0 ) | cut -d : -f 2)
VERSION_MINOR = 17
ifeq ($(VERSION_TWEAK),)
ifeq ($(SVNVER),exported)
# mw.rev is created after an export so we can rely on it to provide the svn rev here
VERSION_TWEAK = $(shell cat $(SRCROOT)/mw.rev)
else
ifeq ($(SVNVER),0)
$(warning failed to run svnversion, is it installed? VERSION_TWEAK will be set to 0)
endif
VERSION_TWEAK = $(SVNVER)
endif
VERSION = $(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_TWEAK)
MWVERSION = mw3-$(VERSION)
libdir ?= $(prefix)/lib
bindir ?= $(prefix)/bin
datadir ?= $(prefix)/share
localstatedir ?= /var

Andrew Price
committed
initddir ?= /etc/init.d
# The non source files that should get installed
INSTALLFILES = colour help login.banner scripthelp talkhelp wizhelp COPYING INSTALL LICENSE README
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
LOGDIR := $(localstatedir)/log/mw
MSGDIR := $(localstatedir)/run/mw
STATEDIR := $(localstatedir)/lib/mw
HOMEPATH := $(libdir)/mw
GCCMAJOR := $(echo __GNUC__ | $compiler -E -xc - | tail -n 1)
GCCMINOR := $(echo __GNUC_MINOR__ | $compiler -E -xc - | tail -n 1)
GCCVER := $(shell printf "%02d%02d" $(GCCMAJOR) $(GCCMINOR))
ifeq ($(JSFLAGS),)
#Fedora
JSFLAGS=$(shell pkg-config --cflags libjs 2>/dev/null)
JSLIBS=$(shell pkg-config --libs-only-l libjs 2>/dev/null)
JSSCRIPTTYPE=JSObject # Some idiot made the script APIs different without changing the version
endif
ifeq ($(JSFLAGS),)
#Debian
JSFLAGS=$(shell pkg-config --cflags mozilla-js)
JSLIBS=$(shell pkg-config --libs-only-l mozilla-js)
JSSCRIPTTYPE=JSScript
endif
# cflags for standard 'cc' compiler
CFLAGS+= -Wall -Wshadow -Wmissing-prototypes -Wstrict-prototypes -Wpointer-arith -Wwrite-strings -Wcast-align -Wbad-function-cast -Wmissing-format-attribute -Wformat=2 -Wformat-security -Wformat-nonliteral -Wno-long-long -Wno-strict-aliasing -pedantic -std=gnu99 -D_GNU_SOURCE $(JSFLAGS) -DJSSCRIPTTYPE=$(JSSCRIPTTYPE)
# until gcc catches up (4.7.x is good)
CFLAGS += $(shell if [ $(GCCVER) -lt 0406 ] ; then echo "-Wno-multichar"; fi )
ifdef WITHPIE
CFLAGS += -fpie
LDFLAGS += -pie
endif
# info strings, do not edit.
DEFS:= -DBUILD_DATE=\"$(shell date +%Y%m%d)\"
DEFS+= -DBUILD_USER=\"$(shell whoami | awk -f $(DEPTH)capitalise.awk)\"
DEFS+= -DVER_MAJ=\"$(VERSION_MAJOR)\"
DEFS+= -DVER_MIN=\"$(VERSION_MINOR)\"
DEFS+= -DVER_TWK=\"$(VERSION_TWEAK)\"
DEFS+= -DHOMEPATH=\"$(HOMEPATH)\"
DEFS+= -DLOGDIR=\"$(LOGDIR)\"
DEFS+= -DSTATEDIR=\"$(STATEDIR)\"
DEFS+= -DMSGDIR=\"$(MSGDIR)\"
### uncomment for gdb debugging
LDFLAGS+= -ggdb -g
CFLAGS+= -ggdb -g -D__NO_STRING_INLINE -fstack-protector-all
### Optimisation - uncomment for release & extra testing
CFLAGS += $(DEFS)
### The magic which lets us autogenerate dependencies
CFLAGS += -MMD
CODE=$(wildcard *.c)
HDRS=$(wildcard *.h)
all: build
%.o: %.c
$(CC) $(CFLAGS) -c -o $@ $<
-include $(CODE:.c=.d)
.PHONY: build install clean test all testclean