From 097f8ed81e50b5efda28c6a2837e75e15b5812e4 Mon Sep 17 00:00:00 2001 From: Aleksandar Bozhinovski Date: Fri, 9 Mar 2012 10:01:30 +0100 Subject: Build Lcd Lcm .dll under Linux Build 32-bit and 64-bit LCD and LCM .dll under Linux using mingw cross compiler ST-Ericsson ID: 412641 ST-Ericsson FOSS-OUT ID: STETL-FOSS-OUT-10204 Change-Id: I9dbb0dfb17f1d51b1ee3528e5dae44cb0dc81a87 Change-Id: I814b561c243a56412fdc29f8b046a6a8648bd297 Reviewed-on: http://gerrit.lud.stericsson.com/gerrit/47975 Reviewed-by: QABUILD Reviewed-by: QATEST Tested-by: Viktor MLADENOVSKI Reviewed-by: Viktor MLADENOVSKI Reviewed-by: Vlatko PISTOLOV Tested-by: Vlatko PISTOLOV --- .gitignore | 2 + Android.mk | 1 + Makefile | 228 +++- lcmodule/Makefile | 196 ++- lcmodule/source/LCM.rc | 103 -- lcmodule/source/LCM.vcproj | 1882 +++++++++++++------------- mingw_prebuilt/mingwm10.dll | Bin 0 -> 24110 bytes source/CEH/commands_types.h | 2 +- source/LCDriver.h | 4 + source/LCDriver.rc | 115 -- source/LCDriver.vcproj | 16 +- source/api_wrappers/linux/LinuxApiWrappers.h | 1 + source/api_wrappers/linux/OS.cpp | 30 - source/api_wrappers/linux/OS.h | 73 - source/api_wrappers/windows/WinApiWrappers.h | 19 +- source/gen_rc.sh | 168 +++ source/security_algorithms/sha/sha2.cpp | 1 + source/utilities/Logger.h | 2 +- source/utilities/String_s.cpp | 34 + source/utilities/String_s.h | 80 ++ 20 files changed, 1584 insertions(+), 1373 deletions(-) delete mode 100644 lcmodule/source/LCM.rc create mode 100644 mingw_prebuilt/mingwm10.dll delete mode 100644 source/LCDriver.rc create mode 100755 source/gen_rc.sh create mode 100644 source/utilities/String_s.cpp create mode 100644 source/utilities/String_s.h diff --git a/.gitignore b/.gitignore index 87996c0..fd6fed8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,8 @@ lcmodule/.config lcmodule/out out +source/outLCDriver.rc +lcmodule/source/outLCM.rc .config cov_data cov_inter diff --git a/Android.mk b/Android.mk index f2dc750..92f1b08 100644 --- a/Android.mk +++ b/Android.mk @@ -154,6 +154,7 @@ LOCAL_SRC_FILES := \ source/utilities/MemMappedFile.cpp\ source/utilities/CaptiveThreadObject.cpp\ source/utilities/BulkHandler.cpp\ + source/utilities/String_s.cpp\ source/CEH/ProtromRpcInterface.cpp\ source/CEH/commands_impl.cpp\ source/CEH/a2_commands_impl.cpp\ diff --git a/Makefile b/Makefile index 7a7ae08..4beeaf4 100644 --- a/Makefile +++ b/Makefile @@ -5,10 +5,22 @@ else endif -include $(config_file) +MINGW_X32_CC:=i586-mingw32msvc- +MINGW_X64_CC:=amd64-mingw32msvc- XALAN_PATH:=./lcmodule/tools/xalan-j_2_7_1/ LCD_CONFIG:=./source/config/ LCD_DIR:=./ -WIN_BINARIES=./win_binaries/ + +ifneq ($(shell which $(MINGW_X32_CC)g++), ) +USE_MINGW_X32 := 1 +else +USE_MINGW_X32 := 0 +endif +ifneq ($(shell which $(MINGW_X64_CC)g++), ) +USE_MINGW_X64 := 1 +else +USE_MINGW_X64 := 0 +endif OS_NAME := $(shell uname) ifeq ($(OS_NAME), Linux) @@ -23,37 +35,48 @@ LIBSRC := \ source/utilities/MemMappedFile.cpp\ source/utilities/CaptiveThreadObject.cpp\ source/utilities/BulkHandler.cpp\ - source/CEH/ProtromRpcInterface.cpp\ - source/CEH/commands_impl.cpp\ + source/utilities/String_s.cpp\ source/CEH/a2_commands_impl.cpp\ - source/CEH/ZRpcInterface.cpp\ source/CEH/CmdResult.cpp\ + source/CEH/commands_impl.cpp\ + source/CEH/ProtromRpcInterface.cpp\ + source/CEH/ZRpcInterface.cpp\ source/LcmInterface.cpp\ source/LCDriverThread.cpp\ source/LCDriverMethods.cpp\ source/LcdVersion.cpp\ source/LCDriverEntry.cpp\ source/LCDriver.cpp\ - source/LCM/Hash.cpp\ source/LCM/Buffers.cpp\ + source/LCM/Hash.cpp\ source/LCM/Queue.cpp\ source/LCM/Timer.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 +ifeq ($(BUILD_WIN),) +LIBSRC += \ 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\ + source/api_wrappers/linux/OS.cpp +endif LIBOBJ_x32 := $(addprefix $(BUILDFOLDER)/$(LIB_x32_OBJ_DIR)/, $(notdir $(LIBSRC:.cpp=.o))) LIBOBJ_x64 := $(addprefix $(BUILDFOLDER)/$(LIB_x64_OBJ_DIR)/, $(notdir $(LIBSRC:.cpp=.o))) +ifeq ($(BUILD_WIN),1) +LIBOBJ_x32 += $(BUILDFOLDER)/$(LIB_x32_OBJ_DIR)/outLCDriver.o +endif +ifeq ($(BUILD_WIN),2) +LIBOBJ_x64 += $(BUILDFOLDER)/$(LIB_x64_OBJ_DIR)/outLCDriver.o +endif + AUTOGEN_FILES := $(AUTO_DIR_LIB)/command_ids.h\ $(AUTO_DIR_LIB)/commands.h\ $(AUTO_DIR_LIB)/commands_impl.h\ @@ -68,7 +91,6 @@ AUTOGEN_FILES := $(AUTO_DIR_LIB)/command_ids.h\ #include directories INCLUDES := \ -Isource\ - -Isource/api_wrappers/linux\ -Isource/utilities\ -Isource/LCM\ -Isource/LCM/include\ @@ -77,24 +99,85 @@ INCLUDES := \ -Isource/security_algorithms/sha\ -I$(AUTO_DIR_LIB) +ifeq ($(BUILD_WIN),) +INCLUDES += \ + -Isource/api_wrappers/linux +else +INCLUDES += \ + -Isource/api_wrappers/windows +endif + +BYTE_ORDER := -DLITTLE_ENDIAN=1234 -DBIG_ENDIAN=4321 -DBYTE_ORDER=LITTLE_ENDIAN # C++ compiler flags (-g -O2 -Wall) +ifeq ($(BUILD_WIN),) CXXFLAGS := -c -O2 -Wall -fPIC -fvisibility=hidden -fno-strict-aliasing -DLCDRIVER_EXPORTS -D_FILE_OFFSET_BITS=64 +else +# For Windows x32 and x64 version compile flags +CXXFLAGS := -D__WIN32__ -mwindows -mthreads -fno-strict-aliasing -Wall $(BYTE_ORDER) -DWIN32 -DWIN32_LEAN_AND_MEAN -DNDEBUG -D_WINDOWS -D_USRDLL -DLCDRIVER_EXPORTS -D_FILE_OFFSET_BITS=64 +endif +ifeq ($(BUILD_WIN),) LDFLAGS := -fPIC -fvisibility=hidden -lpthread -ldl -shared -Wl -o liblcdriver.$(LIB_EXTENSION) +else +# Win x32 linker flags +ifeq ($(BUILD_WIN),1) +LDFLAGS := -D__WIN32__ -s -mwindows -mthreads -mdll -Wl -o LCDriver_CNH1606432.dll +endif +# Win x64 linker flags +ifeq ($(BUILD_WIN),2) +LDFLAGS := -D__WIN32__ -s -mwindows -mthreads -mdll -Wl -o LCDriver_CNH1606432_x64.dll +endif +endif + +build: $(SCRIPT) + $(MAKE) -C . start-build +# Start Win x32 Build +ifeq ($(USE_MINGW_X32),1) + bash $(LCD_DIR)source/gen_rc.sh --lcd + $(MAKE) -C . start-build BUILD_WIN=1 +else + @echo "*** warning: No Cross Compiler $(MINGW_X32_CC)g++ found ***" +endif +# Start Win x64 Build +ifeq ($(USE_MINGW_X64),1) + bash $(LCD_DIR)source/gen_rc.sh --lcd + $(MAKE) -C . start-build BUILD_WIN=2 +else + @echo "*** warning: No Cross Compiler $(MINGW_X64_CC)g++ found ***" +endif LBITS := $(shell getconf LONG_BIT) + +# +# do Linux stuff here +# +ifeq ($(BUILD_WIN),) + ifeq ($(LBITS),64) # # do 64 bit stuff here, like set some CFLAGS # CXXFLAGS += -DLINUX_64 -build: configfile setup_folders $(LIB_x32) $(LIB_x64) +start-build: configfile setup_folders $(LIB_x32) $(LIB_x64) else # # do 32 bit stuff here # CXXFLAGS += -DLINUX_32 -build: configfile setup_folders $(LIB_x32) +start-build: configfile setup_folders $(LIB_x32) +endif + +else +# +# do Windows stuff here +# +ifeq ($(BUILD_WIN),1) +start-build: configfile setup_folders $(LIB_x32) +endif +ifeq ($(BUILD_WIN),2) +start-build: configfile setup_folders $(LIB_x64) +endif + endif $(LIB_x32): $(LIBOBJ_x32) @@ -104,7 +187,7 @@ $(LIB_x64): $(LIBOBJ_x64) $(CXX) $(LDFLAGS) -o $(LIB_x64) $(addprefix $(BUILDFOLDER)/$(LIB_x64_OBJ_DIR)/, $(^F)) # -# Source files build +# Source files build x32 # $(BUILDFOLDER)/$(LIB_x32_OBJ_DIR)/%.o: source/utilities/%.cpp $(AUTOGEN_FILES) @mkdir -p $(dir $@) @@ -122,10 +205,6 @@ $(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) @@ -138,7 +217,21 @@ $(BUILDFOLDER)/$(LIB_x32_OBJ_DIR)/%.o: source/security_algorithms/%.cpp $(AUTOGE @mkdir -p $(dir $@) $(CXX) $(INCLUDES) $(CXXFLAGS) -m32 -c $< -o $(BUILDFOLDER)/$(LIB_x32_OBJ_DIR)/$(@F) -### +ifeq ($(BUILD_WIN),) +$(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) +endif + +ifeq ($(BUILD_WIN),1) +$(BUILDFOLDER)/$(LIB_x32_OBJ_DIR)/%.o: out/autogen/outLCDriver.rc $(AUTOGEN_FILES) + @mkdir -p $(dir $@) + $(MINGW_X32_CC)windres out/autogen/outLCDriver.rc $(BUILDFOLDER)/$(LIB_x32_OBJ_DIR)/$(@F) +endif + +# +# Source files build x64 +# $(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) @@ -155,10 +248,6 @@ $(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) @@ -171,6 +260,18 @@ $(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) +ifeq ($(BUILD_WIN),) +$(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) +endif + +ifeq ($(BUILD_WIN),2) +$(BUILDFOLDER)/$(LIB_x64_OBJ_DIR)/%.o: out/autogen/outLCDriver.rc $(AUTOGEN_FILES) + @mkdir -p $(dir $@) + $(MINGW_X64_CC)windres out/autogen/outLCDriver.rc $(BUILDFOLDER)/$(LIB_x64_OBJ_DIR)/$(@F) +endif + #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..." @@ -257,43 +358,77 @@ configfile: $(if $(wildcard $(config_file)),,config) @echo $< > /dev/null .PHONY: config -config: BUILDFOLDER := $(LCD_DIR)/out -config: AUTO_DIR_LIB :=$(BUILDFOLDER)/autogen/ -config: LIB_x32 := $(BUILDFOLDER)/liblcdriver.$(LIB_EXTENSION) -config: LIB_x64 := $(BUILDFOLDER)/liblcdriver_x64.$(LIB_EXTENSION) config: LIB_x32_OBJ_DIR := x32 config: LIB_x64_OBJ_DIR := x64 -config: CXX := $(CROSS_PREFIX)g++ config: LCD_INSTALLDIR := /tmp/ 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 "BUILDOUT := \$$(LCD_DIR)out" >> $(config_file) + + @echo "ifeq (\$$(BUILD_WIN),)" >> $(config_file) + @echo "BUILDFOLDER := \$$(BUILDOUT)/out_linux" >> $(config_file) + @echo "CXX := $(CROSS_PREFIX)g++" >> $(config_file) + @echo "LIB_x32 := \$$(BUILDFOLDER)/liblcdriver.$(LIB_EXTENSION)" >> $(config_file) + @echo "LIB_x64 := \$$(BUILDFOLDER)/liblcdriver_x64.$(LIB_EXTENSION)" >> $(config_file) + @echo "else" >> $(config_file) + + @echo "ifeq (\$$(BUILD_WIN),1)" >> $(config_file) + @echo "BUILDFOLDER := \$$(BUILDOUT)/out_win" >> $(config_file) + @echo "CXX := $(CROSS_PREFIX)$(MINGW_X32_CC)g++" >> $(config_file) + @echo "LIB_x32 := \$$(BUILDFOLDER)/LCDriver_CNH1606432.dll" >> $(config_file) + @echo "LIB_x64 := \$$(BUILDFOLDER)/LCDriver_CNH1606432_x64.dll" >> $(config_file) + @echo "endif" >> $(config_file) + + @echo "ifeq (\$$(BUILD_WIN),2)" >> $(config_file) + @echo "BUILDFOLDER := \$$(BUILDOUT)/out_win" >> $(config_file) + @echo "CXX := $(CROSS_PREFIX)$(MINGW_X64_CC)g++" >> $(config_file) + @echo "LIB_x32 := \$$(BUILDFOLDER)/LCDriver_CNH1606432.dll" >> $(config_file) + @echo "LIB_x64 := \$$(BUILDFOLDER)/LCDriver_CNH1606432_x64.dll" >> $(config_file) + @echo "endif" >> $(config_file) + + @echo "endif" >> $(config_file) + @echo "AUTO_DIR_LIB := \$$(BUILDOUT)/autogen/" >> $(config_file) @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: + $(MAKE) -C . start-install +ifeq ($(USE_MINGW_X32),1) + $(MAKE) -C . start-install BUILD_WIN=1 +endif +ifeq ($(USE_MINGW_X64),1) + $(MAKE) -C . start-install BUILD_WIN=2 +endif + +start-install: start-build +ifeq ($(BUILD_WIN),) install -m 0755 $(BUILDFOLDER)/liblcdriver.$(LIB_EXTENSION) $(LCD_INSTALLDIR) ifeq ($(LBITS),64) install -m 0755 $(BUILDFOLDER)/liblcdriver_x64.$(LIB_EXTENSION) $(LCD_INSTALLDIR) endif - install -m 0755 $(WIN_BINARIES)/*.dll $(LCD_INSTALLDIR) +else + + install -m 0755 $(LCD_DIR)mingw_prebuilt/mingwm10.dll $(LCD_INSTALLDIR) +ifeq ($(BUILD_WIN),1) + install -m 0755 $(BUILDFOLDER)/LCDriver_CNH1606432.dll $(LCD_INSTALLDIR) +endif +ifeq ($(BUILD_WIN),2) + install -m 0755 $(BUILDFOLDER)/LCDriver_CNH1606432_x64.dll $(LCD_INSTALLDIR) +endif + +endif + clean: + $(MAKE) -C . start-clean + $(MAKE) -C . start-clean BUILD_WIN=1 + $(MAKE) -C . start-clean BUILD_WIN=2 + +start-clean: + @rm -f $(LCD_DIR)out/autogen/outLCDriver.rc $(if $(BUILDFOLDER), \ $(if $(LIB_x32_OBJ_DIR), \ @rm -rf $(BUILDFOLDER)/$(LIB_x32_OBJ_DIR) \ @@ -306,16 +441,21 @@ ifeq ($(LBITS),64) endif $(if $(BUILDFOLDER), \ @rm -f $(BUILDFOLDER)/*.so* \ + @rm -f $(BUILDFOLDER)/*.dll \ @rm -rf $(BUILDFOLDER),) + $(if ${BUILDOUT}, \ + @rm -rf ${BUILDOUT},) 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)/LCDriver_CNH1606432.dll \ @rm -f $(LCD_INSTALLDIR)/liblcdriver.$(LIB_EXTENSION),) ifeq ($(LBITS),64) $(if $(LCD_INSTALLDIR), \ + @rm -f $(LCD_INSTALLDIR)/LCDriver_CNH1606432_x64.dll \ @rm -f $(LCD_INSTALLDIR)/liblcdriver_x64.$(LIB_EXTENSION),) endif $(if $(config_file), \ diff --git a/lcmodule/Makefile b/lcmodule/Makefile index ede3f3f..e464e8b 100644 --- a/lcmodule/Makefile +++ b/lcmodule/Makefile @@ -6,6 +6,8 @@ endif -include $(config_file) +MINGW_X32_CC:=i586-mingw32msvc- +MINGW_X64_CC:=amd64-mingw32msvc- LCM_PATH:=./ TRANSPORT_PATH:=${LCM_PATH}/source/cnh1605204_ldr_transport_layer/ NETWORK_PATH:=${LCM_PATH}/source/cnh1605205_ldr_network_layer/ @@ -17,7 +19,18 @@ SECURITY_ALGORITHMS_PATH:=$(LOADER_DIR)/src/loader_code_base/cnh1605721_ldr_secu LCM_CONFIG:=$(LCM_CNH_PATH)/config LCM_CUST_CONFIG:=$(LCM_PATH)/customer_config SUPPORTED_CMDS_PATH:=$(LOADER_DIR)/src/platform_support/stn8500/config/supported_commands.xml -WIN_BINARIES=./win_binaries/ + +ifneq ($(shell which $(MINGW_X32_CC)gcc), ) +USE_MINGW_X32 := 1 +else +USE_MINGW_X32 := 0 +endif + +ifneq ($(shell which $(MINGW_X64_CC)gcc), ) +USE_MINGW_X64 := 1 +else +USE_MINGW_X64 := 0 +endif OS_NAME := $(shell uname) ifeq ($(OS_NAME), Linux) @@ -67,12 +80,23 @@ LIBSRC :=${TRANSPORT_PATH}/source/bulk_protocol.c\ ${LCM_CNH_PATH}/source/z_family.c\ ${LCM_CNH_PATH}/source/r15_family.c\ ${LCM_CNH_PATH}/source/a2_family.c\ - ${LCM_PATH}/source/cnh1605551_ldr_utilities/critical_section/critical_section_linux.c\ ${LCM_PATH}/source/serialization.c +ifeq ($(BUILD_WIN),) +LIBSRC += ${LCM_PATH}/source/cnh1605551_ldr_utilities/critical_section/critical_section_linux.c +else +LIBSRC += ${LCM_PATH}/source/cnh1605551_ldr_utilities/critical_section/critical_section_win32.c +endif LIBOBJ_x32 := $(addprefix $(BUILDFOLDER)/$(LIB_x32_OBJ_DIR)/, $(notdir $(LIBSRC:.c=.o))) LIBOBJ_x64 := $(addprefix $(BUILDFOLDER)/$(LIB_x64_OBJ_DIR)/, $(notdir $(LIBSRC:.c=.o))) +ifeq ($(BUILD_WIN),1) +LIBOBJ_x32 += $(BUILDFOLDER)/$(LIB_x32_OBJ_DIR)/outLCM.o +endif +ifeq ($(BUILD_WIN),2) +LIBOBJ_x64 += $(BUILDFOLDER)/$(LIB_x64_OBJ_DIR)/outLCM.o +endif + #-I ${AUTO_DIR)\ # -I ${LCM_PATH}/include/ #include directories @@ -91,27 +115,70 @@ INCLUDES := -I. \ -I ${LCM_PATH}/source/legacy_compatibility/\ # C compiler flags (-g -O2 -Wall) +ifeq ($(BUILD_WIN),) CFLAGS := -g -O2 -Wall -fPIC -fvisibility=hidden -DUINT64_SUPPORTED -DSINT64_SUPPORTED -DINT64_BASE_TYPE="long long" -DCFG_ENABLE_A2_FAMILY -DLCM_EXPORTS +else +# For Windows x32 and x64 version compile flags +CFLAGS := -Wall -D__WIN32__ -mthreads -mwindows -DWIN32 -DNDEBUG -D_WINDOWS -D_USRDLL -DLCM_EXPORTS +endif + +build: + $(MAKE) -C . start-build +ifeq ($(USE_MINGW_X32),1) + bash ${LCM_PATH}/../source/gen_rc.sh --lcm + $(MAKE) -C . start-build BUILD_WIN=1 +else + @echo "*** warning: No Cross Compiler $(MINGW_X32_CC)gcc found ***" +endif +ifeq ($(USE_MINGW_X64),1) + bash ${LCM_PATH}/../source/gen_rc.sh --lcm + $(MAKE) -C . start-build BUILD_WIN=2 +else + @echo "*** warning: No Cross Compiler $(MINGW_X64_CC)gcc found ***" +endif LBITS := $(shell getconf LONG_BIT) + +# +# do Linux stuff here +# +ifeq ($(BUILD_WIN),) + ifeq ($(LBITS),64) # # do 64 bit stuff here, like set some CFLAGS # -build: configfile setup_folders $(LIB_x32) $(LIB_x64) +start-build: configfile setup_folders $(LIB_x32) $(LIB_x64) else # # do 32 bit stuff here # -build: configfile setup_folders $(LIB_x32) +start-build: configfile setup_folders $(LIB_x32) +endif + +else +# +# do Windows stuff here +# +ifeq ($(BUILD_WIN),1) +start-build: configfile setup_folders $(LIB_x32) +endif +ifeq ($(BUILD_WIN),2) +start-build: configfile setup_folders $(LIB_x64) endif +endif + + $(LIB_x32): $(LIBOBJ_x32) - $(CC) -shared -m32 -Wl -o $(LIB_x32) -lc $(addprefix $(BUILDFOLDER)/$(LIB_x32_OBJ_DIR)/, $(^F)) + $(CC) -shared -m32 -Wl -o $(LIB_x32) $(LINKOPTS) $(addprefix $(BUILDFOLDER)/$(LIB_x32_OBJ_DIR)/, $(^F)) $(LIB_x64): $(LIBOBJ_x64) - $(CC) -shared -Wl -o $(LIB_x64) -lc $(addprefix $(BUILDFOLDER)/$(LIB_x64_OBJ_DIR)/, $(^F)) + $(CC) -shared -Wl -o $(LIB_x64) $(LINKOPTS) $(addprefix $(BUILDFOLDER)/$(LIB_x64_OBJ_DIR)/, $(^F)) +# +# Source files build x32 +# $(BUILDFOLDER)/$(LIB_x32_OBJ_DIR)/%.o: ${TRANSPORT_PATH}/source/%.c $(AUTOGEN_FILES) @mkdir -p $(dir $@) $(CC) $(INCLUDES) $(CFLAGS) -c -m32 $< -o $(BUILDFOLDER)/$(LIB_x32_OBJ_DIR)/$(@F) @@ -132,6 +199,15 @@ $(BUILDFOLDER)/$(LIB_x32_OBJ_DIR)/%.o: ${LCM_PATH}/source/%.c $(AUTOGEN_FILES) @mkdir -p $(dir $@) $(CC) $(INCLUDES) $(CFLAGS) -c -m32 $< -o $(BUILDFOLDER)/$(LIB_x32_OBJ_DIR)/$(@F) +ifeq ($(BUILD_WIN),1) +$(BUILDFOLDER)/$(LIB_x32_OBJ_DIR)/%.o: out/autogen/outLCM.rc $(AUTOGEN_FILES) + @mkdir -p $(dir $@) + $(MINGW_X32_CC)windres out/autogen/outLCM.rc $(BUILDFOLDER)/$(LIB_x32_OBJ_DIR)/$(@F) +endif + +# +# Source files build x64 +# $(BUILDFOLDER)/$(LIB_x64_OBJ_DIR)/%.o: ${TRANSPORT_PATH}/source/%.c $(AUTOGEN_FILES) @mkdir -p $(dir $@) $(CC) $(INCLUDES) $(CFLAGS) -c $< -o $(BUILDFOLDER)/$(LIB_x64_OBJ_DIR)/$(@F) @@ -152,6 +228,12 @@ $(BUILDFOLDER)/$(LIB_x64_OBJ_DIR)/%.o: ${LCM_PATH}/source/%.c $(AUTOGEN_FILES) @mkdir -p $(dir $@) $(CC) $(INCLUDES) $(CFLAGS) -c $< -o $(BUILDFOLDER)/$(LIB_x64_OBJ_DIR)/$(@F) +ifeq ($(BUILD_WIN),2) +$(BUILDFOLDER)/$(LIB_x64_OBJ_DIR)/%.o: out/autogen/outLCM.rc $(AUTOGEN_FILES) + @mkdir -p $(dir $@) + $(MINGW_X64_CC)windres out/autogen/outLCM.rc $(BUILDFOLDER)/$(LIB_x64_OBJ_DIR)/$(@F) +endif + #Autogen files $(AUTO_DIR_LIB)/commands.h: $(LCM_CONFIG)/commands.xml $(LCM_CONFIG)/commands_h.xsl | setup_folders java -classpath $(LCM_PATH)/tools/xalan-j_2_7_1/xalan.jar org.apache.xalan.xslt.Process -in $(LCM_CONFIG)/commands.xml -xsl $(LCM_CONFIG)/commands_h.xsl -out $@ -PARAM target lcm @@ -279,55 +361,54 @@ configfile: $(if $(wildcard $(config_file)),,config) @echo $< > /dev/null .PHONY: config -config: BUILDFOLDER := $(LCM_PATH)/out -config: LCM_AUTO_DIR:=$(BUILDFOLDER)/autogen -config: AUTO_DIR_LIB:=$(LCM_AUTO_DIR)/lib -config: AUTO_DIR_LOADER:=$(LCM_AUTO_DIR)/loader -config: LIB_x32 := $(BUILDFOLDER)/liblcm.$(LIB_EXTENSION) -config: LIB_x64 := $(BUILDFOLDER)/liblcm_x64.$(LIB_EXTENSION) config: LCMLIB_INSTALLDIR := /tmp/ config: LCMLDR_INSTALLDIR := /tmp/ config: LIB_x32_OBJ_DIR := x32 config: LIB_x64_OBJ_DIR := x64 -config: CC := gcc config: LOADER_DIR := ./ config: @echo Generating config file... @echo config_file : $(config_file) @rm -f $(config_file) @touch $(config_file) - @echo CC: $(CC) - @echo "CC := $(CC)" >> $(config_file) - @echo LOADER_DIR: $(LOADER_DIR) + @echo "BUILDOUT := \$$(LCM_PATH)/out" >> $(config_file) + + @echo "ifeq (\$$(BUILD_WIN),)" >> $(config_file) + @echo "BUILDFOLDER := \$$(BUILDOUT)/out_linux" >> $(config_file) + @echo "CC := gcc" >> $(config_file) + @echo "LIB_x32 := \$$(BUILDFOLDER)/liblcm.$(LIB_EXTENSION)" >> $(config_file) + @echo "LIB_x64 := \$$(BUILDFOLDER)/liblcm_x64.$(LIB_EXTENSION)" >> $(config_file) + @echo "LINKOPTS := -lc" >> $(config_file) + @echo "else" >> $(config_file) + + @echo "ifeq (\$$(BUILD_WIN),1)" >> $(config_file) + @echo "BUILDFOLDER := \$$(BUILDOUT)/out_win" >> $(config_file) + @echo "CC := $(MINGW_X32_CC)gcc" >> $(config_file) + @echo "LIB_x32 := \$$(BUILDFOLDER)/LCM.dll" >> $(config_file) + @echo "LIB_x64 := \$$(BUILDFOLDER)/LCM_x64.dll" >> $(config_file) + @echo "LINKOPTS := -s -mthreads" >> $(config_file) + @echo "endif" >> $(config_file) + + @echo "ifeq (\$$(BUILD_WIN),2)" >> $(config_file) + @echo "BUILDFOLDER := \$$(BUILDOUT)/out_win" >> $(config_file) + @echo "CC := $(MINGW_X64_CC)gcc" >> $(config_file) + @echo "LIB_x32 := \$$(BUILDFOLDER)/LCM.dll" >> $(config_file) + @echo "LIB_x64 := \$$(BUILDFOLDER)/LCM_x64.dll" >> $(config_file) + @echo "LINKOPTS := -s -mthreads" >> $(config_file) + @echo "endif" >> $(config_file) + + @echo "endif" >> $(config_file) + @echo "LCM_AUTO_DIR := \$$(BUILDOUT)/autogen" >> $(config_file) + @echo "AUTO_DIR_LIB := \$$(LCM_AUTO_DIR)/lib" >> $(config_file) + @echo "AUTO_DIR_LOADER := \$$(LCM_AUTO_DIR)/loader" >> $(config_file) @echo "LOADER_DIR := $(LOADER_DIR)" >> $(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 LCM_AUTO_DIR: $(LCM_AUTO_DIR) - @echo "LCM_AUTO_DIR := $(LCM_AUTO_DIR)" >> $(config_file) - @echo LCMLIB_INSTALLDIR: $(LCMLIB_INSTALLDIR) @echo "LCMLIB_INSTALLDIR := $(LCMLIB_INSTALLDIR)" >> $(config_file) - @echo LCMLDR_INSTALLDIR: $(LCMLDR_INSTALLDIR) @echo "LCMLDR_INSTALLDIR := $(LCMLDR_INSTALLDIR)" >> $(config_file) - @echo AUTO_DIR_LOADER: $(AUTO_DIR_LOADER) - @echo "AUTO_DIR_LOADER := $(AUTO_DIR_LOADER)" >> $(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 CONFIG_DIR : $(CONFIG_DIR) -install: build - install -p -m 0755 ${BUILDFOLDER}/liblcm.$(LIB_EXTENSION) ${LCMLIB_INSTALLDIR} -ifeq ($(LBITS),64) - install -p -m 0755 ${BUILDFOLDER}/liblcm_x64.$(LIB_EXTENSION) ${LCMLIB_INSTALLDIR} -endif - install -p -m 0755 $(WIN_BINARIES)/*.dll ${LCMLIB_INSTALLDIR} +install: install -p -m 0555 ${AUTO_DIR_LOADER}/* ${LCMLDR_INSTALLDIR} install -p -m 0555 ${TRANSPORT_PATH}/source/*.c ${LCMLDR_INSTALLDIR} install -p -m 0555 ${NETWORK_PATH}/source/*.c ${LCMLDR_INSTALLDIR} @@ -337,7 +418,36 @@ endif install -p -m 0555 ${LCM_CNH_PATH}/include/*.h ${LCMLDR_INSTALLDIR} install -p -m 0555 ${LCM_PATH}/source/serialization.c ${LCMLDR_INSTALLDIR} + $(MAKE) -C . start-install +ifeq ($(USE_MINGW_X32),1) + $(MAKE) -C . start-install BUILD_WIN=1 +endif +ifeq ($(USE_MINGW_X64),1) + $(MAKE) -C . start-install BUILD_WIN=2 +endif + +start-install: start-build +ifeq ($(BUILD_WIN),) + install -p -m 0755 $(LIB_x32) ${LCMLIB_INSTALLDIR} +ifeq ($(LBITS),64) + install -p -m 0755 $(LIB_x64) ${LCMLIB_INSTALLDIR} +endif +else +ifeq ($(BUILD_WIN),1) + install -p -m 0755 $(LIB_x32) ${LCMLIB_INSTALLDIR} +endif +ifeq ($(BUILD_WIN),2) + install -p -m 0755 $(LIB_x64) ${LCMLIB_INSTALLDIR} +endif +endif + clean: + $(MAKE) -C . start-clean + $(MAKE) -C . start-clean BUILD_WIN=1 + $(MAKE) -C . start-clean BUILD_WIN=2 + +start-clean: + @rm -f $(LCM_PATH)out/autogen/outLCM.rc $(if ${BUILDFOLDER}, \ $(if ${LIB_x32_OBJ_DIR}, \ @rm -rf ${BUILDFOLDER}/${LIB_x32_OBJ_DIR}/*.o \ @@ -352,7 +462,10 @@ ifeq ($(LBITS),64) endif $(if ${BUILDFOLDER}, \ @rm -f ${BUILDFOLDER}/*.so* \ + @rm -f $(BUILDFOLDER)/*.dll \ @rm -rf ${BUILDFOLDER},) + $(if ${BUILDOUT}, \ + @rm -rf ${BUILDOUT},) distclean: clean $(if ${LCMLDR_INSTALLDIR}, \ @@ -448,6 +561,8 @@ distclean: clean @rm -f ${LCMLDR_INSTALLDIR}/z_transport.c \ @rm -f ${LCMLDR_INSTALLDIR}/r15_transport_layer.c \ @rm -f ${LCMLDR_INSTALLDIR}/t_a2_network.h \ + @rm -f ${LCMLIB_INSTALLDIR}/LCM.dll \ + @rm -f $(LCMLIB_INSTALLDIR)/LCM_x64.dll \ @rm -f ${LCMLIB_INSTALLDIR}/liblcm.$(LIB_EXTENSION),) ifeq ($(LBITS),64) $(if ${LCMLDR_INSTALLDIR}, \ @@ -477,3 +592,8 @@ coverity: @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 + +astyle: + astyle --style=k/r --indent=spaces --break-blocks --convert-tabs --add-brackets \ + --unpad-paren --pad-header --pad-oper --indent-col1-comments --align-pointer=name \ + -R "*.h" -R "*.c" diff --git a/lcmodule/source/LCM.rc b/lcmodule/source/LCM.rc deleted file mode 100644 index 61bc97a..0000000 --- a/lcmodule/source/LCM.rc +++ /dev/null @@ -1,103 +0,0 @@ -// Microsoft Visual C++ generated resource script. -// -#include "resource.h" - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#include "windows.h" - -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// English (U.S.) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US -#pragma code_page(1252) -#endif //_WIN32 - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE -BEGIN - "resource.h\0" -END - -2 TEXTINCLUDE -BEGIN - "#include ""windows.h""\r\n" - "\0" -END - -3 TEXTINCLUDE -BEGIN - "\r\n" - "\0" -END - -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// Version -// - -VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,0,0,1 - PRODUCTVERSION 1,0,0,1 - FILEFLAGSMASK 0x1fL -#ifdef _DEBUG - FILEFLAGS 0x9L -#else - FILEFLAGS 0x8L -#endif - FILEOS 0x4L - FILETYPE 0x2L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904b0" - BEGIN - VALUE "Comments", "Build date: 2012-03-14" - VALUE "CompanyName", "STEricsson AB" - VALUE "FileDescription", "LCM Dynamic Link Library" - VALUE "FileVersion", "1, 0, 0, 1" - VALUE "InternalName", "Loader Communication Module" - VALUE "LegalCopyright", "Copyright (C) STEricsson AB 2012" - VALUE "PrivateBuild", "Change-Id: I2f2835b56857eb9640501ff681400517600ccdef" - VALUE "ProductName", "CXA1104507 Loader Communication Module" - VALUE "ProductVersion", "P5Y" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 1200 - END -END - -#endif // English (U.S.) resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// - - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - diff --git a/lcmodule/source/LCM.vcproj b/lcmodule/source/LCM.vcproj index 86b8f4c..ae70436 100644 --- a/lcmodule/source/LCM.vcproj +++ b/lcmodule/source/LCM.vcproj @@ -1,943 +1,939 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/mingw_prebuilt/mingwm10.dll b/mingw_prebuilt/mingwm10.dll new file mode 100644 index 0000000..926fb6c Binary files /dev/null and b/mingw_prebuilt/mingwm10.dll differ diff --git a/source/CEH/commands_types.h b/source/CEH/commands_types.h index eec039c..7231edf 100644 --- a/source/CEH/commands_types.h +++ b/source/CEH/commands_types.h @@ -62,4 +62,4 @@ struct TEntriesInternal { } }; -#endif // _COMMANDS_TYPES_H_ \ No newline at end of file +#endif // _COMMANDS_TYPES_H_ diff --git a/source/LCDriver.h b/source/LCDriver.h index 0456570..314a8fd 100644 --- a/source/LCDriver.h +++ b/source/LCDriver.h @@ -11,6 +11,10 @@ #define LCDRIVER_API __declspec(dllexport) #else #define LCDRIVER_API __declspec(dllimport) +#endif //LCDRIVER_EXPORTS + +#ifndef __int64 +#define __int64 long long #endif typedef unsigned __int64 uint64; diff --git a/source/LCDriver.rc b/source/LCDriver.rc deleted file mode 100644 index 0b30f01..0000000 --- a/source/LCDriver.rc +++ /dev/null @@ -1,115 +0,0 @@ -// Microsoft Visual C++ generated resource script. -// -#include "resource.h" - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#include "windows.h" - -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// English (U.S.) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US -#pragma code_page(1252) -#endif //_WIN32 - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE -BEGIN - "resource.h\0" -END - -2 TEXTINCLUDE -BEGIN - "#include ""windows.h""\r\n" - "\0" -END - -3 TEXTINCLUDE -BEGIN - "\r\n" - "\0" -END - -#endif // APSTUDIO_INVOKED - -#endif // English (U.S.) resources -///////////////////////////////////////////////////////////////////////////// - - -///////////////////////////////////////////////////////////////////////////// -// English (U.K.) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENG) -#ifdef _WIN32 -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_UK -#pragma code_page(1252) -#endif //_WIN32 - -///////////////////////////////////////////////////////////////////////////// -// -// Version -// - -VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,0,0,1 - PRODUCTVERSION 1,0,0,1 - FILEFLAGSMASK 0x1fL -#ifdef _DEBUG - FILEFLAGS 0x9L -#else - FILEFLAGS 0x8L -#endif - FILEOS 0x4L - FILETYPE 0x2L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "000904b0" - BEGIN - VALUE "Comments", "Build date: 2012-03-14" - VALUE "CompanyName", "STEricsson AB" - VALUE "FileDescription", "LCDriver Dynamic Link Library" - VALUE "FileVersion", "1, 0, 0, 1" - VALUE "InternalName", "Loader Communication Driver" - VALUE "LegalCopyright", "Copyright (C) STEricsson AB 2012" - VALUE "PrivateBuild", "Change-Id: I2f2835b56857eb9640501ff681400517600ccdef" - VALUE "ProductName", "CXC 173 0865, LCDriver DLL" - VALUE "ProductVersion", "P5Y" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x9, 1200 - END -END - -#endif // English (U.K.) resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// - - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - diff --git a/source/LCDriver.vcproj b/source/LCDriver.vcproj index 21feb76..703954c 100644 --- a/source/LCDriver.vcproj +++ b/source/LCDriver.vcproj @@ -1,7 +1,7 @@ - - diff --git a/source/api_wrappers/linux/LinuxApiWrappers.h b/source/api_wrappers/linux/LinuxApiWrappers.h index b63b840..b89e42f 100644 --- a/source/api_wrappers/linux/LinuxApiWrappers.h +++ b/source/api_wrappers/linux/LinuxApiWrappers.h @@ -15,6 +15,7 @@ #include "CWaitableObject.h" #include "CWaitableObjectCollection.h" #include "OS.h" +#include "String_s.h" #endif /* _LINUXAPIWRAPPERS_H */ diff --git a/source/api_wrappers/linux/OS.cpp b/source/api_wrappers/linux/OS.cpp index 6ed6425..aaaa592 100644 --- a/source/api_wrappers/linux/OS.cpp +++ b/source/api_wrappers/linux/OS.cpp @@ -2,7 +2,6 @@ * Copyright (C) ST-Ericsson SA 2011 * License terms: 3-clause BSD license ******************************************************************************/ - #include #include #include @@ -59,32 +58,3 @@ timespec OS::GetAbsoluteTime(DWORD dwTimeout) return absolute_time; } - - -char *strcpy_s(char *dst, size_t _Size, const char *src) -{ - return strncpy(dst, src, _Size); -} - -int sprintf_s(char *dst, size_t _Size, const char *format, ...) -{ - va_list l; - int ReturnValue; - - va_start(l, format); - ReturnValue = vsnprintf(dst, _Size, format, l); - va_end(l); - - return ReturnValue; -} - -char *strncpy_s(char *dst, const char *src, size_t _Size) -{ - return strncpy(dst, src, _Size); -} - -int _stricmp(const char *s1, const char *s2) -{ - return strcasecmp(s1, s2); -} - diff --git a/source/api_wrappers/linux/OS.h b/source/api_wrappers/linux/OS.h index b79c6ea..ad1e7af 100644 --- a/source/api_wrappers/linux/OS.h +++ b/source/api_wrappers/linux/OS.h @@ -7,9 +7,6 @@ #define _OS_H #include #include -#include -#include -#include #include #include "Types.h" @@ -36,74 +33,4 @@ private: static DWORD ErrorCode; }; - -#define MAX(a, b) ((a) > (b) ? (a) : (b)) - -/* - * str manipulation functions used in windows build - */ - -char *strcpy_s(char *dst, size_t _Size, const char *src); -char *strncpy_s(char *dst, const char *src, size_t _Size); -int _stricmp(const char *s1, const char *s2); -int sprintf_s(char *dst, size_t _Size, const char *format, ...); - -#define _snprintf snprintf - -template -char *strcpy_s(char(&dst)[_Size], const char src[]) -{ - return strncpy(dst, src, _Size); -} - -template -int sprintf_s(char(&dst)[_Size], const char *format, ...) -{ - int ReturnValue; - va_list l; - va_start(l, format); - ReturnValue = vsnprintf(dst, _Size, format, l); - va_end(l); - return ReturnValue; -} - -template -char *strcat_s(char(&dst)[_Size], const char src[]) -{ - return strncat(dst, src, _Size); -} - -template -int _ultoa_s(unsigned long value, char(&str)[_Size], int radix) -{ - switch (radix) { - case 10: - return sprintf_s(str, "%ul", value); - - case 16: - return sprintf_s(str, "%ulX", value); - - default: - return -1; - } -} - -template -int _snprintf_s(char(&dst)[_Size], size_t _MaxCount, const char *format, ...) -{ - int ReturnValue; - va_list l; - va_start(l, format); - ReturnValue = vsnprintf(dst, MAX(_MaxCount, _Size), format, l); - va_end(l); - return ReturnValue; -} - -template -int vsprintf_s(char(&dst)[_Size], const char *format, va_list l) -{ - return vsnprintf(dst, _Size, format, l); -} - #endif /* _OS_H */ - diff --git a/source/api_wrappers/windows/WinApiWrappers.h b/source/api_wrappers/windows/WinApiWrappers.h index f3fbfa1..2d5a7ed 100644 --- a/source/api_wrappers/windows/WinApiWrappers.h +++ b/source/api_wrappers/windows/WinApiWrappers.h @@ -22,6 +22,11 @@ #include #include #include +#ifdef __MINGW32__ +#include "String_s.h" +#include +#endif + using namespace std; class CWaitableObject @@ -95,20 +100,6 @@ public: DWORD Wait(DWORD milliseconds = INFINITE) { return ::WaitForSingleObject(m_Handle, milliseconds); } - void WaitForAllEvents(HANDLE *pHandles, int iHandles, DWORD msec = INFINITE) { - ::WaitForMultipleObjects( - iHandles, // Number of objects in handles - pHandles, - TRUE, // Wait all events - msec); - } // Wait indefinitely default i.e. INFINITE - int WaitForFirstEvent(HANDLE *pHandles, int iHandles, DWORD msec = INFINITE) { - ::WaitForMultipleObjects( - iHandles, // Number of objects in handles - pHandles, - FALSE, // Wait for first event object - msec); - } // Wait indefinitely default i.e. INFINITE HANDLE GetHandle() { return m_Handle; } diff --git a/source/gen_rc.sh b/source/gen_rc.sh new file mode 100755 index 0000000..61400ab --- /dev/null +++ b/source/gen_rc.sh @@ -0,0 +1,168 @@ +#!/usr/bin/env bash +# ------------------------------------------------------------------------------ +# Copyright (C) ST-Ericsson SA 2012 +# License terms: 3-clause BSD license +# ------------------------------------------------------------------------------ + +#-------- Global vars init values ----------- + +#script version +SCRIPT_VERSION="v1.0" + +#printout stream channels +error_channel=/dev/stderr +normal_channel=/dev/stdout +stream_channel=$normal_channel + +#current date +DATE="" + +#git revision info +VERSION="" + +LCD_RC_PATH=out/autogen/outLCDriver.rc +LCM_RC_PATH=out/autogen/outLCM.rc + +# ------------------------------INTERNAL FUNCTIONS ---------------------------- + +function show_err() +{ + cat >> $stream_channel << INLINE_DOC + +Syntax ERROR! +Try reading the script help info +$0 --help + +INLINE_DOC +} + +function get_help() +{ + cat >> $stream_channel << INLINE_DOC +================================ HELP ================================ +The purpose of this script is generating resource .rc files +that will be used by the resource compiler in order to +produce compiled resource files .res +This res files will be used by the linker when it will try to embedd +the version info into the executables. + +INLINE_DOC +} + +function get_init_data() +{ + DATE=`date` + VERSION=`git describe --tags --always --long` +} + +# +# Loader Communication module +# +function process_lcm() +{ + cat > $LCM_RC_PATH << INLINE_DOC +1 VERSIONINFO + FILEVERSION 1,0,0,1 + PRODUCTVERSION 1,0,0,1 + FILEFLAGSMASK 0x1fL +#ifdef _DEBUG + FILEFLAGS 0x9L +#else + FILEFLAGS 0x8L +#endif + FILEOS 0x4L + FILETYPE 0x2L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN +INLINE_DOC +echo " VALUE \"Comments\", \"Build date: $DATE\"" >> $LCM_RC_PATH +cat >> $LCM_RC_PATH << INLINE_DOC + VALUE "CompanyName", "STEricsson AB" + VALUE "FileDescription", "LCM Dynamic Link Library" + VALUE "FileVersion", "1, 0, 0, 1" + VALUE "InternalName", "Loader Communication Module" + VALUE "LegalCopyright", "Copyright (C) STEricsson AB 2012" + VALUE "ProductName", "CXA1104507 Loader Communication Module" +INLINE_DOC +echo " VALUE \"ProductVersion\", \"$VERSION\"" >> $LCM_RC_PATH +cat >> $LCM_RC_PATH << INLINE_DOC + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x9, 1200 + END +END + +INLINE_DOC + +} + +# +# Loader Communication Driver +# +function process_lcd() +{ + cat > $LCD_RC_PATH << INLINE_DOC +1 VERSIONINFO + FILEVERSION 1,0,0,1 + PRODUCTVERSION 1,0,0,1 + FILEFLAGSMASK 0x1fL +#ifdef _DEBUG + FILEFLAGS 0x9L +#else + FILEFLAGS 0x8L +#endif + FILEOS 0x4L + FILETYPE 0x2L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "000904b0" + BEGIN +INLINE_DOC +echo " VALUE \"Comments\", \"Build date: $DATE\"" >> $LCD_RC_PATH +cat >> $LCD_RC_PATH << INLINE_DOC + VALUE "CompanyName", "STEricsson AB" + VALUE "FileDescription", "LCDriver Dynamic Link Library" + VALUE "FileVersion", "1, 0, 0, 1" + VALUE "InternalName", "Loader Communication Driver" + VALUE "LegalCopyright", "Copyright (C) STEricsson AB 2012" + VALUE "ProductName", "CXC 173 0865, LCDriver DLL" +INLINE_DOC +echo " VALUE \"ProductVersion\", \"$VERSION\"" >> $LCD_RC_PATH +cat >> $LCD_RC_PATH << INLINE_DOC + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x9, 1200 + END +END + +INLINE_DOC +} + +# ------------------------------- main script routine ------------------------- +get_init_data +case $1 in + + --lcm) + echo "Generating LCM.rc file .." + process_lcm;; + --lcd) + echo "Generating LCDriver.rc file." + process_lcd;; + + -h|?|--help) + get_help;; + *) + stream_channel=$error_channel + show_err;; +esac + diff --git a/source/security_algorithms/sha/sha2.cpp b/source/security_algorithms/sha/sha2.cpp index 07473e7..ec214f6 100644 --- a/source/security_algorithms/sha/sha2.cpp +++ b/source/security_algorithms/sha/sha2.cpp @@ -85,6 +85,7 @@ * where the appropriate definitions are actually * made). */ + #if !defined(BYTE_ORDER) || (BYTE_ORDER != LITTLE_ENDIAN && BYTE_ORDER != BIG_ENDIAN) #error Define BYTE_ORDER to be equal to either LITTLE_ENDIAN or BIG_ENDIAN #endif diff --git a/source/utilities/Logger.h b/source/utilities/Logger.h index 2388bb4..ec1f0a9 100644 --- a/source/utilities/Logger.h +++ b/source/utilities/Logger.h @@ -30,4 +30,4 @@ private: MessageCallback_t messageCallback_; }; -#endif // _LOGGER_H_ \ No newline at end of file +#endif // _LOGGER_H_ diff --git a/source/utilities/String_s.cpp b/source/utilities/String_s.cpp new file mode 100644 index 0000000..c204ec8 --- /dev/null +++ b/source/utilities/String_s.cpp @@ -0,0 +1,34 @@ +/******************************************************************************* + * Copyright (C) ST-Ericsson SA 2012 + * License terms: 3-clause BSD license + ******************************************************************************/ +#include "String_s.h" + +char *strcpy_s(char *dst, size_t _Size, const char *src) +{ + return strncpy(dst, src, _Size); +} + +int sprintf_s(char *dst, size_t _Size, const char *format, ...) +{ + va_list l; + int ReturnValue; + + va_start(l, format); + ReturnValue = vsnprintf(dst, _Size, format, l); + va_end(l); + + return ReturnValue; +} + +char *strncpy_s(char *dst, const char *src, size_t _Size) +{ + return strncpy(dst, src, _Size); +} + +#ifndef __MINGW32__ +int _stricmp(const char *s1, const char *s2) +{ + return strcasecmp(s1, s2); +} +#endif diff --git a/source/utilities/String_s.h b/source/utilities/String_s.h new file mode 100644 index 0000000..88179e8 --- /dev/null +++ b/source/utilities/String_s.h @@ -0,0 +1,80 @@ +/******************************************************************************* + * Copyright (C) ST-Ericsson SA 2012 + * License terms: 3-clause BSD license + ******************************************************************************/ +#include +#include +#include +#include + +#define MAX(a, b) ((a) > (b) ? (a) : (b)) + +/* + * str manipulation functions used in windows build + */ + +char *strcpy_s(char *dst, size_t _Size, const char *src); +char *strncpy_s(char *dst, const char *src, size_t _Size); +#ifndef __MINGW32__ +int _stricmp(const char *s1, const char *s2); +#endif +int sprintf_s(char *dst, size_t _Size, const char *format, ...); + +#define _snprintf snprintf + +template +char *strcpy_s(char(&dst)[_Size], const char src[]) +{ + return strncpy(dst, src, _Size); +} + +template +int sprintf_s(char(&dst)[_Size], const char *format, ...) +{ + int ReturnValue; + va_list l; + va_start(l, format); + ReturnValue = vsnprintf(dst, _Size, format, l); + va_end(l); + return ReturnValue; +} + +template +char *strcat_s(char(&dst)[_Size], const char src[]) +{ + return strncat(dst, src, _Size); +} + +template +int _ultoa_s(unsigned long value, char(&str)[_Size], int radix) +{ + switch (radix) { + case 10: + return sprintf_s(str, "%ul", value); + + case 16: + return sprintf_s(str, "%ulX", value); + + default: + return -1; + } +} + +template +int _snprintf_s(char(&dst)[_Size], size_t _MaxCount, const char *format, ...) +{ + int ReturnValue; + va_list l; + va_start(l, format); + ReturnValue = vsnprintf(dst, MAX(_MaxCount, _Size), format, l); + va_end(l); + return ReturnValue; +} + +template +int vsprintf_s(char(&dst)[_Size], const char *format, va_list l) +{ + return vsnprintf(dst, _Size, format, l); +} + + -- cgit v1.2.3