ref: 40d4dff58996cb9fcede20f57495e5cd3845f91e
parent: 48aed4bbb6fa2fba3da9fcf4bc6bf8e81bec48e9
author: Tor Andersson <tor@ccxvii.net>
date: Thu Mar 20 08:37:13 EDT 2014
Add debug, release and install targets.
--- a/Makefile
+++ b/Makefile
@@ -2,11 +2,28 @@
HDRS := $(wildcard js*.h mujs.h utf.h regex.h)
OBJS := $(SRCS:%.c=build/%.o)
+prefix ?= /usr/local
+bindir ?= $(prefix)/bin
+incdir ?= $(prefix)/include
+libdir ?= $(prefix)/lib
+
CC := clang
-CFLAGS := -std=c99 -pedantic -Wall -Wextra -Wunreachable-code -Wno-unused-parameter -g
+CFLAGS := -std=c99 -pedantic -Wall -Wextra -Wunreachable-code -Wno-unused-parameter
+ifeq "$(build)" "debug"
+CFLAGS += -g
+else
+CFLAGS += -O3
+endif
+
default: build build/mujs build/mujsone
+debug:
+ $(MAKE) build=debug
+
+release:
+ $(MAKE) build=release
+
astnames.h: jsparse.h
grep '\(AST\|EXP\|STM\)_' jsparse.h | sed 's/^[ \t]*\(AST_\)\?/"/;s/,.*/",/' | tr A-Z a-z > $@
@@ -33,8 +50,13 @@
build/mujsone: build/main.o build/one.o
$(CC) -o $@ $^ -lm
-build/re: regex.c utf.c utftype.c
- $(CC) $(CFLAGS) -DTEST -o $@ $^
+install: release
+ install -d $(DESTDIR)$(incdir)
+ install -d $(DESTDIR)$(libdir)
+ install -d $(DESTDIR)$(bindir)
+ install -t $(DESTDIR)$(incdir) mujs.h
+ install -t $(DESTDIR)$(libdir) build/libmujs.a
+ install -t $(DESTDIR)$(bindir) build/mujs
tags: $(SRCS) main.c $(HDRS)
ctags $^
@@ -45,4 +67,4 @@
clean:
rm -f astnames.h opnames.h one.c build/*
-.PHONY: default test clean
+.PHONY: default test clean install debug release