shrub/pkg/urbit/Makefile

106 lines
2.7 KiB
Makefile
Raw Normal View History

2019-03-05 03:43:53 +03:00
include config.mk
jets = jets/tree.c $(wildcard jets/*/*.c)
noun = $(wildcard noun/*.c)
vere = $(wildcard vere/*.c)
daemon = $(wildcard daemon/*.c)
worker = $(wildcard worker/*.c)
2019-03-05 03:43:53 +03:00
common = $(jets) $(noun) $(vere)
headers = $(shell find include -type f) include/ca-bundle.h include/ivory.h
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)
all_exes = ./build/mug_tests ./build/jam_tests ./build/hashtable_tests \
./build/urbit ./build/urbit-worker
2019-03-05 03:43:53 +03:00
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
ifeq ($(SSL_CERT_FILE),)
$(error SSL_CERT_FILE is undefined)
endif
2019-04-26 01:23:53 +03:00
ifeq ($(IVORY),)
$(error IVORY is undefined)
endif
2019-03-05 03:43:53 +03:00
################################################################################
.PHONY: all test clean mkproper
2019-03-05 03:43:53 +03:00
################################################################################
all: $(all_exes)
test: build/hashtable_tests build/jam_tests build/mug_tests
./build/hashtable_tests
./build/jam_tests
./build/mug_tests
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 include/ca-bundle.h include/ivory.h
2019-03-05 03:43:53 +03:00
################################################################################
include/ca-bundle.h:
@echo XXD -i $(SSL_CERT_FILE)
@cat $(SSL_CERT_FILE) > include/ca-bundle.crt
@xxd -i include/ca-bundle.crt > include/ca-bundle.h
@rm include/ca-bundle.crt
include/ivory.h:
@echo XXD -i $(IVORY)
@# heuristics to confirm the ivory pill is valid
@#
@# greater than 10KB
@# first 7 bytes != "version" (start of an lfs pointer)
@# XX move these to a nix build that produces the ivory pill
@#
@test "`du -k $(IVORY) | cut -f1`" -gt 10
@test "`cat $(IVORY) | head -c 7`" != "version"
@cat $(IVORY) > u3_Ivory.pill
@xxd -i u3_Ivory.pill > include/ivory.h
@rm u3_Ivory.pill
build/hashtable_tests: $(common_objs) tests/hashtable_tests.o
@echo CC -o $@
@mkdir -p ./build
@$(CC) $^ $(LDFLAGS) -o $@
build/jam_tests: $(common_objs) tests/jam_tests.o
2019-05-12 12:29:13 +03:00
@echo CC -o $@
@mkdir -p ./build
2019-05-12 12:29:13 +03:00
@$(CC) $^ $(LDFLAGS) -o $@
build/mug_tests: $(common_objs) tests/mug_tests.o
@echo CC -o $@
@mkdir -p ./build
@$(CC) $^ $(LDFLAGS) -o $@
build/urbit: $(common_objs) $(daemon_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 $@
build/urbit-worker: $(common_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 $@
%.o: %.c $(headers)
@echo CC $<
@$(CC) -I./include $(CFLAGS) -c $< -o $@
tags: $(all_srcs) $(headers)
ctags $^