forked from Xfennec/progress
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
48 lines (47 loc) · 1.5 KB
/
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
43
44
45
46
47
48
OBJ = progress
CFLAGS ?= -g
override CFLAGS += -Wall -D_FILE_OFFSET_BITS=64
override LDFLAGS += -lm
UNAME := $(shell uname)
PKG_CONFIG ?= pkg-config
ifeq ($(UNAME), Linux)
ifeq (, $(shell which $(PKG_CONFIG) 2> /dev/null))
$(error "pkg-config command not found")
endif
ifeq (, $(shell $(PKG_CONFIG) ncursesw --libs 2> /dev/null))
$(error "ncurses package not found")
endif
override LDFLAGS += $(shell $(PKG_CONFIG) ncursesw --libs)
endif
ifeq ($(UNAME), Darwin)
override LDFLAGS += -lncurses
endif
ifeq ($(UNAME), FreeBSD)
override LDFLAGS += -lncurses -lprocstat
endif
PREFIX ?= /usr/local
BINDIR = $(PREFIX)/bin
MANDIR = $(PREFIX)/share/man/man1
ZSHDIR = $(PREFIX)/share/zsh/site-functions
$(OBJ) : progress.o sizes.o hlist.o
$(CC) -Wall $^ -o $@ $(LDFLAGS)
%.o : %.c
$(CC) $(CFLAGS) -c $^
clean :
rm -f *.o $(OBJ)
install : $(OBJ)
@echo "Installing program to $(DESTDIR)$(BINDIR) ..."
@mkdir -p $(DESTDIR)$(BINDIR)
@install -pm0755 $(OBJ) $(DESTDIR)$(BINDIR)/$(TARGET) || \
echo "Failed. Try "make PREFIX=~ install" ?"
@echo "Installing manpage to $(DESTDIR)$(MANDIR) ..."
@mkdir -p $(DESTDIR)$(MANDIR)
@install -pm0644 $(OBJ).1 $(DESTDIR)$(MANDIR)/ || \
echo "Failed. Try "make PREFIX=~ install" ?"
@echo "Installing zsh completion to $(DESTDIR)$(ZSHDIR) ..."
@install -Dpm0644 _$(OBJ) -t $(DESTDIR)$(ZSHDIR)/ || \
echo "Failed. Try "make PREFIX=~ install" ?"
uninstall :
@rm -f $(DESTDIR)$(BINDIR)/$(OBJ)
@rm -f $(DESTDIR)$(MANDIR)/$(OBJ).1
@rm -f $(DESTDIR)$(ZSHDIR)/_$(OBJ)