summaryrefslogtreecommitdiff
path: root/Makefile
blob: 44eadf75c65dc21821d91eaaec7c7d57ac90968b (plain)
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# Makefile - mkpkg for rawnix.org (version: see MKPKG_VERSION in util.h)
# https://rawnix.org

CC      = clang
CFLAGS  = -O2 -pipe -march=x86-64-v3 \
          -fstack-protector-strong \
          -D_FORTIFY_SOURCE=2 \
          -std=c99 \
          -D_POSIX_C_SOURCE=200809L \
          -D_XOPEN_SOURCE=700 \
          -Wall -Wextra \
          -Wno-format-truncation \
          -I.

LDFLAGS = -Wl,-O1 -Wl,--as-needed

PREFIX  = /usr
BINDIR  = $(PREFIX)/bin
MANDIR  = $(PREFIX)/share/man
ETCDIR  = /etc

# ── Shared objects ─────────────────────────────────────────────────────

UTIL_OBJ    = util.o
DB_OBJ      = db.o
ARCHIVE_OBJ = archive.o
META_OBJ    = meta.o
LB_CMN_OBJ  = lockbox_common.o

# ── Per-binary objects ─────────────────────────────────────────────────

MKPKG_OBJS = \
    mkpkg.o parser.o download.o checksum.o signature.o \
    build.o footprint.o lockbox.o \
    $(LB_CMN_OBJ) $(ARCHIVE_OBJ) $(DB_OBJ) $(UTIL_OBJ)

LBEXEC_OBJS  = lbexec.o $(LB_CMN_OBJ) $(UTIL_OBJ)
ADDPKG_OBJS  = addpkg.o $(DB_OBJ) $(ARCHIVE_OBJ) $(META_OBJ) $(UTIL_OBJ)
DELPKG_OBJS  = delpkg.o $(DB_OBJ) $(ARCHIVE_OBJ) $(META_OBJ) $(UTIL_OBJ)
INFOPKG_OBJS = infopkg.o $(DB_OBJ) $(ARCHIVE_OBJ) $(UTIL_OBJ)
PORTS_OBJS   = ports.o $(DB_OBJ) $(ARCHIVE_OBJ) parser.o $(UTIL_OBJ)
BULK_OBJS    = bulk.o $(DB_OBJ) $(UTIL_OBJ)

BINS = mkpkg lbexec addpkg delpkg infopkg ports bulk

# ── Targets ────────────────────────────────────────────────────────────

all: $(BINS)

mkpkg:   $(MKPKG_OBJS)  ; $(CC) $(LDFLAGS) -o $@ $^ -lssl -lcrypto
lbexec:  $(LBEXEC_OBJS) ; $(CC) $(LDFLAGS) -o $@ $^
addpkg:  $(ADDPKG_OBJS) ; $(CC) $(LDFLAGS) -o $@ $^
delpkg:  $(DELPKG_OBJS) ; $(CC) $(LDFLAGS) -o $@ $^
infopkg: $(INFOPKG_OBJS); $(CC) $(LDFLAGS) -o $@ $^
ports:   $(PORTS_OBJS)  ; $(CC) $(LDFLAGS) -o $@ $^
bulk:    $(BULK_OBJS)   ; $(CC) $(LDFLAGS) -o $@ $^

# ── Compile rule ───────────────────────────────────────────────────────

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

# ── Install ────────────────────────────────────────────────────────────

install: $(BINS)
	install -d $(DESTDIR)$(BINDIR)
	install -m 755 $(BINS) $(DESTDIR)$(BINDIR)
	install -d $(DESTDIR)$(ETCDIR)
	install -m 644 etc/mkpkg.conf $(DESTDIR)$(ETCDIR)/mkpkg.conf
	install -d $(DESTDIR)$(ETCDIR)/ports
	install -m 644 etc/ports.rsync.inactive  $(DESTDIR)$(ETCDIR)/ports/ports.rsync.inactive
	install -m 644 etc/community.git.inactive $(DESTDIR)$(ETCDIR)/ports/community.git.inactive
	install -d $(DESTDIR)$(MANDIR)/man5
	install -m 644 man/man5/MAKEPKG.5         $(DESTDIR)$(MANDIR)/man5/MAKEPKG.5
	install -m 644 man/man5/mkpkg.conf.5   $(DESTDIR)$(MANDIR)/man5/mkpkg.conf.5
	install -d $(DESTDIR)$(MANDIR)/man7
	install -m 644 man/man7/lockbox.7         $(DESTDIR)$(MANDIR)/man7/lockbox.7
	install -d $(DESTDIR)$(MANDIR)/man8
	install -m 644 man/man8/mkpkg.8           $(DESTDIR)$(MANDIR)/man8/mkpkg.8
	install -m 644 man/man8/addpkg.8          $(DESTDIR)$(MANDIR)/man8/addpkg.8
	install -m 644 man/man8/delpkg.8          $(DESTDIR)$(MANDIR)/man8/delpkg.8
	install -m 644 man/man8/infopkg.8         $(DESTDIR)$(MANDIR)/man8/infopkg.8
	install -m 644 man/man8/ports.8           $(DESTDIR)$(MANDIR)/man8/ports.8
	install -m 644 man/man8/bulk.8            $(DESTDIR)$(MANDIR)/man8/bulk.8
	install -m 644 man/man8/lbexec.8          $(DESTDIR)$(MANDIR)/man8/lbexec.8

# ── Lint ───────────────────────────────────────────────────────────────

MANPAGES = man/man5/MAKEPKG.5 man/man5/mkpkg.conf.5 man/man7/lockbox.7 \
           man/man8/mkpkg.8 man/man8/addpkg.8 man/man8/delpkg.8 \
           man/man8/infopkg.8 man/man8/ports.8 man/man8/bulk.8 \
           man/man8/lbexec.8

lint:
	mandoc -Tlint $(MANPAGES)

# ── Clean ──────────────────────────────────────────────────────────────

clean:
	rm -f *.o $(BINS)

.PHONY: all install lint clean