ack/Makefile

143 lines
3.5 KiB
Makefile
Raw Permalink Normal View History

# ======================================================================= #
# ACK CONFIGURATION #
# (Edit this before building) #
# ======================================================================= #
# What platform to build for by default?
DEFAULT_PLATFORM ?= pc86
# Where should the ACK put its temporary files?
ACK_TEMP_DIR ?= /tmp
# Where is the ACK going to be installed, eventually? If you don't want to
# install it and just want to run the ACK from the build directory
# (/tmp/ack-build/staging, by default), leave this as $(INSDIR).
ifeq ($(OS),Windows_NT)
PREFIX ?= c:/ack
else
PREFIX ?= /usr/local
#PREFIX = $(INSDIR)
endif
# Where do you want to put the object files used when building?
BUILDDIR ?= $(ACK_TEMP_DIR)/ack-build
2018-06-02 19:30:52 +00:00
# What build flags do you want to use for native code?
CFLAGS ?= -g -Wno-return-type
LDFLAGS ?=
# Various commands.
AR ?= ar
CC ?= gcc
2022-06-26 20:28:30 +00:00
LUA ?= lua
2016-09-01 21:36:39 +00:00
# Which build system to use; use 'ninja' or 'make' (in lower case). Leave
# blank to autodetect.
BUILDSYSTEM ?=
2016-09-01 21:36:39 +00:00
# Build flags for ninja.
NINJAFLAGS ?=
2016-09-01 21:36:39 +00:00
# Build flags for make.
MAKEFLAGS ?=
2016-09-01 21:36:39 +00:00
# ======================================================================= #
# END OF CONFIGURATION #
# ======================================================================= #
# You shouldn't need to change anything below this point unless you are
# actually developing ACK.
OBJDIR = $(abspath $(BUILDDIR)/obj)
BINDIR = $(abspath $(BUILDDIR)/bin)
LIBDIR = $(abspath $(BUILDDIR)/lib)
INCDIR = $(abspath $(BUILDDIR)/include)
INSDIR = $(abspath $(BUILDDIR)/staging)
PLATIND = $(INSDIR)/share/ack
PLATDEP = $(INSDIR)/lib/ack
.NOTPARALLEL:
ifeq ($(BUILDSYSTEM),)
ifneq ($(shell which ninja),)
2016-09-01 21:36:39 +00:00
BUILDSYSTEM = ninja
else
2016-09-01 21:36:39 +00:00
BUILDSYSTEM = make
endif
2016-09-01 21:36:39 +00:00
endif
build-file = $(BUILDDIR)/build.$(BUILDSYSTEM)
lua-files = $(shell find . -name 'build*.lua')
our-lua = $(BUILDDIR)/lua
# GNU make sets MAKECMDGOALS to the list of targets from the command
# line. We look for targets with '+' and forward them to BUILDSYSTEM.
# This handles commands like
# $ make util/opt+pkg util/ego+pkg
all-goals = +ack +tests
plus-goals := $(patsubst all,$(all-goals),$(or $(MAKECMDGOALS),all))
plus-goals := $(foreach g,$(plus-goals),$(if $(findstring +,$(g)),$(g),))
# @true silences extra message, "make: Nothing to be done..."
all: build-plus-goals
@true
ifneq ($(plus-goals),)
$(plus-goals): build-plus-goals
@true
2016-09-01 21:36:39 +00:00
endif
build-plus-goals: $(build-file)
ifeq ($(BUILDSYSTEM),ninja)
@ninja $(NINJAFLAGS) -f $(build-file) $(plus-goals)
else ifeq ($(BUILDSYSTEM),make)
# GNU make passes MAKEFLAGS in environment.
@$(MAKE) -f $(build-file) $(plus-goals)
else
$(error unknown BUILDSYSTEM = $(BUILDSYSTEM))
endif
$(build-file): first/ackbuilder.lua Makefile $(lua-files)
@mkdir -p $(BUILDDIR)
2022-06-26 20:28:30 +00:00
@$(LUA) first/ackbuilder.lua \
2016-09-01 21:36:39 +00:00
first/build.lua build.lua \
--$(BUILDSYSTEM) \
2022-06-26 20:28:30 +00:00
LUA=$(LUA) \
DEFAULT_PLATFORM=$(DEFAULT_PLATFORM) \
OBJDIR=$(OBJDIR) \
BINDIR=$(BINDIR) \
LIBDIR=$(LIBDIR) \
INCDIR=$(INCDIR) \
INSDIR=$(INSDIR) \
PLATIND=$(PLATIND) \
PLATDEP=$(PLATDEP) \
PREFIX="$(PREFIX)" \
AR=$(AR) \
CC=$(CC) \
2018-06-02 19:30:52 +00:00
CFLAGS="$(CFLAGS)" \
LDFLAGS="$(LDFLAGS)" \
> $(build-file)
ack-setup.exe: etc/windows-installer.nsi
makensis -dBUILDDIR=$(BUILDDIR)/staging -dOUTFILE="$$(realpath $@)" $<
2016-09-02 21:03:57 +00:00
install:
mkdir -p $(PREFIX)
tar cf - -C $(INSDIR) . | tar xvf - -C $(PREFIX)
clean:
rm -rf $(BUILDDIR)