|  | 
| 1 |  | -ifdef BUILDDIR | 
| 2 |  | -# bit of a hack, but we want to make sure BUILDDIR directory structure | 
| 3 |  | -# is correct before any commands | 
| 4 |  | -$(if $(findstring n,$(MAKEFLAGS)),, $(shell mkdir -p \ | 
| 5 |  | -	$(BUILDDIR)/ \ | 
| 6 |  | -	$(BUILDDIR)/bd \ | 
| 7 |  | -	$(BUILDDIR)/runners \ | 
| 8 |  | -	$(BUILDDIR)/tests \ | 
| 9 |  | -	$(BUILDDIR)/benches)) | 
| 10 |  | -endif | 
|  | 1 | +# overrideable build dir, default is in-place | 
| 11 | 2 | BUILDDIR ?= . | 
| 12 |  | - | 
| 13 | 3 | # overridable target/src/tools/flags/etc | 
| 14 | 4 | ifneq ($(wildcard test.c main.c),) | 
| 15 | 5 | TARGET ?= $(BUILDDIR)/lfs | 
| @@ -163,6 +153,18 @@ TESTFLAGS  += --perf-path="$(PERF)" | 
| 163 | 153 | BENCHFLAGS += --perf-path="$(PERF)" | 
| 164 | 154 | endif | 
| 165 | 155 | 
 | 
|  | 156 | +# this is a bit of a hack, but we want to make sure the BUILDDIR | 
|  | 157 | +# directory structure is correct before we run any commands | 
|  | 158 | +ifneq ($(BUILDDIR),.) | 
|  | 159 | +$(if $(findstring n,$(MAKEFLAGS)),, $(shell mkdir -p \ | 
|  | 160 | +	$(addprefix $(BUILDDIR)/,$(dir \ | 
|  | 161 | +		$(SRC) \ | 
|  | 162 | +		$(TESTS) \ | 
|  | 163 | +		$(TEST_SRC) \ | 
|  | 164 | +		$(BENCHES) \ | 
|  | 165 | +		$(BENCH_SRC))))) | 
|  | 166 | +endif | 
|  | 167 | + | 
| 166 | 168 | 
 | 
| 167 | 169 | # commands | 
| 168 | 170 | 
 | 
| @@ -514,6 +516,9 @@ $(BUILDDIR)/runners/bench_runner: $(BENCH_OBJ) | 
| 514 | 516 | $(BUILDDIR)/%.o $(BUILDDIR)/%.ci: %.c | 
| 515 | 517 | 	$(CC) -c -MMD $(CFLAGS) $< -o $(BUILDDIR)/$*.o | 
| 516 | 518 | 
 | 
|  | 519 | +$(BUILDDIR)/%.o $(BUILDDIR)/%.ci: $(BUILDDIR)/%.c | 
|  | 520 | +	$(CC) -c -MMD $(CFLAGS) $< -o $(BUILDDIR)/$*.o | 
|  | 521 | + | 
| 517 | 522 | $(BUILDDIR)/%.s: %.c | 
| 518 | 523 | 	$(CC) -S $(CFLAGS) $< -o $@ | 
| 519 | 524 | 
 | 
|  | 
0 commit comments