Skip to content

Commit 452c318

Browse files
committed
Add a simplistic "make install" target
To really do this properly would probably mean setting up autoconf and/or automake, which doesn't sound like a ton of fun. This mimics a subset of what such a system would produce, which should make life easier for distribution packagers.
1 parent 7e08b31 commit 452c318

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

Makefile

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,17 @@ LDFLAGS ?=
3737

3838
SHARED_LDFLAGS ?= -shared
3939

40+
# Prefix for all installed files
41+
prefix = /usr/local
42+
43+
exec_prefix = ${prefix}
44+
bindir = ${exec_prefix}/bin
45+
includedir = ${prefix}/include
46+
libdir = ${exec_prefix}/lib
47+
DESTDIR =
48+
INSTALL = install -c
49+
INSTALL_DATA = ${INSTALL} -m 644
50+
4051
################################################################################
4152
# End of user-servicable parts
4253
################################################################################
@@ -70,8 +81,10 @@ ALL_HEADERS = \
7081
core/std.jsonnet.h \
7182
include/libjsonnet.h
7283

84+
.PHONY: default
7385
default: jsonnet
7486

87+
.PHONY: all
7588
all: $(ALL)
7689

7790
TEST_SNIPPET = "std.assertEqual(({ x: 1, y: self.x } { x: 2 }).y, 2)"
@@ -89,6 +102,7 @@ MAKEDEPEND_SRCS = \
89102
core/libjsonnet_test_snippet.c \
90103
core/libjsonnet_test_file.c
91104

105+
.PHONY: depend
92106
depend:
93107
makedepend -f- $(LIB_SRC) $(MAKEDEPEND_SRCS) > Makefile.depend
94108

@@ -141,7 +155,15 @@ core/%.jsonnet.h: stdlib/%.jsonnet
141155
| tr "\n" "," ) && echo "0") > $@
142156
echo >> $@
143157

158+
.PHONY: clean
144159
clean:
145-
rm -vf */*~ *~ .*~ */.*.swp .*.swp $(ALL) *.o core/*.jsonnet.h Make.depend
160+
rm -vf */*~ *~ .*~ */.*.swp .*.swp $(ALL) *.o core/*.jsonnet.h Makefile.depend
161+
162+
.PHONY: install
163+
install: all
164+
mkdir -p $(DESTDIR)$(bindir) $(DESTDIR)$(libdir) $(DESTDIR)$(includedir)
165+
$(INSTALL) jsonnet $(DESTDIR)$(bindir)/jsonnet
166+
$(INSTALL) libjsonnet.so $(DESTDIR)$(libdir)/libjsonnet.so
167+
$(INSTALL_DATA) include/libjsonnet.h $(DESTDIR)$(includedir)/libjsonnet.h
146168

147169
-include Makefile.depend

0 commit comments

Comments
 (0)