~laumann/C

ref: 74c6c80ca891acc54bb96e3aac560ca2ce1635e4 C/progress/Makefile -rw-r--r-- 1.0 KiB
74c6c80c — Thomas Bracht Laumann Jespersen Added help message and -h,--help option. 9 years ago
                                                                                
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
#### Definitions ####
# (using := means immediate binding)
CC      := gcc
CFLAGS  := -Wall -g
RM      := rm -rfv
MKDIR   := mkdir -v

BINDIR  := bin
BIN     := $(BINDIR)/use_progress

OBJDIR  := obj
OBJECTS := $(addprefix $(OBJDIR)/,\
		progress.o use_progress.o)

# Phony targets
.PHONY: clean help run compile

#### Target section ####
compile: $(BIN)

help:
	@echo "This progress bar is taken directly from git -- because I like it, and it serves"
	@echo "as a good exercise to see how some C code works. Run:"
	@echo ""
	@echo "  'make run'"
	@echo ""
	@echo "or"
	@echo ""
	@echo "  'make compile'  (default)"
	@echo ""
	@echo "to see an example program."


run: $(BIN)
	$<

$(BIN): $(OBJECTS) | $(BINDIR)
	$(CC) $(CFLAGS) -o $@ $(OBJECTS)

$(OBJDIR)/%.o: %.c
	$(CC) $(CFLAGS) -c $< -o $@

$(OBJECTS): progress.h git-compat-util.h bswap.h | $(OBJDIR)
$(OBJDIR) $(BINDIR): ; @$(MKDIR) $@

# Dependencies - difficult to express in this form
# progress.o: progress.h git-compat-util.h bswap.h
# use_progress.o: progress.h

clean:
	@$(RM) $(OBJDIR) $(BINDIR)