aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/libhmap/build.jst.tmpl
blob: b0c3670b78107f65ce1d9afc408bd0267df328eb (plain) (blame)
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
#default PREFIX /usr/local
#default INCLDIR /include
#default LIBDIR /lib
#default CC gcc

#ifdef LIBHMAP_DEBUG
#define DEBUG 1
#endif

#ifdef DEBUG
#define OPT_CFLAGS -Og -g
#else
#define OPT_CFLAGS -O2
#endif

cflags = -Wunused-function -Wunused-variable -Wconversion -Wformat
		-I include -I lib/liballoc/include #{OPT_CFLAGS}
		 #{EXTRA_CFLAGS} #{LIBHMAP_EXTRA_CFLAGS}

rule mkdir
	mkdir $out

rule liba
	#{CC} -o $out.tmp.o $in $cflags -r
	objcopy --keep-global-symbols=libhmap.api $out.tmp.o $out.fixed.o
	ar rcs $out $out.fixed.o
	rm $out.tmp.o $out.fixed.o

rule libso
	#{CC} -o $out $in $cflags -shared -Wl,-version-script libhmap.lds

rule cc
	#{CC} -o $out $in $cflags

target build
	mkdir

target lib/liballoc/build/liballoc.a
	just lib/liballoc

target build/libhmap.a
	liba src/hmap.c | include/hmap.h build

target build/libhmap.so
	libso src/hmap.c | include/hmap.h build

target build/test
	cc src/test.c build/libhmap.a lib/liballoc/build/liballoc.a | build

command clean
	rm -rf build

command cleanall
	just clean
	just -C lib/liballoc cleanall

command install
	install -m755 build/libhmap.a -t "#{DESTDIR}#{PREFIX}#{LIBDIR}"
	install -m755 build/libhmap.so -t "#{DESTDIR}#{PREFIX}#{LIBDIR}"
	install -m644 include/hmap.h -t "#{DESTDIR}#{PREFIX}#{INCLDIR}"

command uninstall
	rm -f "#{DESTDIR}#{PREFIX}#{LIBDIR}/libhmap.a"
	rm -f "#{DESTDIR}#{PREFIX}#{LIBDIR}/libhmap.so"
	rm -f "#{DESTDIR}#{PREFIX}#{INCLDIR}/hmap.h"

command all
	just build/libhmap.a build/libhmap.so build/test