aboutsummaryrefslogtreecommitdiff
path: root/rules.mk
blob: d4c7bf993fca59290fd230613e2b8febcfacc0f5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# Standard housekeeping
.PHONY: 	all debug release clean target install
.SUFFIXES:

all: targets

debug: CC := clang
debug: CFLAGS += -DDEBUG -g -fsanitize=address
debug: INCS := -I $(INC_DIR)
debug: ELIBS := -fsanitize=address
debug: STATIC :=
debug: CINIT :=
debug: CFINI :=
debug: targets

release: CFLAGS += -O3 -mtune=native -flto -ffast-math #-DNDEBUG
release: targets

# Targets & array of sources & intermediates
SRCS :=
OBJS :=
DEPS :=

LIBS :=
BINS :=
UNTS :=

GENS :=

# Iterate through directory tree
DIR := sys
include $(DIR)/rules.mk

# DIR := src
# include $(DIR)/rules.mk

# Generic rules
%.a: %.o
	$(ARCHIVE)

%: %.o
	$(LINK)

$(OBJ_DIR)/%.o: %.c
	$(COMPILE)

$(OBJ_DIR)/%.o: %.s
	$(ASSEMBLE)

$(OBJ_DIR)/%: %.c
	$(COMPLNK)

targets: $(LIBS) $(BINS) $(UNTS)

clean:
	@echo removing object files
	@rm -f $(OBJS)
	@echo removing dependency files
	@rm -f $(DEPS)
	@echo removing generated source files 
	@rm -f $(GENS)
	@echo removing libraries
	@rm -f $(LIBS)
	@echo removing binaries
	@rm -f $(BINS)
	@echo removing unit tests
	@rm -f $(UNTS)

install: targets
	@echo installing executables
	@if [ -n $$BINS ]; then\
		install $(BINS) $(BIN_DIR); \
	fi
	@echo installing libraries
	@if [ -n $$LIBS ]; then\
		install $(LIBS) $(LIB_DIR); \
	fi
	@echo installing terminfo
	@tic -sx sys/cmd/term/term.info

database:
	compiledb make -j4