-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
executable file
·137 lines (107 loc) · 3.38 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
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
include globals.make
LOCAL_SRCS = $(wildcard *.cpp)
LOCAL_OBJS = $(LOCAL_SRCS:.cpp=.o)
PRJ_LIBS = -lCrtSvc -lCrtRestInterface
PRJ_AR_LIBS = -l:libCrtSvc.a -l:libCrtRestInterface.a
SUBDIRS = svc api
SUBDIRS.A = svc.a api.a
all: shared
shared: $(SUBDIRS) $(LOCAL_OBJS)
$(CC) $(CC_ARGS) -o crt $(LOCAL_OBJS) $(PRJ_LIBS) $(LD_ARGS)
static: $(SUBDIRS.A) $(LOCAL_OBJS)
$(CC) $(CC_ARGS) -o a.crt $(LOCAL_OBJS) $(PRJ_AR_LIBS) $(AR_ARGS)
svc:
cd service && $(MAKE)
svc.a:
cd service && $(MAKE) static
api:
cd resources && $(MAKE)
api.a:
cd resources && $(MAKE) static
.cpp.o:
$(CC) $(CC_ARGS) -c $< -o $@
clean:
cd service && $(MAKE) clean
cd resources && $(MAKE) clean
rm -rf pkgdir
rm -f lib/* xfer/* *.o *~ *.deb crt a.crt
docker-image:
docker build --rm --pull --tag sostheim/crt:latest .
tag-image: docker-image
docker tag sostheim/crt:latest sostheim/crt:$(COMMIT)
push-image: tag-image
docker push sostheim/crt:$(COMMIT)
docker push sostheim/crt:latest
transfer:
mkdir --mode=755 -p ./xfer
rm -f ./xfer/*
ifneq ("$(wildcard crt)","")
cp crt ./xfer/
cp ./lib/lib*so ./xfer/
else ifneq ("$(wildcard a.crt)","")
cp a.crt ./xfer/
endif
cd xfer && tar czvf crt_xfer.tgz *
install:
mkdir --mode=755 -p /usr/local/crt/bin
ifneq ("$(wildcard crt)","")
cp ./crt /usr/local/crt/bin
mkdir --mode=755 -p /usr/local/crt/lib
cp ./lib/lib*.so /usr/local/crt/lib
cp ./etc/ld.so.conf.d/crt.conf /etc/ld.so.conf.d/
ldconfig
else ifneq ("$(wildcard a.crt)","")
cp ./a.crt /usr/local/crt/bin/crt
endif
mkdir --mode=755 -p /var/log/crt/
chmod 777 /var/log/crt/
package: shared
#
# Always start clean just in case there are residual directories laying
# around from a previous, or failed, build.
#
rm -rf pkgdir
#
# Instead of making a separate package for POCO, for right now we just bundle it
# we remove the libData* to obviate dependencies on mysqlclient and odbc.
#
mkdir --mode=755 -p ./pkgdir/usr/lib
cp -d /usr/local/lib/libPoco* ./pkgdir/usr/lib
cd ./pkgdir/usr/lib; \
rm -f libPocoData*
chmod 644 ./pkgdir/usr/lib/*.so
#
# The rest is analogous to install, but with pkgdir as the root and release versioning
#
mkdir --mode=755 -p ./pkgdir/etc/ld.so.conf.d
mkdir --mode=755 -p ./pkgdir/usr/bin
mkdir --mode=755 -p ./pkgdir/usr/local/crt/bin
mkdir --mode=755 -p ./pkgdir/usr/local/crt/lib
mkdir --mode=755 -p ./pkgdir/var/log/crt/
# Conf files
cp -r ./etc/ ./pkgdir/
# crt pplication binary
cp ./crt ./pkgdir/usr/local/crt/bin/crt.$(VERSION)
cd ./pkgdir/usr/bin; \
ln -f -s ../local/crt/bin/crt.$(VERSION) crt
# crt application libraries
cp ./lib/libCrtSvc.so ./pkgdir/usr/local/crt/lib/libCrtSvc.so.$(VERSION)
cp ./lib/libCrtRestInterface.so ./pkgdir/usr/local/crt/lib/libCrtRestInterface.so.$(VERSION)
cd ./pkgdir/usr/local/crt/lib \
ln -f -s libCrtSvc.so.$(VERSION) libCrtSvc.so \
ln -f -s libCrtRestInterface.so.$(VERSION) libCrtRestInterface.so \
#
# Create the Debian package
#
rm -f crt-x86_64.$(VERSION).deb
fpm -s dir -t deb \
-C ./pkgdir \
--name crt -v $(VERSION) \
--package crt-x86_64.$(VERSION).deb \
--maintainer Richard Sostheim \
--description "The C++ Rest Template (crt) Service" \
--provides "crt" \
--depends 'openssl > 1.0' \
usr var etc
chown root:root crt-x86_64.$(VERSION).deb
rm -rf pkgdir