blob: ffed7e821466fad19d31521f25d87e7716e31f2a (
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
42
|
CC ?= clang
PREFIX ?= /usr
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 -d $(PREFIX)/bin
install -m 0755 $(OBJ)/$(BIN) $(PREFIX)/bin/$(BIN)
clean:
-rm -rf $(BIN) obj *.core
.PHONY: all depend install clean
-include $(DEPS)
|