-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathMakefile
71 lines (56 loc) · 1.69 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
65
66
67
68
69
70
71
PREFIX ?= /usr/local
CFLAGS := -O3 -std=c99 -Wall -Wextra -g -fPIC -I. $(CPPFLAGS)
LDFLAGS +=
CC := $(CROSS)gcc
AR := $(CROSS)ar
ifneq (,$(findstring mingw,$(CC)))
LIBSUF=.dll
EXESUF=.exe
SYSTEM=MINGW
else
LIBSUF=.so
LDFLAGS=-Wl,--version-script,obuparse.v
endif
all: libobuparse$(LIBSUF) libobuparse.a
clean:
@rm -fv *.so *.o *.a *.dll
@rm -fv tools/obudump$(EXESUF) tools/*.o
libobuparse.a: obuparse.o
$(AR) rcs $@ $^
libobuparse$(LIBSUF): obuparse.o
$(CC) $(LDFLAGS) -shared $^ -o $@
install: install-shared install-static
install-header:
@install -d $(PREFIX)
@install -d $(PREFIX)/include
@install -v obuparse.h $(PREFIX)/include
install-shared: libobuparse$(LIBSUF) install-header
@install -d $(PREFIX)/lib
ifneq ($(SYSTEM),MINGW)
@install -v libobuparse$(LIBSUF) $(PREFIX)/lib/libobuparse$(LIBSUF).1
@rm -fv $(PREFIX)/lib/libobuparse$(LIBSUF)
@ln -sv libobuparse$(LIBSUF).1 $(PREFIX)/lib/libobuparse$(LIBSUF)
else
@install -d $(PREFIX)/bin
@install -v libobuparse$(LIBSUF) $(PREFIX)/bin/libobuparse$(LIBSUF)
endif
install-static: libobuparse.a install-header
@install -d $(PREFIX)/lib
@install -v libobuparse.a $(PREFIX)/lib/libobuparse.a
uninstall:
@rm -fv $(PREFIX)/include/obuparse.h
@rm -fv $(PREFIX)/lib/libobuparse.a
ifneq ($(SYSTEM),MINGW)
@rm -fv $(PREFIX)/lib/libobuparse$(LIBSUF).1
@rm -fv $(PREFIX)/lib/libobuparse$(LIBSUF)
else
@rm -fv $(PREFIX)/bin/libobuparse$(LIBSUF)
endif
tools: tools/obudump$(EXESUF)
tools/obudump$(EXESUF): obuparse.o tools/obudump.o tools/json.o
$(CC) -o tools/obudump$(EXESUF) $^ -o $@
install-tools: tools
@install -d $(PREFIX)/bin
@install -v tools/obudump$(EXESUF) $(PREFIX)/bin
uninstall-tools:
@rm -fv $(PREFIX)/bin/obudump$(EXESUF)