-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
55 lines (39 loc) · 1.11 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
OBJECTS=src/getopt_pp.o
CXXFLAGS=-Wall -I.
EXAMPLES_SRCS=$(wildcard examples/example_*.cpp)
EXAMPLES_OBJS=$(patsubst %.cpp,%.o,$(EXAMPLES_SRCS))
EXAMPLE_BIN=$(patsubst %.cpp,%,$(EXAMPLES_SRCS))
_PREFIX=$(if $(PREFIX),$(PREFIX),/usr)
INSTALL_DIR=$(_PREFIX)/lib/getoptpp
DEV_INSTALL_DIR=$(_PREFIX)/include/getoptpp
ifeq ($(SHARED),n)
library: libgetopt_pp.a
$(EXAMPLE_BIN): libgetopt_pp.a
install_lib: libgetopt_pp.a
else
CXXFLAGS:=$(CXXFLAGS) -fPIC
library: libgetopt_pp.so
$(EXAMPLE_BIN): libgetopt_pp.so
install_lib: libgetopt_pp.so
endif
libgetopt_pp.a: $(OBJECTS)
ar -cvq $@ $^
libgetopt_pp.so: $(OBJECTS)
g++ -I. -shared -o $@ $^
examples: $(EXAMPLES_OBJS) $(EXAMPLE_BIN)
$(EXAMPLE_BIN):
g++ -I. -o $@ [email protected] -lgetopt_pp -L.
.PHONY: clean install install_dev
clean:
@rm -rf $(OBJECTS) libgetopt_pp.so libgetopt_pp.a $(EXAMPLE_BIN) src/*.o examples/*.o
install_lib:
mkdir -p $(INSTALL_DIR)
cp -f $^ $(INSTALL_DIR)
ifneq ($(SHARED),n)
ldconfig
endif
install_headers: getoptpp/getopt_pp.h
mkdir -p $(DEV_INSTALL_DIR)
cp -f $^ $(DEV_INSTALL_DIR)
install: install_lib install_headers
all: libgetopt_pp.so