-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
35 lines (26 loc) · 918 Bytes
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# Files are installed under $(DESTDIR)/$(PREFIX)
PREFIX ?= /usr/local
DEST := $(shell echo "$(DESTDIR)/$(PREFIX)" | sed 's:///*:/:g; s://*$$::')
all: _output/lib/libnac.dylib _output/bin/nac
GO ?= go
GO_LDFLAGS ?= -s -w
GO_BUILD ?= $(GO) build -trimpath -ldflags="$(GO_LDFLAGS)"
# Because deprecated functions have to be hooked
CFLAGS += -Wno-deprecated-declarations
%.o: %.c *.h
$(CC) $(CFLAGS) -c $< -o $@
_output/lib/libnac.dylib: $(patsubst %.c, %.o, $(wildcard libnac/*.c))
mkdir -p _output/lib
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) -ldl -dynamiclib $^
_output/bin/nac: $(shell find . -type f -name '*.go')
$(GO_BUILD) -o $@ ./cmd/nac
.PHONY: clean
clean:
$(RM) -r _output libnac/*.o
.PHONY: install
install: uninstall
install _output/bin/nac "$(DEST)/bin/nac"
install _output/lib/libnac.dylib "$(DEST)/lib/libnac.dylib"
.PHONY: uninstall
uninstall:
$(RM) "$(DEST)/bin/nac" "$(DEST)/lib/libnac.dylib"