From: Olof J. <ol...@et...> - 2013-05-11 19:29:27
|
With these changes, some commonly overrided values can be exported from the environment to influence the build output (e.g. PREFIX, CFLAGS, INSTALL, etc). You can also specify the lua version you'd like to use with the following variable: "LUA_VERSION" (if not specified, it tries to detect the highest lua version available (as seen by pkg-config)). --- README | 6 +-- build/lua-detect.mk | 48 +++++++++++++++++++++ system-autodetect.mk | 116 ++++++++++++++------------------------------------ 3 files changed, 82 insertions(+), 88 deletions(-) create mode 100644 build/lua-detect.mk diff --git a/README b/README index c069acf..fc7c4c8 100644 --- a/README +++ b/README @@ -41,9 +41,9 @@ See also: build-essential lua5.1 liblua5.1-0-dev libx11-dev libxext-dev libsm-dev gettext libxinerama-dev libxrandr-dev -3. If the default build settings don't suit you, review system-autodetect.mk - and either override values in a newly added system-local.mk or make changes - directly to system-autodetect.mk +3. If the default build settings don't suit you, review system-autodetect.mk + and either override values from the environment or in a newly added + system-local.mk or make changes directly to system-autodetect.mk. 4. If you want to build some extra modules now or do not want to build some of the standard modules, edit `modulelist.mk`. diff --git a/build/lua-detect.mk b/build/lua-detect.mk new file mode 100644 index 0000000..a41b06f --- /dev/null +++ b/build/lua-detect.mk @@ -0,0 +1,48 @@ +# Find highest known lua version. +# +# It uses pkg-config to do this, but will fail if you have liblua, but +# not the corresponding interpreter/compiler. Let's say you have liblua5.2 +# but want to build with liblua5.1 (for which you have the lib, interpreter +# and compiler), you can override by setting LUA_VERSION=5.0 when invoking +# make. +# +# If successful, sets the following variables: +# * LUA_VERSION (unless already set) +# * LUA_LIBS (can be appended to LDFLAGS directly) +# * LUA_INCLUDES (can be appended to CFLAGS directly) +# * LUA (full path to lua interpreter) +# * LUAC (full path to lua compiler) + +LUA_VERSION ?= $(shell pkg-config --exists lua5.2 && echo 5.2) +LUA_VERSION ?= $(shell pkg-config --exists lua5.1 && echo 5.1) +LUA_VERSION ?= $(shell pkg-config --exists lua && echo 5.0) + +ifeq ($(LUA_VERSION),) + $(error Could not find any lua version. (Did you install the -dev package?)) +endif + +# prior to 5.1 the lib didn't include version in name. +ifeq ($(LUA_VERSION),5.0) + LUA_VERSION= +endif + +LUA_LIBS = $(shell pkg-config --libs lua$(LUA_VERSION)) +LUA_INCLUDES = $(shell pkg-config --cflags lua$(LUA_VERSION)) +LUA = $(shell which lua$(LUA_VERSION)) +LUAC = $(shell which luac$(LUA_VERSION)) + +ifeq ($(LUA_LIBS),) + $(error "pkg-config couldn't find linker flags for lua$(LUA_VERSION)!") +endif + +ifeq ($(LUA_INCLUDES),) + $(error "pkg-config couldn't find compiler flags for lua$(LUA_VERSION)!") +endif + +ifeq ($(LUA),) + $(error No lua$(LUA_VERSION) interpreter found!) +endif + +ifeq ($(LUAC),) + $(error No lua$(LUA_VERSION) compiler found!) +endif diff --git a/system-autodetect.mk b/system-autodetect.mk index 5cdfc46..fef949b 100644 --- a/system-autodetect.mk +++ b/system-autodetect.mk @@ -9,15 +9,13 @@ # Installation path prefix. Unless you know what you're doing, the default # of /usr/local is likely the correct choice. #DIST: PREFIX=/usr/local -PREFIX=/usr/local +PREFIX ?= /usr/local # Unless you are creating a package conforming to some OS's standards, you # probably do not want to modify the following directories: # Main binaries BINDIR=$(PREFIX)/bin -# Configuration .lua files -ETCDIR=$(PREFIX)/etc/notion # Some .lua files and ion-* shell scripts SHAREDIR=$(PREFIX)/share/notion # Manual pages @@ -25,8 +23,6 @@ MANDIR=$(PREFIX)/share/man # Some documents DOCDIR=$(PREFIX)/share/doc/notion # Nothing at the moment -INCDIR=$(PREFIX)/include/notion -# Nothing at the moment LIBDIR=$(PREFIX)/lib # Modules MODULEDIR=$(LIBDIR)/notion/mod @@ -39,6 +35,19 @@ VARDIR=/var/cache/notion # Message catalogs LOCALEDIR=$(PREFIX)/share/locale +# Configuration .lua files. Overrideable, as config files are usually +# not placed under $(PREFIX). +ETCDIR ?= $(PREFIX)/etc/notion + +# Force all include files to be installed to /usr even if the +# PREFIX is unset. No header files are installed at the moment +# though. +ifeq ($(PREFIX),) + INCDIR = $(PREFIX)/include/notion +else + INCDIR = /usr/include/notion +endif + # Executable suffix (for Cygwin). #BIN_SUFFIX = .exe @@ -61,80 +70,16 @@ DL_LIBS=-ldl ## Lua ## -# To skip auto-detection of lua uncomment this and edit the variables below to -# suit your installation of lua. -#LUA_MANUAL=1 - -# Default to paths and names that should work for a build installed from the -# official Lua 5.1 source tarball. -LUA_DIR=/usr/local -LUA_LIBS=-L$(LUA_DIR)/lib -llua -LUA_INCLUDES = -I$(LUA_DIR)/include - -ifneq ($(shell which lua),) -LUA=$(LUA_DIR)/bin/lua -LUAC=$(LUA_DIR)/bin/luac -endif - -# Attempt to autodect lua using pkg-config. - -ifndef LUA_MANUAL - -# lua libraries and includes: - -ifeq (5.2,$(findstring 5.2,$(shell pkg-config --exists lua5.2 && pkg-config --modversion lua5.2))) -ifneq ($(shell which lua5.2),) -HAS_LUA52=true -HAS_LUA=true -endif -endif - -ifeq (5.1,$(findstring 5.1,$(shell pkg-config --exists lua5.1 && pkg-config --modversion lua5.1))) -ifneq ($(shell which lua5.1),) -HAS_LUA51=true -HAS_LUA=true -endif -endif - -ifeq (5.1,$(findstring 5.1,$(shell pkg-config --exists lua && pkg-config --modversion lua))) -ifneq ($(shell which lua),) -HAS_LUA=true -endif -endif - -ifdef HAS_LUA52 - -LUA_LIBS=`pkg-config --libs lua5.2` -LUA_INCLUDES=`pkg-config --cflags lua5.2` -LUA=`which lua5.2` -LUAC=`which luac5.2` - -else ifdef HAS_LUA51 - -LUA_LIBS=`pkg-config --libs lua5.1` -LUA_INCLUDES=`pkg-config --cflags lua5.1` -LUA=`which lua5.1` -LUAC=`which luac5.1` - -else ifdef HAS_LUA - -LUA_LIBS=`pkg-config --libs lua` -LUA_INCLUDES=`pkg-config --cflags lua` -LUA=`which lua` -LUAC=`which luac` - -endif # lua - -endif # lua manual +include $(TOPDIR)/build/lua-detect.mk ## ## X libraries, includes and options ## # Paths -X11_PREFIX=/usr/X11R6 +X11_PREFIX ?= /usr/X11R6 # SunOS/Solaris -#X11_PREFIX=/usr/openwin +#X11_PREFIX ?= /usr/openwin X11_LIBS=-L$(X11_PREFIX)/lib -lX11 -lXext X11_INCLUDES=-I$(X11_PREFIX)/include @@ -178,7 +123,7 @@ DEFINES += -DCF_XFREE86_TEXTPROP_BUG_WORKAROUND # You may uncomment this if you know that your system C libary provides # asprintf and vasprintf. (GNU libc does.) If HAS_SYSTEM_ASPRINTF is not # defined, an implementation provided in libtu/sprintf_2.2/ is used. -HAS_SYSTEM_ASPRINTF=1 +HAS_SYSTEM_ASPRINTF ?= 1 # The following setting is needed with GNU libc for clock_gettime and the # monotonic clock. Other systems may not need it, or may not provide a @@ -200,7 +145,7 @@ EXTRA_LIBS += -lrt ## C compiler. ## -CC=gcc +CC ?= gcc # Same as '-Wall -pedantic' without '-Wunused' as callbacks often # have unused variables. @@ -208,9 +153,10 @@ WARN= -W -Wimplicit -Wreturn-type -Wswitch -Wcomment \ -Wtrigraphs -Wformat -Wchar-subscripts \ -Wparentheses -pedantic -Wuninitialized -CFLAGS=-Os $(WARN) $(DEFINES) $(INCLUDES) $(EXTRA_INCLUDES) -DHAS_SYSTEM_ASPRINTF=$(HAS_SYSTEM_ASPRINTF) +CFLAGS += -Os $(WARN) $(DEFINES) $(INCLUDES) $(EXTRA_INCLUDES) \ + -DHAS_SYSTEM_ASPRINTF=$(HAS_SYSTEM_ASPRINTF) -LDFLAGS=-Wl,--as-needed $(LIBS) $(EXTRA_LIBS) +LDFLAGS += -Wl,--as-needed $(LIBS) $(EXTRA_LIBS) EXPORT_DYNAMIC=-Xlinker --export-dynamic # The following options are mainly for development use and can be used @@ -250,23 +196,23 @@ MAKE_DEPEND=$(DO_MAKE_DEPEND) $(SOURCES) > $(DEPEND_FILE) ## AR ## -AR=ar -ARFLAGS=cr -RANLIB=ranlib +AR ?= ar +ARFLAGS ?= cr +RANLIB ?= ranlib ## ## Install & strip ## -INSTALL=sh $(TOPDIR)/install-sh -c -INSTALL_STRIP=-s -INSTALLDIR=mkdir -p +INSTALL ?= sh $(TOPDIR)/install-sh -c +INSTALL_STRIP = -s +INSTALLDIR ?= mkdir -p -BIN_MODE=755 -DATA_MODE=644 +BIN_MODE ?= 755 +DATA_MODE ?= 644 -RM=rm +RM ?= rm ## -- 1.7.10.4 |