summaryrefslogtreecommitdiff
path: root/Makefile
blob: de03318f44228459790e40a0c5de7b0512c5fd72 (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
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
ifeq ($(CONFIG_DIR),)
    config_file=./.config
else
    config_file=$(CONFIG_DIR)/.config
endif
-include $(config_file)

XALAN_PATH:=./lcmodule/tools/xalan-j_2_7_1/
LCD_CONFIG:=./source/config/

LIBSRC := \
	source/utilities/Serialization.cpp\
	source/utilities/Logger.cpp\
	source/utilities/MemMappedFile.cpp\
	source/utilities/CaptiveThreadObject.cpp\
	source/utilities/BulkHandler.cpp\
	source/CEH/ProtromRpcInterface.cpp\
	source/CEH/commands_impl.cpp\
	source/CEH/a2_commands_impl.cpp\
	source/CEH/ZRpcInterface.cpp\
	source/CEH/CmdResult.cpp\
	source/LcmInterface.cpp\
	source/LCDriverThread.cpp\
	source/LCDriverMethods.cpp\
	source/LCDriverEntry.cpp\
	source/LCDriver.cpp\
	source/LCM/Hash.cpp\
	source/LCM/Buffers.cpp\
	source/LCM/Queue.cpp\
	source/LCM/Timer.cpp\
	source/api_wrappers/linux/CThreadWrapper.cpp\
	source/api_wrappers/linux/CWaitableObject.cpp\
	source/api_wrappers/linux/CSemaphore.cpp\
	source/api_wrappers/linux/CSemaphoreQueue.cpp\
	source/api_wrappers/linux/CEventObject.cpp\
	source/api_wrappers/linux/CWaitableObjectCollection.cpp\
	source/api_wrappers/linux/OS.cpp\
	source/LCDriverInterface.cpp\
	source/security_algorithms/SecurityAlgorithms.cpp\
	source/security_algorithms/sha/sha2.cpp\
	$(AUTO_DIR_LIB)/commands_marshal.cpp\
	$(AUTO_DIR_LIB)/a2_commands_marshal.cpp\

LIBOBJ_x32 := $(addprefix $(BUILDFOLDER)/$(LIB_x32_OBJ_DIR)/, $(notdir $(LIBSRC:.cpp=.o)))
LIBOBJ_x64 := $(addprefix $(BUILDFOLDER)/$(LIB_x64_OBJ_DIR)/, $(notdir $(LIBSRC:.cpp=.o)))

AUTOGEN_FILES := $(AUTO_DIR_LIB)/command_ids.h\
		$(AUTO_DIR_LIB)/commands.h\
		$(AUTO_DIR_LIB)/commands_impl.h\
		$(AUTO_DIR_LIB)/commands_marshal.cpp\
		$(AUTO_DIR_LIB)/lcdriver_error_codes.h\
		$(AUTO_DIR_LIB)/a2_command_ids.h\
		$(AUTO_DIR_LIB)/a2_commands.h\
		$(AUTO_DIR_LIB)/a2_commands_impl.h\
		$(AUTO_DIR_LIB)/a2_commands_marshal.cpp


#include directories
INCLUDES := \
	-Isource\
	-Isource/api_wrappers/linux\
	-Isource/utilities\
	-Isource/LCM\
	-Isource/LCM/include\
	-Isource/security_algorithms\
	-Isource/CEH\
	-Isource/security_algorithms/sha\
	-I$(AUTO_DIR_LIB)

# C++ compiler flags (-g -O2 -Wall)
CXXFLAGS := -c -O2 -Wall -fPIC -fvisibility=hidden -fno-strict-aliasing -DLCDRIVER_EXPORTS -D_FILE_OFFSET_BITS=64

LDFLAGS := -fPIC -fvisibility=hidden -lpthread -lrt -ldl -shared -Wl,-soname,liblcdriver.so

LBITS := $(shell getconf LONG_BIT)
ifeq ($(LBITS),64)
#
# do 64 bit stuff here, like set some CFLAGS
#
CXXFLAGS += -DLINUX_64
build: configfile setup_folders $(LIB_x32) $(LIB_x64) lcmodule
else
#
# do 32 bit stuff here
#
CXXFLAGS += -DLINUX_32
build: configfile setup_folders $(LIB_x32) lcmodule
endif

$(LIB_x32): $(LIBOBJ_x32)
	$(CXX) $(LDFLAGS) -m32 -o $(LIB_x32) $(addprefix $(BUILDFOLDER)/$(LIB_x32_OBJ_DIR)/, $(^F))

$(LIB_x64): $(LIBOBJ_x64)
	$(CXX) $(LDFLAGS) -o $(LIB_x64) $(addprefix $(BUILDFOLDER)/$(LIB_x64_OBJ_DIR)/, $(^F))

#
# Source files build
#
$(BUILDFOLDER)/$(LIB_x32_OBJ_DIR)/%.o: source/utilities/%.cpp $(AUTOGEN_FILES)
	@mkdir -p $(dir $@)
	$(CXX) $(INCLUDES) $(CXXFLAGS) -m32 -c $< -o $(BUILDFOLDER)/$(LIB_x32_OBJ_DIR)/$(@F)

$(BUILDFOLDER)/$(LIB_x32_OBJ_DIR)/%.o: source/CEH/%.cpp $(AUTOGEN_FILES)
	@mkdir -p $(dir $@)
	$(CXX) $(INCLUDES) $(CXXFLAGS) -m32 -c $< -o $(BUILDFOLDER)/$(LIB_x32_OBJ_DIR)/$(@F)

$(BUILDFOLDER)/$(LIB_x32_OBJ_DIR)/%.o: source/%.cpp $(AUTOGEN_FILES)
	@mkdir -p $(dir $@)
	$(CXX) $(INCLUDES) $(CXXFLAGS) -m32 -c $< -o $(BUILDFOLDER)/$(LIB_x32_OBJ_DIR)/$(@F)

$(BUILDFOLDER)/$(LIB_x32_OBJ_DIR)/%.o: source/LCM/%.cpp $(AUTOGEN_FILES)
	@mkdir -p $(dir $@)
	$(CXX) $(INCLUDES) $(CXXFLAGS) -m32 -c $< -o $(BUILDFOLDER)/$(LIB_x32_OBJ_DIR)/$(@F)

$(BUILDFOLDER)/$(LIB_x32_OBJ_DIR)/%.o: source/api_wrappers/linux/%.cpp $(AUTOGEN_FILES)
	@mkdir -p $(dir $@)
	$(CXX) $(INCLUDES) $(CXXFLAGS) -m32 -c $< -o $(BUILDFOLDER)/$(LIB_x32_OBJ_DIR)/$(@F)

$(BUILDFOLDER)/$(LIB_x32_OBJ_DIR)/%.o: $(AUTO_DIR_LIB)/%.cpp $(AUTOGEN_FILES)
	@mkdir -p $(dir $@)
	$(CXX) $(INCLUDES) $(CXXFLAGS) -m32 -c $< -o $(BUILDFOLDER)/$(LIB_x32_OBJ_DIR)/$(@F)

$(BUILDFOLDER)/$(LIB_x32_OBJ_DIR)/%.o: source/security_algorithms/sha/%.cpp $(AUTOGEN_FILES)
	@mkdir -p $(dir $@)
	$(CXX) $(INCLUDES) $(CXXFLAGS) -m32 -c $< -o $(BUILDFOLDER)/$(LIB_x32_OBJ_DIR)/$(@F)

$(BUILDFOLDER)/$(LIB_x32_OBJ_DIR)/%.o: source/security_algorithms/%.cpp $(AUTOGEN_FILES)
	@mkdir -p $(dir $@)
	$(CXX) $(INCLUDES) $(CXXFLAGS) -m32 -c $< -o $(BUILDFOLDER)/$(LIB_x32_OBJ_DIR)/$(@F)

###
$(BUILDFOLDER)/$(LIB_x64_OBJ_DIR)/%.o: source/utilities/%.cpp $(AUTOGEN_FILES)
	@mkdir -p $(dir $@)
	$(CXX) $(INCLUDES) $(CXXFLAGS) -c $< -o $(BUILDFOLDER)/$(LIB_x64_OBJ_DIR)/$(@F)

$(BUILDFOLDER)/$(LIB_x64_OBJ_DIR)/%.o: source/CEH/%.cpp $(AUTOGEN_FILES)
	@mkdir -p $(dir $@)
	$(CXX) $(INCLUDES) $(CXXFLAGS) -c $< -o $(BUILDFOLDER)/$(LIB_x64_OBJ_DIR)/$(@F)

$(BUILDFOLDER)/$(LIB_x64_OBJ_DIR)/%.o: source/%.cpp $(AUTOGEN_FILES)
	@mkdir -p $(dir $@)
	$(CXX) $(INCLUDES) $(CXXFLAGS) -c $< -o $(BUILDFOLDER)/$(LIB_x64_OBJ_DIR)/$(@F)

$(BUILDFOLDER)/$(LIB_x64_OBJ_DIR)/%.o: source/LCM/%.cpp $(AUTOGEN_FILES)
	@mkdir -p $(dir $@)
	$(CXX) $(INCLUDES) $(CXXFLAGS) -c $< -o $(BUILDFOLDER)/$(LIB_x64_OBJ_DIR)/$(@F)

$(BUILDFOLDER)/$(LIB_x64_OBJ_DIR)/%.o: source/api_wrappers/linux/%.cpp $(AUTOGEN_FILES)
	@mkdir -p $(dir $@)
	$(CXX) $(INCLUDES) $(CXXFLAGS) -c $< -o $(BUILDFOLDER)/$(LIB_x64_OBJ_DIR)/$(@F)

$(BUILDFOLDER)/$(LIB_x64_OBJ_DIR)/%.o: source/security_algorithms/%.cpp $(AUTOGEN_FILES)
	@mkdir -p $(dir $@)
	$(CXX) $(INCLUDES) $(CXXFLAGS) -c $< -o $(BUILDFOLDER)/$(LIB_x64_OBJ_DIR)/$(@F)

$(BUILDFOLDER)/$(LIB_x64_OBJ_DIR)/%.o: source/security_algorithms/sha/%.cpp $(AUTOGEN_FILES)
	@mkdir -p $(dir $@)
	$(CXX) $(INCLUDES) $(CXXFLAGS) -c $< -o $(BUILDFOLDER)/$(LIB_x64_OBJ_DIR)/$(@F)

$(BUILDFOLDER)/$(LIB_x64_OBJ_DIR)/%.o: $(AUTO_DIR_LIB)/%.cpp $(AUTOGEN_FILES)
	@mkdir -p $(dir $@)
	$(CXX) $(INCLUDES) $(CXXFLAGS) -c $< -o $(BUILDFOLDER)/$(LIB_x64_OBJ_DIR)/$(@F)

#Autogen files
$(AUTO_DIR_LIB)/command_ids.h: $(LCD_CONFIG)commands.xml $(LCD_CONFIG)command_ids_h.xsl | setup_folders
	@echo "Generating autogen $(AUTO_DIR_LIB)/command_ids.h..."
	@java -classpath $(XALAN_PATH)xalan.jar org.apache.xalan.xslt.Process -in $(LCD_CONFIG)commands.xml -xsl $(LCD_CONFIG)command_ids_h.xsl -out $(AUTO_DIR_LIB)/command_ids.h

$(AUTO_DIR_LIB)/commands.h: $(LCD_CONFIG)commands.xml $(LCD_CONFIG)commands_h.xsl | setup_folders
	@echo "Generating autogen $(AUTO_DIR_LIB)/commands.h..."
	@java -classpath $(XALAN_PATH)xalan.jar org.apache.xalan.xslt.Process -in $(LCD_CONFIG)commands.xml -xsl $(LCD_CONFIG)commands_h.xsl -out $(AUTO_DIR_LIB)/commands.h

$(AUTO_DIR_LIB)/commands_impl.h: $(LCD_CONFIG)commands.xml $(LCD_CONFIG)commands_impl_h.xsl | setup_folders
	@echo "Generating autogen $(AUTO_DIR_LIB)/commands_impl.h..."
	@java -classpath $(XALAN_PATH)xalan.jar org.apache.xalan.xslt.Process -in $(LCD_CONFIG)commands.xml -xsl $(LCD_CONFIG)commands_impl_h.xsl -out $(AUTO_DIR_LIB)/commands_impl.h

$(AUTO_DIR_LIB)/commands_marshal.cpp: $(LCD_CONFIG)commands.xml $(LCD_CONFIG)commands_marshal_cpp.xsl | setup_folders
	@echo "Generating autogen $(AUTO_DIR_LIB)/commands_marshal.cpp..."
	@java -classpath $(XALAN_PATH)xalan.jar org.apache.xalan.xslt.Process -in $(LCD_CONFIG)commands.xml -xsl $(LCD_CONFIG)commands_marshal_cpp.xsl -out $(AUTO_DIR_LIB)/commands_marshal.cpp

$(AUTO_DIR_LIB)/lcdriver_error_codes.h: $(LCD_CONFIG)lcdriver_error_codes.xml $(LCD_CONFIG)lcdriver_error_codes_h.xsl | setup_folders
	@echo "Generating autogen $(AUTO_DIR_LIB)/lcdriver_error_codes.h..."
	@java -classpath $(XALAN_PATH)xalan.jar org.apache.xalan.xslt.Process -in $(LCD_CONFIG)lcdriver_error_codes.xml -xsl $(LCD_CONFIG)lcdriver_error_codes_h.xsl -out $(AUTO_DIR_LIB)/lcdriver_error_codes.h

$(AUTO_DIR_LIB)/a2_command_ids.h: $(LCD_CONFIG)a2_commands.xml $(LCD_CONFIG)a2_command_ids_h.xsl | setup_folders
	@echo "Generating autogen $(AUTO_DIR_LIB)/a2_command_ids.h..."
	@java -classpath $(XALAN_PATH)xalan.jar org.apache.xalan.xslt.Process -in $(LCD_CONFIG)a2_commands.xml -xsl $(LCD_CONFIG)a2_command_ids_h.xsl -out $(AUTO_DIR_LIB)/a2_command_ids.h

$(AUTO_DIR_LIB)/a2_commands.h: $(LCD_CONFIG)a2_commands.xml $(LCD_CONFIG)a2_commands_h.xsl | setup_folders
	@echo "Generating autogen $(AUTO_DIR_LIB)/a2_commands.h..."
	@java -classpath $(XALAN_PATH)xalan.jar org.apache.xalan.xslt.Process -in $(LCD_CONFIG)a2_commands.xml -xsl $(LCD_CONFIG)a2_commands_h.xsl -out $(AUTO_DIR_LIB)/a2_commands.h

$(AUTO_DIR_LIB)/a2_commands_impl.h: $(LCD_CONFIG)a2_commands.xml $(LCD_CONFIG)a2_commands_impl_h.xsl | setup_folders
	@echo "Generating autogen $(AUTO_DIR_LIB)/a2_commands_impl.h..."
	@java -classpath $(XALAN_PATH)xalan.jar org.apache.xalan.xslt.Process -in $(LCD_CONFIG)a2_commands.xml -xsl $(LCD_CONFIG)a2_commands_impl_h.xsl -out $(AUTO_DIR_LIB)/a2_commands_impl.h

$(AUTO_DIR_LIB)/a2_commands_marshal.cpp: $(LCD_CONFIG)a2_commands.xml $(LCD_CONFIG)a2_commands_marshal_cpp.xsl | setup_folders
	@echo "Generating autogen $(AUTO_DIR_LIB)/a2_commands_marshal.cpp..."
	@java -classpath $(XALAN_PATH)xalan.jar org.apache.xalan.xslt.Process -in $(LCD_CONFIG)a2_commands.xml -xsl $(LCD_CONFIG)a2_commands_marshal_cpp.xsl -out $(AUTO_DIR_LIB)/a2_commands_marshal.cpp

#setting up needed folders
$(BUILDFOLDER): | configfile
	@mkdir -p $@ 2> /dev/null

$(BUILDFOLDER)/.builddummy: | $(BUILDFOLDER)
	@touch $@

$(AUTO_DIR_LIB): | configfile
	@mkdir -p $@ 2> /dev/null

$(AUTO_DIR_LIB)/.autodirdummy: | $(AUTO_DIR_LIB)
	@touch $@

$(LCD_INSTALLDIR): | configfile
	@mkdir -p $@ 2> /dev/null

$(LCD_INSTALLDIR)/.installdummy: | $(LCD_INSTALLDIR)
	@touch $@

.PHONY: setup_folders
setup_folders: validatevariables
setup_folders: $(BUILDFOLDER)/.builddummy $(AUTO_DIR_LIB)/.autodirdummy $(LCD_INSTALLDIR)/.installdummy
	@echo $< > /dev/null

.PHONY: validatevariables
validatevariables: configfile
	$(if $(CXX),, $(error "CXX not set"))
	$(if $(BUILDFOLDER),, $(error "BUILDFOLDER not set"))
	$(if $(AUTO_DIR_LIB),, $(error "AUTO_DIR_LIB not set"))
	$(if $(LIB_x32),, $(error "LIB_x32 not set"))
	$(if $(LIB_x64),, $(error "LIB_x64 not set"))
	$(if $(LIB_x32_OBJ_DIR),, $(error "LIB_x32_OBJ_DIR not set"))
	$(if $(LIB_x64_OBJ_DIR),, $(error "LIB_x64_OBJ_DIR not set"))
	$(if $(LCD_INSTALLDIR),, $(error "LCD_INSTALLDIR not set"))

#if the wildcard function finds any file matching the name
#of the configfile then this will result in
#"configfile: " so the config target will not be unnecessarily
#called. If however there is no file matching the configfile
#this will become "configfile: config" and the config target
#will be called and the configfile created.
#(calling config directly will always recreate the configfile
#so any values that has been changed will be overwritten with
#the new value)
.PHONY: configfile
configfile: $(if $(wildcard $(config_file)),,config)
	@echo $< > /dev/null

.PHONY: config
config: BUILDFOLDER := $(if $(strip $(BUILDFOLDER)),$(BUILDFOLDER),$(shell bash -c "pwd")/build)
config: AUTO_DIR_LIB :=$(BUILDFOLDER)/autogen/
config: LIB_x32 := $(BUILDFOLDER)/liblcdriver.so
config: LIB_x64 := $(BUILDFOLDER)/liblcdriver_x64.so
config: LIB_x32_OBJ_DIR := x32
config: LIB_x64_OBJ_DIR := x64
config: CXX := $(CROSS_PREFIX)g++
config: LCD_INSTALLDIR := $(shell pwd)/dist
config: lcmodule-config
	@echo Generating config file...
	@rm -f $(config_file)
	@touch $(config_file)
	@echo CXX: $(CXX)
	@echo "CXX := $(CXX)" >> $(config_file)
	@echo BUILDFOLDER: $(BUILDFOLDER)
	@echo "BUILDFOLDER := $(BUILDFOLDER)" >> $(config_file)
	@echo AUTO_DIR_LIB: $(AUTO_DIR_LIB)
	@echo "AUTO_DIR_LIB := $(AUTO_DIR_LIB)" >> $(config_file)
	@echo LIB_x32: $(LIB_x32)
	@echo "LIB_x32 := $(LIB_x32)" >> $(config_file)
	@echo LIB_x64: $(LIB_x64)
	@echo "LIB_x64 := $(LIB_x64)" >> $(config_file)
	@echo LIB_x32_OBJ_DIR: $(LIB_x32_OBJ_DIR)
	@echo "LIB_x32_OBJ_DIR := $(LIB_x32_OBJ_DIR)" >> $(config_file)
	@echo LIB_x64_OBJ_DIR: $(LIB_x64_OBJ_DIR)
	@echo "LIB_x64_OBJ_DIR := $(LIB_x64_OBJ_DIR)" >> $(config_file)
	@echo LCD_INSTALLDIR: $(LCD_INSTALLDIR)
	@echo "LCD_INSTALLDIR := $(LCD_INSTALLDIR)" >> $(config_file)

install: build
	install -m 0755 -t $(LCD_INSTALLDIR) $(BUILDFOLDER)/liblcdriver.so
ifeq ($(LBITS),64)
	install -m 0755 -t $(LCD_INSTALLDIR) $(BUILDFOLDER)/liblcdriver_x64.so
endif

clean:
	$(if $(BUILDFOLDER), \
		$(if $(LIB_x32_OBJ_DIR), \
			@rm -f $(BUILDFOLDER)/$(LIB_x32_OBJ_DIR)/*.o \
			@rm -rf $(BUILDFOLDER)/$(LIB_x32_OBJ_DIR),),)
ifeq ($(LBITS),64)
	$(if $(BUILDFOLDER), \
		$(if $(LIB_x64_OBJ_DIR), \
			@rm -f $(BUILDFOLDER)/$(LIB_x64_OBJ_DIR)/*.o \
			@rm -rf $(BUILDFOLDER)/$(LIB_x64_OBJ_DIR),),)
endif
	$(if $(BUILDFOLDER), \
		@rm -f $(BUILDFOLDER)/*.so*,)
	$(if $(BUILDFOLDER), \
		@rm -f $(BUILDFOLDER)/*.deb,)

distclean: clean
	$(if $(AUTO_DIR_LIB), \
		@rm -f $(AUTO_DIR_LIB)/*.cpp \
		@rm -f $(AUTO_DIR_LIB)/*.h,)
	$(if $(LCD_INSTALLDIR), \
		@rm -f $(LCD_INSTALLDIR)/liblcdriver.so,)
ifeq ($(LBITS),64)
	$(if $(LCD_INSTALLDIR), \
		@rm -f $(LCD_INSTALLDIR)/liblcdriver_x64.so,)
endif
	$(if $(config_file), \
		@rm -f $(config_file),)

COV_DATA_DIR=cov_data
COV_INTER_DATA_DIR=cov_inter

coverity:
	@if [ -d "$(COV_DATA_DIR)" ]; then \
	@cov-stop-gui --datadir $(COV_DATA_DIR); \
	fi
	@cov-configure --compiler $(CC) --comptype gcc
	@if [ -d "$(COV_DATA_DIR)" ]; then \
		echo coverity gui already installed; \
	else \
		cov-install-gui --password admin --datadir $(COV_DATA_DIR) --product lcd --domain "C/C++"; \
	fi

	@cov-build --dir $(COV_INTER_DATA_DIR) $(MAKE) build
	@cov-analyze --dir $(COV_INTER_DATA_DIR) --aggressiveness-level medium --all
	@cov-commit-defects --datadir $(COV_DATA_DIR) --product lcd --user admin --dir $(COV_INTER_DATA_DIR)
	@cov-start-gui --datadir $(COV_DATA_DIR) --port 1122
	echo Go to localhost port 1122 in webbrowser and login with username admin and password admin to review result

.PHONY: lcmodule-config
lcmodule-config:
	make -C lcmodule config BUILDFOLDER=$(BUILDFOLDER) LCMLIB_INSTALLDIR=$(LCD_INSTALLDIR) LCMLDR_INSTALLDIR=$(LCD_INSTALLDIR)

.PHONY: lcmodule
lcmodule:
	make -C lcmodule

DEB_VERSION := custom
.PHONY: debian
debian: build lcmodule
	mkdir -p debian/DEBIAN
	mkdir -p debian/usr/lib

	cp packages/control debian/DEBIAN/control
	cp $(BUILDFOLDER)/liblcdriver.so $(BUILDFOLDER)/liblcm.so.1 debian/usr/lib

	fakeroot dpkg-deb --build debian $(BUILDFOLDER)/riff-loadercomm-${DEB_VERSION}_i386.deb || error

	rm -rf debian

	mkdir -p debian/DEBIAN
	mkdir -p debian/usr/lib

	cp packages/control-x64 debian/DEBIAN/control
	cp $(BUILDFOLDER)/liblcdriver_x64.so $(BUILDFOLDER)/liblcm_x64.so.1 debian/usr/lib
	ln -s liblcdriver_x64.so debian/usr/lib/liblcdriver.so
	ln -s liblcm_x64.so.1 debian/usr/lib/liblcm.so.1

	fakeroot dpkg-deb --build debian $(BUILDFOLDER)/riff-loadercomm-${DEB_VERSION}_x64.deb || error

	rm -rf debian