-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
64 lines (44 loc) · 1.02 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
54
55
56
57
58
59
60
61
62
63
64
### Preliminaries ###
SHELL := /bin/sh
LIBNAME := trace
LIB := lib$(LIBNAME).so
SRC := $(wildcard *.c)
OBJ := $(SRC:.c=.o)
UNITS := $(OBJ:.o=)
### Building ###
CC := gcc -c
LD := ld
override CFLAGS += -Wall -Werror -fpic $(and $(DEBUG),-g)
override LDFLAGS += --fatal-warnings -shared
.PHONY: all
all: $(LIB)
$(LIB): $(OBJ)
$(LD) $(LDFLAGS) -o $@ $(OBJ)
%.o: %.c
$(CC) $(CFLAGS) -o $@ $<
execve.o: execve.c
$(CC) -DLIBNAME=$(LIBNAME) -DLIBDIR=$(PREFIX)/lib $(CFLAGS) -o $@ $<
### Testing ###
.PHONY: test
test:
cd tests && $(MAKE) LIB=$(abspath $(LIB)) UNITS='$(UNITS)' test
### Installation ###
INSTALL := /usr/bin/install -D
INSTALL_DATA := $(INSTALL) -m 644
INSTALL_PROGRAM := $(INSTALL)
PREFIX := /usr/local
LIBDIR := $(PREFIX)/lib
.PHONY: install
install:
$(INSTALL) $(LIB) $(LIBDIR)/$(LIB)
.PHONY: installcheck
installcheck:
cd tests && $(MAKE) LIB=$(LIBDIR)/$(LIB) test
### Cleanup ###
.PHONY: clean
clean:
rm -f $(OBJ) $(LIB)
cd tests && $(MAKE) clean
.PHONY: uninstall
uninstall:
rm -f $(LIBDIR)/$(LIB)