-
Notifications
You must be signed in to change notification settings - Fork 128
/
Copy pathMakefile
53 lines (40 loc) · 1.16 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
49
50
51
52
53
# for portability.
SHELL = /bin/sh
CC = gcc
# compile flags.
CFLAGS = -g -std=c99 -pedantic -Wall -Wextra -Werror -march=native -O2 -fwhole-program -flto
TARGET = icmptunnel
MANPAGE = icmptunnel.8
SOURCES = $(shell echo src/*.c)
HEADERS = $(shell echo src/*.h)
OBJECTS = $(SOURCES:.c=.o)
VERSION = 0.1-beta
# installation paths.
PREFIX = $(DESTDIR)/usr/local
BINDIR = $(PREFIX)/sbin
MANDIR = $(PREFIX)/share/man/man8
# standard targets.
all: $(TARGET)
$(TARGET): $(OBJECTS)
@echo "[LD] $@"
@$(CC) $(CFLAGS) -o $(TARGET) $(OBJECTS)
man:
@(cd man; gzip < $(MANPAGE) > $(MANPAGE).gz)
install: $(TARGET) man
@install -D -m 755 $(TARGET) $(BINDIR)/$(TARGET)
@install -D -m 744 man/$(MANPAGE).gz $(MANDIR)/$(MANPAGE).gz
install-strip: $(TARGET) man
@install -D -m 755 -s $(TARGET) $(BINDIR)/$(TARGET)
@install -D -m 744 man/$(MANPAGE).gz $(MANDIR)/$(MANPAGE).gz
uninstall:
@$(RM) $(BINDIR)/$(TARGET)
@$(RM) $(MANDIR)/$(MANPAGE).gz
clean:
@$(RM) $(OBJECTS)
distclean: clean
@$(RM) $(TARGET)
@(cd man; $(RM) $(MANPAGE).gz)
%.o: %.c $(HEADERS)
@echo "[CC] $<"
@$(CC) $(CFLAGS) -c -o $@ $<
.PHONY: all man install install-strip uninstall clean distclean