about summary refs log tree commit diff
path: root/Makefile
blob: 25d8394bf46f662b5fbbdd1a3f5abb4edf7f27ca (plain) (blame)
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
CC ?= clang 
INSTALLPATH ?= /usr/bin

CFLAGS += -Wall -Werror
LDFLAGS += -lm

BIN = ministat 
SRC = $(BIN).c

# No user serviceable parts below this line.
OBJS = $(addprefix $(OBJ), $(SRC:.c=.o))
DEPS = $(addsuffix .depend, $(OBJS))
OBJ  = obj

all: obj $(OBJ)/$(BIN)

obj:
	-mkdir obj

$(OBJ)$/(BIN): $(OBJS)
	$(CC) -o $@ $^ ${LDFLAGS}


$(OBJ)/%.o: %.c
	@echo "Generating $@.depend"
	@$(CC) $(CFLAGS) -MM $< | \
	sed 's,$*\.o[ :]*,$@ $@.depend : ,g' >> $@.depend
	$(CC) $(CFLAGS) -o $@ -c $<

depend:
	@echo "Dependencies are automatically generated."

install:
	install -m 0755 $(OBJ)/$(BIN) $(INSTALLPATH)

clean:
	-rm -rf $(BIN) obj *.core

.PHONY: all depend install clean

-include $(DEPS)