aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--Makefile30
-rwxr-xr-xconfigure13
2 files changed, 35 insertions, 8 deletions
diff --git a/Makefile b/Makefile
index 7543ed8..762832a 100644
--- a/Makefile
+++ b/Makefile
@@ -1,3 +1,5 @@
+OUT?=antcc
+BUILDDIR?=build
SRC=main.c io.c mem.c c/c.c c/lex.c c/eval.c c/builtin.c type.c targ.c \
ir/ir.c ir/builder.c ir/fold.c ir/dump.c ir/ssa.c ir/cfg.c ir/intrin.c ir/abi0.c ir/mem2reg.c ir/regalloc.c ir/simpl.c ir/stack.c \
ir/cse.c ir/inliner.c \
@@ -5,13 +7,16 @@ SRC=main.c io.c mem.c c/c.c c/lex.c c/eval.c c/builtin.c type.c targ.c \
aarch64/aapcs.c aarch64/isel.c aarch64/emit.c \
obj/obj.c obj/elf.c \
embedfilesdir.c
-CFLAGS=-Wall -std=c11 -pedantic
OBJ=$(patsubst %.c,build/%.o,$(SRC))
DEP=$(OBJ:.o=.d)
-BUILDDIR?=build
-OUT?=antcc
-all: CFLAGS += -g
+CFLAGS=-Wall -std=c11 -pedantic
+PREFIX=/usr/local
+BINDIR=$(PREFIX)/bin
+
+-include config.mk
+
+all: CFLAGS += -g -Og
all: $(OUT)
opt: CFLAGS += -g -O2
@@ -24,13 +29,24 @@ dbg: $(OUT)
$(OUT): $(OBJ)
$(CC) $(CFLAGS) -o $@ $(OBJ)
-$(BUILDDIR)/%.o: %.c common.h
+hostconfig.h:
+ ./configure
+
+$(BUILDDIR)/%.o: %.c hostconfig.h
@mkdir -p `dirname $@`
- $(CC) $(CFLAGS) -MMD -MP -MT $@ -MF $(BUILDDIR)/$*.d -c -o $@ $<
+ @cc $(CFLAGS) -MMD -MP -fsyntax-only -MF $(BUILDDIR)/$*.d -MT $@ $< #depfiles
+ $(CC) $(CFLAGS) -c -o $@ $<
clean:
$(RM) -r $(BUILDDIR)/ test/build/ $(OUT) *.o a.out
-.PHONY: clean
+clean-config: clean
+ $(RM) -r config.mk hostconfig.h
+
+install: $(OUT)
+ @mkdir -p "$(DESTDIR)$(BINDIR)"
+ install -m755 $(OUT) -T "$(DESTDIR)$(BINDIR)/antcc"
+
+.PHONY: clean clean-config install
-include $(DEP)
diff --git a/configure b/configure
index d9daa20..f48555b 100755
--- a/configure
+++ b/configure
@@ -14,12 +14,14 @@ Options:
--help Print this help mesage
--host=target-triple $host
--cc=cc C compiler [cc]
+ --prefix=PREFIX Installation path [/usr/local]
--sysroot=/path System root [/usr]
--includedir="/a/b",... System include dirs
EOF
}
sysroot=/usr
+prefix=/usr/local
host=
for arg ; do
@@ -29,6 +31,9 @@ for arg ; do
--includedir=*) host_include_dirs=${arg#*=} ;;
CC=*) CC=${arg#*=} ;;
--cc=*) CC=${arg#*=} ;;
+ CFLAGS=*) CFLAGS=${arg#*=} ;;
+ --cflags=*) CFLAGS=${arg#*=} ;;
+ --prefix=*) prefix=$(sh -c "echo ${arg#*=}") ;;
--help) prihelp ; exit ;;
*) die "$0: unknown option '$arg'"
esac
@@ -112,4 +117,10 @@ echo "/** GENERATED WITH $0 $@ **/
#define HOST_CC \"$CC\"
#endif // HOSTCONFIG_H_" > hostconfig.h
-echo config written to hostconfig.h
+
+echo "# GENERATED WITH $0 $@
+PREFIX = $prefix
+CC = $CC
+CFLAGS = ${CFLAGS:--Wall -std=c11 -pedantic}" > config.mk
+
+echo config written to hostconfig.h, config.mk