forked from wkz/phytool
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
42 lines (32 loc) · 1000 Bytes
/
Makefile
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
.PHONY: all clean install dist
# Top directory for building complete system, fall back to this directory
ROOTDIR ?= $(shell pwd)
VERSION = 2
NAME = phytool
PKG = $(NAME)-$(VERSION)
ARCHIVE = $(PKG).tar.xz
APPLETS = mv6tool
PREFIX ?= /usr/local/
CFLAGS ?= -Wall -Wextra -Werror
LDLIBS =
objs = $(patsubst %.c, %.o, $(wildcard *.c))
hdrs = $(wildcard *.h)
%.o: %.c $(hdrs) Makefile
@printf " CC $(subst $(ROOTDIR)/,,$(shell pwd)/$@)\n"
@$(CC) $(CFLAGS) -c $< -o $@
phytool: $(objs)
@printf " CC $(subst $(ROOTDIR)/,,$(shell pwd)/$@)\n"
@$(CC) $(LDFLAGS) $(LDLIBS) -o $@ $^
all: phytool
clean:
@rm -f *.o
@rm -f $(TARGET)
dist:
@echo "Creating $(ARCHIVE), with $(ARCHIVE).md5 in parent dir ..."
@git archive --format=tar --prefix=$(PKG)/ v$(VERSION) | xz >../$(ARCHIVE)
@(cd .. && md5sum $(ARCHIVE) > $(ARCHIVE).md5)
install: phytool
@cp phytool $(DESTDIR)/$(PREFIX)/bin/
@for app in $(APPLETS); do \
ln -sf phytool $(DESTDIR)/$(PREFIX)/bin/$$app; \
done