This repository has been archived by the owner on Jan 31, 2022. It is now read-only.
forked from uwcms/APx-rpcsvc
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMakefile
126 lines (102 loc) · 4.46 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
ifndef PETALINUX
PETA_ROOTFS=/afs/hep.wisc.edu/home/uwhepfpga/petalinux-v2013.10-final/CTP7/build/linux/rootfs
CFLAGS= -fomit-frame-pointer -pipe -fno-common -fno-builtin \
-Wall \
-march=armv7-a -mfpu=neon -mfloat-abi=softfp \
-mthumb-interwork -mtune=cortex-a9 \
-DEMBED -Dlinux -D__linux__ -Dunix -fPIC \
-I$(PETA_ROOTFS)/stage/usr/include \
-I$(PETA_ROOTFS)/stage/include \
-I$(PETA_ROOTFS)/libs/libmemsvc
LDLIBS= -L$(PETA_ROOTFS)/targetroot/lib \
-L$(PETA_ROOTFS)/stage/lib \
-L$(PETA_ROOTFS)/targetroot/usr/lib \
-L$(PETA_ROOTFS)/stage/usr/lib
BUILDINFO_PATH=../../apps/buildinfo
CXX=arm-xilinx-linux-gnueabi-g++
else
BUILDINFO_PATH=$$PROOT/components/apps/buildinfo
include apps.common.mk
include $(PETALINUX)/rpm.mk
endif
APP = rpcsvc
# Add any other object files to this list below
APP_OBJS = rpcsvc.o run_client.o ModuleManager.o wiscRPCMsg.o LogManager.o LockTools.o proto_cpp/rpcmsg.pb.o
ifndef PETALINUX
all: build modules packages
else
all: build modules packages install
endif
build: $(APP)
$(APP): $(APP_OBJS)
$(CXX) $(LDFLAGS) -o $@ -rdynamic $(APP_OBJS) $(LDLIBS) -lmemsvc -ldl -l:libz.so.1 -lrt $(patsubst -lz,-l:libz.so.1,$(shell pkg-config --libs protobuf-lite))
clean:
chmod -fR u+w *.elf *.gdb *.o *.so modules/*.so packages/ proto_cpp/ || true
-rm -rf $(APP) *.elf *.gdb *.o *.so modules/*.so packages/ proto_cpp/
for I in *.h; do rm -f modules/$$I; done
ifdef PETALINUX
install: $(APP) modules packages
rm -rf instroot *.rpm
mkdir instroot
TARGETDIR=$$(pwd)/instroot $(TARGETINST) -d $(APP) /bin/$(APP)
mkdir -p instroot/usr/local/rpcmodules.preinstall
rsync -vrh modules/*.so instroot/usr/local/rpcmodules.preinstall/
chmod -R 0755 instroot/usr/local/rpcmodules.preinstall
TARGETDIR=$$(pwd)/instroot $(TARGETINST) -d initpersist_rpcsvc.sh /etc/initpersist.d/50rpcsvc.sh
#
TARGETDIR=$$(pwd)/instroot $(TARGETINST) -p 0755 -d rpcsvc.sh /etc/init.d/rpcsvc
TARGETDIR=$$(pwd)/instroot $(TARGETINST) -d -s /etc/init.d/rpcsvc /etc/rcS.d/S70rpcsvc
#
TARGETDIR=$$(pwd)/instroot $(TARGETINST) -p 0644 -d packages/module_dev.tbz2 /usr/share/doc/rpcsvc/module_dev.tbz2
TARGETDIR=$$(pwd)/instroot $(TARGETINST) -p 0644 -d packages/client_dev.tbz2 /usr/share/doc/rpcsvc/client_dev.tbz2
$(call FPM_AUTOVER_CALL,rpcsvc,instroot)
$(call RPM_AUTOVER_INSTALL_CALL,rpcsvc)
endif
%.o: %.cpp
$(CXX) -c $(CFLAGS) -o $@ $<
wiscRPCMsg.o: wiscRPCMsg.cpp proto_cpp
proto_cpp/%.pb.o: proto_cpp
$(CXX) -c $(CFLAGS) -o $@ $(patsubst proto_cpp/%.pb.o,proto_cpp/%.pb.cc,$@)
proto_cpp: $(wildcard *.proto)
@mkdir -p proto_cpp/
protoc --cpp_out=proto_cpp/ $^
@touch -c proto_cpp/
modules: $(patsubst %.cpp, %.so, $(wildcard modules/*.cpp))
modules/%.h: %.h
ln -s ../$< modules/$<
MODULE_HEADERS = $(patsubst %.h, modules/%.h, $(wildcard *.h))
modules/optical.so: modules/optical.cpp $(MODULE_HEADERS)
$(CXX) $(CFLAGS) $(LDFLAGS) -fPIC -shared -o $@ $< -lwisci2c
modules/%.so: modules/%.cpp $(MODULE_HEADERS)
$(CXX) $(CFLAGS) $(LDFLAGS) -fPIC -shared -o $@ $<
packages: packages/module_dev.tbz2 packages/client_dev.tbz2
packages/module_dev.tbz2: $(MODULE_HEADERS)
# Initialize package build directory
chmod -fR u+w packages/rpcsvc_module_dev || true
rm -rf packages/rpcsvc_module_dev
mkdir -p packages/rpcsvc_module_dev
# Install package files
cp -rL modules/*.h modules/*.cpp modules/Makefile modules/README.md packages/rpcsvc_module_dev/
#-grip packages/rpcsvc_module_dev/README.md --export
# Generate package version data
./gen_package_version.sh packages/rpcsvc_module_dev >> packages/rpcsvc_module_dev/RPCSVC_MANIFEST
# Mark package files readonly
chmod a-w packages/rpcsvc_module_dev/*
chmod +w packages/rpcsvc_module_dev/Makefile
# Generate package
tar -cjhf $@ --numeric-owner --owner=0 --group=0 -C packages/ rpcsvc_module_dev
packages/client_dev.tbz2: rpcmsg.proto $(wildcard libwiscrpcsvc-client/*.h) $(wildcard libwiscrpcsvc-client/*.cpp) libwiscrpcsvc-client/Makefile
# Initialize package build directory
chmod -fR u+w packages/rpcsvc_client_dev || true
rm -rf packages/rpcsvc_client_dev
mkdir -p packages/rpcsvc_client_dev
# Install package files
cp -rL $^ packages/rpcsvc_client_dev/
# Generate package version data
./gen_package_version.sh packages/rpcsvc_client_dev >> packages/rpcsvc_client_dev/RPCSVC_MANIFEST
# Mark package files readonly
chmod a-w packages/rpcsvc_client_dev/*
chmod +w packages/rpcsvc_client_dev/Makefile
# Generate package
tar -cjhf $@ --numeric-owner --owner=0 --group=0 -C packages/ rpcsvc_client_dev
.PHONY: all build install image packages