File: Makefile

package info (click to toggle)
libelfin 0.3-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 668 kB
  • sloc: cpp: 4,883; makefile: 189; python: 139; sh: 129; ansic: 10
file content (74 lines) | stat: -rw-r--r-- 2,229 bytes parent folder | download | duplicates (3)
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
# Changed when ABI backwards compatibility is broken.
# Typically uses the major version.
SONAME = 0

LIBVERSION = $(shell git describe --match 'v*' | sed -e s/^v//)

CXXFLAGS+=-g -O2 -Werror
override CXXFLAGS+=-std=c++0x -Wall -fPIC

all: libelf++.a libelf++.so libelf++.so.$(SONAME) libelf++.pc

SRCS := elf.cc mmap_loader.cc to_string.cc
HDRS := elf++.hh data.hh common.hh to_hex.hh
CLEAN :=

libelf++.a: $(SRCS:.cc=.o)
	ar rcs $@ $^
CLEAN += libelf++.a $(SRCS:.cc=.o)

$(SRCS:.cc=.o): $(HDRS)

to_string.cc: enum-print.py data.hh Makefile
	@echo "// Automatically generated by make at $$(date)" > to_string.cc
	@echo "// DO NOT EDIT" >> to_string.cc
	@echo >> to_string.cc
	@echo '#include "data.hh"' >> to_string.cc
	@echo '#include "to_hex.hh"' >> to_string.cc
	@echo >> to_string.cc
	@echo 'ELFPP_BEGIN_NAMESPACE' >> to_string.cc
	@echo >> to_string.cc
	python3 enum-print.py -u --hex --no-type --mask shf --mask pf \
		-x loos -x hios -x loproc -x hiproc < data.hh >> to_string.cc
	@echo 'ELFPP_END_NAMESPACE' >> to_string.cc
CLEAN += to_string.cc

libelf++.so.$(SONAME): $(SRCS:.cc=.o)
	$(CXX) $(CXXFLAGS) $(LDFLAGS) -shared -Wl,-soname,$@ -o $@ $^
CLEAN += libelf++.so.*

libelf++.so:
	ln -s $@.$(SONAME) $@
CLEAN += libelf++.so

# Create pkg-config for local library and headers. This will be
# transformed in to the correct global pkg-config by install.
libelf++.pc: always
	@(echo "libdir=$$PWD"; \
	  echo "includedir=$$PWD"; \
	  echo ""; \
	  echo "Name: libelf++"; \
	  echo "Description: C++11 ELF library"; \
	  echo "Version: $(LIBVERSION)"; \
	  echo "Libs: -L\$${libdir} -lelf++"; \
	  echo "Cflags: -I\$${includedir}") > $@
CLEAN += libelf++.pc

.PHONY: always

PREFIX?=/usr/local

install: libelf++.a libelf++.so libelf++.so.$(SONAME) libelf++.pc
	install -d $(PREFIX)/lib/pkgconfig
	install -t $(PREFIX)/lib libelf++.a
	install -t $(PREFIX)/lib libelf++.so.$(SONAME)
	install -t $(PREFIX)/lib libelf++.so
	install -d $(PREFIX)/include/libelfin/elf
	install -t $(PREFIX)/include/libelfin/elf common.hh data.hh elf++.hh
	sed 's,^libdir=.*,libdir=$(PREFIX)/lib,;s,^includedir=.*,includedir=$(PREFIX)/include,' libelf++.pc \
		> $(PREFIX)/lib/pkgconfig/libelf++.pc

clean:
	rm -f $(CLEAN)

.DELETE_ON_ERROR: