add the BUILD variable to the makefiles to control the build root
[libc-test] / src / math / Makefile
index 9199580..a8b2704 100644 (file)
@@ -1,13 +1,15 @@
 CFLAGS+=-g -pipe -std=c99 -D_POSIX_C_SOURCE=200809L -Wall -Wno-unused-function -Wno-missing-braces
-CFLAGS+=-Wno-unknown-pragmas -fno-builtin -frounding-math -D_GNU_SOURCE
+CFLAGS+=-Wno-unknown-pragmas -fno-builtin -frounding-math
+CFLAGS+=-D_GNU_SOURCE -O0
 LDFLAGS+=-g -lm
+BUILD?=.
 
 SRC=$(sort $(wildcard *.c))
-OBJ=$(SRC:.c=.o)
-BINOBJ=$(filter-out util.o,$(OBJ))
+OBJ=$(SRC:%.c=$(BUILD)/%.o)
+BINOBJ=$(filter-out $(BUILD)/util.o,$(OBJ))
 BIN=$(BINOBJ:.o=)
 
-include ../../config.mak
+-include ../../config.mak
 
 all: $(BIN)
 run: all
@@ -15,10 +17,15 @@ run: all
 clean:
        rm -f $(OBJ) $(BIN)
 
-$(BIN): util.o
-
-%.o: %.c sanity/%.h ucb/%.h crlibm/%.h special/%.h util.h
+$(BUILD):
+       mkdir -p $@
+$(BIN): $(BUILD)/util.o
+$(OBJ): util.h | $(BUILD)
+$(BUILD)/%.o: %.c
        $(CC) $(CFLAGS) -c -o $@ $<
 %: %.c
+
 %: %.o
        $(CC) $(LDFLAGS) -o $@ $^
+
+.PRECIOUS: $(OBJ)