about summary refs log tree commit diff
path: root/pkgs/build-support/build-sandbox/src/Makefile
blob: a5b9b32d79e2573b9f51eab54aa36e32452e68cf (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
BINARIES = $(wildcard $(BINDIR)/*)
WRAPPERS = $(subst $(BINDIR),$(out)/bin,$(BINARIES))

NIX_VERSION = `pkg-config --modversion nix-main | \
               sed -e 's/^\([0-9]\+\)\.\([0-9][0-9]\).*/\1\2/' \
                   -e 's/^\([0-9]\+\)\.\([0-9]\).*/\10\2/'`

OBJECTS = nix-query.o path-cache.o params.o setup.o

CFLAGS = -g -Wall -std=gnu11 -DFS_ROOT_DIR=\"$(out)\"
CXXFLAGS = -g -Wall -std=c++14 `pkg-config --cflags nix-main`
CXXFLAGS += -DNIX_VERSION=$(NIX_VERSION)
LDFLAGS = -Wl,--copy-dt-needed-entries `pkg-config --libs nix-main`

all: $(OBJECTS)

$(out)/bin/%: CFLAGS += -DWRAPPED_PROGNAME=\"$(@F)\"
$(out)/bin/%: CFLAGS += -DWRAPPED_PATH=\"$(BINDIR)/$(@F)\"
$(out)/bin/%: $(OBJECTS)
	mkdir -p $(out)/bin
	$(CC) -o $@ $(CFLAGS) $(LDFLAGS) $? sandbox.c

.PHONY: install
install: $(WRAPPERS)