summaryrefslogtreecommitdiff
path: root/GNUmakefile
blob: 4e6007a9b01a063de8c853897a9fcfa4a57e0fd8 (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
PREFIX ?= /usr/local
includedir ?= /include
bindir ?= /bin
mandir ?= /share/man/man1
docdir ?= /share/doc

MAKEFLAGS += --no-builtin-rules

WARNINGS = -Wall -Wextra -Wpedantic -Wformat=2 -Wstrict-aliasing=3 -Wstrict-overflow=5 -Wstack-usage=12500 \
           -Wfloat-equal -Wcast-align -Wpointer-arith -Wchar-subscripts -Warray-bounds=2 -Wno-unknown-warning-option

override CFLAGS ?= -g -O2 $(WANRINGS)
override CFLAGS += -std=c99
override CPPFLAGS ?= -D_FORTIFY_SOURCE=2
override CPPFLAGS += -D_DEFAULT_SOURCE

all: physfs-serve

%.a: %.c
        $(LINK.c) -c $(filter %.c,$^) $(LDLIBS) -o $@

libphysfs-serve.a: private override CPPFLAGS += $(shell pkg-config --cflags-only-I physfs)
libphysfs-serve.a: libphysfs-serve.h

physfs-serve: private override LDLIBS += $(shell pkg-config --libs physfs)
physfs-serve: libphysfs-serve.a physfs-serve.c
        $(LINK.c) $(filter %.c %.a,$^) $(LDLIBS) -o $@

install: all
        install -Dm 755 physfs-serve $(DESTDIR)$(PREFIX)$(bindir)/physfs-serve
        install -Dm 644 libphysfs-serve.a $(DESTDIR)$(PREFIX)$(libdir)/libphysfs-serve.a

clean:
        $(RM) physfs-serve libphysfs-serve.a