Add debug, release and install targets.

This commit is contained in:
Tor Andersson
2014-03-20 12:37:13 +01:00
parent 48aed4bbb6
commit 40d4dff589

View File

@@ -2,11 +2,28 @@ SRCS := $(wildcard js*.c utf*.c regex.c)
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/mujs: build/main.o build/libmujs.a
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 @@ test: build/js
clean:
rm -f astnames.h opnames.h one.c build/*
.PHONY: default test clean
.PHONY: default test clean install debug release