File: Makefile

package info (click to toggle)
vfu 4.16%2Brepack-1
  • links: PTS
  • area: main
  • in suites: buster
  • size: 2,652 kB
  • ctags: 4,212
  • sloc: cpp: 16,503; ansic: 12,357; perl: 598; makefile: 564; sh: 61
file content (80 lines) | stat: -rw-r--r-- 1,839 bytes parent folder | download
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
############################# configurable section #############################

# configure install path

PREFIX:=/usr/local

# configure debug or release build

DEBUG:=-DDEBUG=1 -O0 -g3 -fno-inline -fstack-protector-all
# for debug build, comment the line below
DEBUG:=-O3

# configure default tools

CC?=cc
# make defines AR, so we have to override to gcc-ar, so -flto works
AR=gcc-ar
STRIP?=strip
RANLIB?=gcc-ranlib

########################## end of configurable section #########################

# shared library version

SOVERM:=0
SOVERF:=0.0.0

# change options based on wild guess of compiler brand/type

ifeq ($(lastword $(subst /, ,$(CC))),tcc)
CCOPT:=-Wall $(DEBUG) -I.
else
ifeq ($(lastword $(subst /, ,$(CC))),clang)
CCOPT:=-Wall $(DEBUG) -I. --std=gnu89
else
CCOPT:=-Wall $(DEBUG) -I. --std=gnu89 -flto
endif
endif

# allow to pass additional compiler flags

CFLAGS:=$(CCOPT) $(CFLAGS)

all: libyascreen.a libyascreen.so yastest yastest.shared

yascreen.o: yascreen.c yascreen.h
	$(CC) $(CFLAGS) -o $@ -c $<

yastest.o: yastest.c yascreen.h
	$(CC) $(CFLAGS) -o $@ -c $<

yastest: yastest.o yascreen.o
	$(CC) $(CFLAGS) -o $@ $^ -lrt
	$(STRIP) $@

yastest.shared: yastest.o libyascreen.so
	$(CC) $(CFLAGS) -o $@ $^ -lrt -L. -lyascreen
	$(STRIP) $@

libyascreen.a: yascreen.o
	$(AR) r $@ $^
	$(RANLIB) $@

libyascreen.so: libyascreen.so.$(SOVERM)
	ln -fs $^ $@

libyascreen.so.$(SOVERM): libyascreen.so.$(SOVERF)
	ln -fs $^ $@

libyascreen.so.$(SOVERF): yascreen.c yascreen.h
	$(CC) $(CFLAGS) -o $@ $< -fPIC -lrt -shared
	$(STRIP) $@

install: all
	cp -a libyascreen.a libyascreen.so libyascreen.so.$(SOVERM) libyascreen.so.$(SOVERF) $(PREFIX)/lib/
	cp -a yascreen.h $(PREFIX)/include/

clean:
	rm -f yastest yastest.shared yastest.o yascreen.o libyascreen.a libyascreen.so libyascreen.so.$(SOVERM) libyascreen.so.$(SOVERF)