2012-11-17 10:00:32 +00:00
|
|
|
DESTDIR :=
|
2012-12-20 00:22:22 +00:00
|
|
|
PREFIX := /usr/local
|
|
|
|
BINDIR := $(PREFIX)/bin
|
2012-12-06 17:57:56 +00:00
|
|
|
DATADIR := $(PREFIX)/share
|
2012-12-20 00:22:22 +00:00
|
|
|
MANDIR := $(DATADIR)/man
|
|
|
|
|
2012-12-20 08:49:14 +00:00
|
|
|
UNAME ?= $(shell uname)
|
|
|
|
CYGWIN = $(findstring CYGWIN, $(UNAME))
|
|
|
|
MINGW = $(findstring MINGW32, $(UNAME))
|
2012-11-17 10:00:32 +00:00
|
|
|
|
2012-04-25 14:20:38 +00:00
|
|
|
CC ?= clang
|
2012-12-28 08:52:13 +00:00
|
|
|
CFLAGS += -Wall -Wextra -I. -pedantic-errors -fno-strict-aliasing -fsigned-char
|
2012-06-07 14:57:48 +00:00
|
|
|
#turn on tons of warnings if clang is present
|
2012-12-20 00:22:22 +00:00
|
|
|
# but also turn off the STUPID ONES
|
2012-06-07 14:57:48 +00:00
|
|
|
ifeq ($(CC), clang)
|
2012-11-22 20:46:38 +00:00
|
|
|
CFLAGS += \
|
2012-06-07 15:18:04 +00:00
|
|
|
-Weverything \
|
|
|
|
-Wno-padded \
|
2012-11-22 20:46:38 +00:00
|
|
|
-Wno-format-nonliteral \
|
|
|
|
-Wno-disabled-macro-expansion \
|
2012-11-23 06:26:19 +00:00
|
|
|
-Wno-conversion \
|
2012-12-22 08:22:50 +00:00
|
|
|
-Wno-missing-prototypes \
|
|
|
|
-Wno-float-equal \
|
|
|
|
-Wno-cast-align
|
2012-06-07 14:57:48 +00:00
|
|
|
endif
|
2012-08-22 10:38:16 +00:00
|
|
|
ifeq ($(track), no)
|
|
|
|
CFLAGS += -DNOTRACK
|
|
|
|
endif
|
|
|
|
|
2012-12-23 09:44:03 +00:00
|
|
|
OBJ_D = util.o code.o ast.o ir.o conout.o ftepp.o opts.o file.o utf8.o
|
2012-12-23 06:05:22 +00:00
|
|
|
OBJ_T = test.o util.o conout.o file.o
|
|
|
|
OBJ_C = main.o lexer.o parser.o file.o
|
|
|
|
OBJ_X = exec-standalone.o util.o conout.o file.o
|
2012-04-09 10:42:06 +00:00
|
|
|
|
2012-12-20 00:22:22 +00:00
|
|
|
ifneq ("$(CYGWIN)", "")
|
|
|
|
#nullify the common variables that
|
|
|
|
#most *nix systems have (for windows)
|
|
|
|
PREFIX :=
|
|
|
|
BINDIR :=
|
|
|
|
DATADIR :=
|
|
|
|
MANDIR :=
|
|
|
|
QCVM = qcvm.exe
|
|
|
|
GMQCC = gmqcc.exe
|
|
|
|
TESTSUITE = testsuite.exe
|
|
|
|
else
|
2012-12-20 08:51:29 +00:00
|
|
|
ifneq ("$(MINGW)", "")
|
2012-12-20 00:22:22 +00:00
|
|
|
#nullify the common variables that
|
|
|
|
#most *nix systems have (for windows)
|
|
|
|
PREFIX :=
|
|
|
|
BINDIR :=
|
|
|
|
DATADIR :=
|
|
|
|
MANDIR :=
|
|
|
|
QCVM = qcvm.exe
|
|
|
|
GMQCC = gmqcc.exe
|
|
|
|
TESTSUITE = testsuite.exe
|
|
|
|
else
|
2012-12-28 08:59:41 +00:00
|
|
|
#arm support for linux .. we need to allow unaligned accesses
|
|
|
|
#to memory otherwise we just segfault everywhere
|
|
|
|
ifneq (, $(findstring $(shell uname -m), "arm"))
|
|
|
|
CFLAGS += -munaligned-access
|
|
|
|
endif
|
|
|
|
|
2012-12-20 00:22:22 +00:00
|
|
|
QCVM = qcvm
|
|
|
|
GMQCC = gmqcc
|
|
|
|
TESTSUITE = testsuite
|
|
|
|
endif
|
|
|
|
endif
|
2012-11-17 10:00:55 +00:00
|
|
|
|
2012-12-20 00:22:22 +00:00
|
|
|
#standard rules
|
2012-12-18 15:58:21 +00:00
|
|
|
default: all
|
2012-04-09 10:42:06 +00:00
|
|
|
%.o: %.c
|
2012-04-10 01:32:24 +00:00
|
|
|
$(CC) -c $< -o $@ $(CFLAGS)
|
2012-04-09 10:42:06 +00:00
|
|
|
|
2012-06-27 12:56:43 +00:00
|
|
|
exec-standalone.o: exec.c
|
|
|
|
$(CC) -c $< -o $@ $(CFLAGS) -DQCVM_EXECUTOR=1
|
|
|
|
|
2012-12-20 00:22:22 +00:00
|
|
|
$(QCVM): $(OBJ_X)
|
2012-08-23 08:24:17 +00:00
|
|
|
$(CC) -o $@ $^ $(CFLAGS) -lm
|
2012-04-29 20:54:05 +00:00
|
|
|
|
2012-12-20 00:22:22 +00:00
|
|
|
$(GMQCC): $(OBJ_C) $(OBJ_D)
|
2012-11-10 20:53:37 +00:00
|
|
|
$(CC) -o $@ $^ $(CFLAGS)
|
2012-04-29 20:54:05 +00:00
|
|
|
|
2012-12-20 00:22:22 +00:00
|
|
|
$(TESTSUITE): $(OBJ_T)
|
2012-11-17 02:54:30 +00:00
|
|
|
$(CC) -o $@ $^ $(CFLAGS)
|
|
|
|
|
2012-12-20 00:22:22 +00:00
|
|
|
all: $(GMQCC) $(QCVM) $(TESTSUITE)
|
2012-05-03 20:54:34 +00:00
|
|
|
|
2012-11-21 20:31:41 +00:00
|
|
|
check: all
|
2012-12-20 00:22:22 +00:00
|
|
|
@ ./$(TESTSUITE)
|
2012-11-21 20:27:41 +00:00
|
|
|
|
2012-04-09 10:42:06 +00:00
|
|
|
clean:
|
2012-12-20 00:22:22 +00:00
|
|
|
rm -f *.o $(GMQCC) $(QCVM) $(TESTSUITE) *.dat
|
2012-11-17 10:00:32 +00:00
|
|
|
|
2012-12-20 00:22:22 +00:00
|
|
|
# deps
|
2012-12-20 15:28:35 +00:00
|
|
|
$(OBJ_D) $(OBJ_C) $(OBJ_X): gmqcc.h opts.def
|
2012-12-20 00:22:22 +00:00
|
|
|
main.o: lexer.h
|
2012-11-17 09:43:50 +00:00
|
|
|
parser.o: ast.h lexer.h
|
2012-12-22 19:43:59 +00:00
|
|
|
lexer.o: lexer.h
|
2012-12-20 00:22:22 +00:00
|
|
|
ast.o: ast.h ir.h
|
|
|
|
ir.o: ir.h
|
2012-11-17 10:00:32 +00:00
|
|
|
|
2012-12-20 00:22:22 +00:00
|
|
|
#install rules
|
2012-12-06 17:57:56 +00:00
|
|
|
install: install-gmqcc install-qcvm install-doc
|
2012-12-20 00:22:22 +00:00
|
|
|
install-gmqcc: $(GMQCC)
|
2012-12-06 17:57:56 +00:00
|
|
|
install -d -m755 $(DESTDIR)$(BINDIR)
|
2012-12-20 00:22:22 +00:00
|
|
|
install -m755 $(GMQCC) $(DESTDIR)$(BINDIR)/gmqcc
|
|
|
|
install-qcvm: $(QCVM)
|
2012-12-06 17:57:56 +00:00
|
|
|
install -d -m755 $(DESTDIR)$(BINDIR)
|
2012-12-20 00:22:22 +00:00
|
|
|
install -m755 $(QCVM) $(DESTDIR)$(BINDIR)/qcvm
|
2012-12-06 17:57:56 +00:00
|
|
|
install-doc:
|
|
|
|
install -d -m755 $(DESTDIR)$(MANDIR)/man1
|
|
|
|
install -m755 doc/gmqcc.1 $(DESTDIR)$(MANDIR)/man1/
|
2012-12-18 15:03:48 +00:00
|
|
|
install -m755 doc/qcvm.1 $(DESTDIR)$(MANDIR)/man1/
|