aboutsummaryrefslogtreecommitdiff
path: root/Makefile
blob: d4a8d48c235e250d91f4abc3131152dc2b282574 (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
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#
# Copyright (C) 2007-2014 Xagasoft, All rights reserved.
#
# This file is part of the libbu++ library and is released under the
# terms of the license contained in the file LICENSE.
#

PREFIX := /home/eichlan/testroot
OBJECTS := $(patsubst %.cpp,%.o,$(wildcard src/stable/*.cpp src/unstable/*.cpp src/experimental/*.cpp src/compat/*.cpp))
HEADERS := bu/signals.h bu/autoconfig.h bu/version.h bu/config.h $(foreach fn,$(wildcard src/stable/*.h src/unstable/*.h src/experimental/*.h),bu/$(notdir ${fn})) $(patsubst src/%,bu/%,$(wildcard src/compat/*.h))
TOOLS := $(patsubst src/tools/%.cpp,%,$(wildcard src/tools/*.cpp))
UNITS := $(patsubst src/unit/%.unit,unit/%,$(wildcard src/unit/*.unit))
TESTS := $(patsubst src/tests/%.cpp,tests/%,$(wildcard src/tests/*.cpp))

.PHONY: default all headers clean tests install

default: libbu++.a tools

all: default tests

install: libbu++.a tools
	install -d ${PREFIX}/{include/bu/compat,lib,bin}
	install -m u=rw,go=r $(filter-out bu/compat/%,${HEADERS}) ${PREFIX}/include/bu
	install -m u=rw,go=r $(filter bu/compat/%,${HEADERS}) ${PREFIX}/include/bu/compat
	install -m u=rw,go=r libbu++.a ${PREFIX}/lib
	install ${TOOLS} ${PREFIX}/bin

tests: ${UNITS} ${TESTS}

clean:
	-rm ${HEADERS} ${OBJECTS} libbu++.a ${TOOLS} ${UNITS} ${TESTS}

bu:
	mkdir -p bu/compat

bu/signals.h bu/config.h bu/autoconfig.h bu/version.h: bu/%: src/%
	ln -s ../$< $@

$(foreach fn,$(wildcard src/stable/*.h),bu/$(notdir ${fn})): bu/%: src/stable/%
	ln -s ../$< $@

$(foreach fn,$(wildcard src/unstable/*.h),bu/$(notdir ${fn})): bu/%: src/unstable/%
	ln -s ../$< $@

$(foreach fn,$(wildcard src/experimental/*.h),bu/$(notdir ${fn})): bu/%: src/experimental/%
	ln -s ../$< $@

$(patsubst src/%,bu/%,$(wildcard src/compat/*.h)): bu/%: src/%
	mkdir -p bu/compat; ln -s ../../$< $@

autoconfig: autoconfig.cpp
	${CXX} -o autoconfig autoconfig.cpp

src/autoconfig.h src/version.h: autoconfig
	./autoconfig $@

src/signals.h: pregen/signals.h
	cp $< $@

headers: bu ${HEADERS}

tools: ${TOOLS}

${TOOLS}: %: src/tools/%.cpp libbu++.a

$(filter-out viewcsv bin2cpp,${TOOLS}):
	${CXX} -ggdb -W -Wall -I. -L. $< -o $@ -lbu++

viewcsv:
	${CXX} -ggdb -W -Wall -I. -L. $< -o $@ -lbu++ -lncurses

bin2cpp:
	${CXX} -ggdb -W -Wall -I. -L. $< -o $@ -lbu++ -lbz2 -lz -llzma

myriad:
	${CXX} -ggdb -W -Wall -I. -L. $< -o $@ -lbu++ -lpthread

${OBJECTS}: %.o: %.cpp
	${CXX} -ggdb -W -Wall -I. ${CXXFLAGS} $< -c -o $@

$(patsubst %,src/%.cpp,${UNITS}): %.cpp: %.unit mkunit
	./mkunit $< $@

${UNITS}: %: src/%.cpp
	${CXX} -ggdb -W -Wall -I. -L. $< -o $@ -lbu++

${TESTS}: %: src/%.cpp

$(filter-out tests/bzip2 tests/deflate tests/lzma,${TESTS}):
	${CXX} -ggdb -W -Wall -I. -L. $< -o $@ -lbu++

tests/bzip2:
	${CXX} -ggdb -W -Wall -I. -L. $< -o $@ -lbu++ -lbz2

tests/deflate:
	${CXX} -ggdb -W -Wall -I. -L. $< -o $@ -lbu++ -lz

tests/lzma:
	${CXX} -ggdb -W -Wall -I. -L. $< -o $@ -lbu++ -llzma

tests/threadid:
	${CXX} -ggdb -W -Wall -I. -L. $< -o $@ -lbu++ -lpthread

libbu++.a: bu ${HEADERS} ${OBJECTS}
	ar -r libbu++.a ${OBJECTS}