shrub/pkg/urbit/Makefile

83 lines
2.5 KiB
Makefile
Raw Normal View History

2019-03-05 03:43:53 +03:00
include config.mk
2021-06-03 00:59:08 +03:00
include $(foreach dir,$(compat),$(wildcard compat/$(dir)/*.mk))
2019-03-05 03:43:53 +03:00
jets = jets/tree.c $(wildcard jets/*/*.c)
noun = $(wildcard noun/*.c)
2020-07-29 01:52:32 +03:00
ur = $(wildcard ur/*.c)
vere = $(wildcard vere/*.c) $(wildcard vere/*/*.c)
daemon = $(wildcard daemon/*.c)
worker = $(wildcard worker/*.c)
tests = $(wildcard tests/*.c)
bench = $(wildcard bench/*.c)
2019-03-05 03:43:53 +03:00
2021-03-31 13:29:45 +03:00
compat := $(foreach dir,$(compat),$(wildcard compat/$(dir)/*.c))
common = $(jets) $(noun) $(ur) $(vere) $(compat)
headers = $(shell find include -type f)
2019-03-05 03:43:53 +03:00
common_objs = $(shell echo $(common) | sed 's/\.c/.o/g')
daemon_objs = $(shell echo $(daemon) | sed 's/\.c/.o/g')
worker_objs = $(shell echo $(worker) | sed 's/\.c/.o/g')
2019-03-05 03:43:53 +03:00
all_objs = $(common_objs) $(daemon_objs) $(worker_objs)
all_srcs = $(common) $(daemon) $(worker)
test_exes = $(shell echo $(tests) | sed 's/tests\//.\/build\//g' | sed 's/\.c//g')
bench_exes = $(shell echo $(bench) | sed 's/bench\//.\/build\//g' | sed 's/\.c//g')
2022-04-10 05:25:17 +03:00
all_exes = $(test_exes) $(bench_exes) ./build/urbit
2019-04-26 01:23:53 +03:00
# -Werror promotes all warnings that are enabled into errors (this is on)
# -Wall issues all types of errors. This is off (for now)
CFLAGS := $(CFLAGS)
2019-04-26 01:23:53 +03:00
2019-03-05 03:43:53 +03:00
################################################################################
2021-06-03 00:59:08 +03:00
.PHONY: all test clean mrproper
2019-03-05 03:43:53 +03:00
################################################################################
all: $(all_exes)
test: $(test_exes)
@FAIL=0; \
for x in $^; \
2021-12-26 22:48:04 +03:00
do echo $$'\n'"$$x" && ./$$x; \
if [ $$? != 0 ]; then FAIL=1; fi; \
done; \
if [ $$FAIL != 0 ]; then echo "\n" && exit 1; fi;
2019-03-05 03:43:53 +03:00
bench: $(bench_exes)
build/ur_bench
2019-03-05 03:43:53 +03:00
clean:
rm -f ./tags $(all_objs) $(all_exes)
2019-03-05 03:43:53 +03:00
mrproper: clean
rm -f config.mk include/config.h
2019-03-05 03:43:53 +03:00
################################################################################
build/ur_bench: $(common_objs) bench/ur_bench.o
@echo CC -o $@
@mkdir -p ./build
@$(CC) $^ $(LDFLAGS) -o $@
build/%_tests: $(common_objs) tests/%_tests.o
@echo CC -o $@
@mkdir -p ./build
@$(CC) $^ $(LDFLAGS) -o $@
2022-04-10 05:25:17 +03:00
build/urbit: $(common_objs) $(daemon_objs) $(worker_objs)
2019-03-05 03:43:53 +03:00
@echo CC -o $@
@mkdir -p ./build
2019-03-05 03:43:53 +03:00
@$(CC) $^ $(LDFLAGS) -o $@
# CCDEPS and CCEXTRA are empty except in MingW build,
# which uses them to inject a C source transform step
2021-06-03 01:45:50 +03:00
%.o: %.c $(headers) $(CCDEPS)
2019-03-05 03:43:53 +03:00
@echo CC $<
2021-06-03 01:45:50 +03:00
@$(CC) -I./include $(CFLAGS) $< $(CCEXTRA) -c -o $@
2019-03-05 03:43:53 +03:00
tags: $(all_srcs) $(headers)
ctags $^