简体   繁体   English

如何为Verifone(vx520或vx820)创建制作文件

[英]how to crate a make file for verifone (vx520 or vx820)

I have a verifone terminal (vx520 and vx820). 我有一个Verifone终端(vx520和vx820)。 I whant to crate a makefile for compile app for this terminal. 我希望为此终端创建一个makefile来编译应用程序。 I have "VRXSDK" version 1.2.0 我有“ VRXSDK”版本1.2.0

howto do it? 怎么做?

or how to compile a file like "main.c" or "main.cpp" till have a execute file for verifone POS terminal 或如何编译“ main.c”或“ main.cpp”之类的文件,直到拥有Verifone POS终端的执行文件

Wherever you got your "VRXSDK" from, you should also be able to get some sample project files. 无论从何处获得“ VRXSDK”,您都应该能够获得一些示例项目文件。 You will find a make file in there (likely with a .smk extension). 您将在其中找到一个生成文件(可能带有.smk扩展名)。 I would recommend you start with that and as you read through it, that should give you more specific questions to ask and things you can look up using your favorite search engine. 我建议您从此开始,并在阅读它的过程中,为您提供更具体的问题,以及您可以使用自己喜欢的搜索引擎查找的内容。

A make file is, in essence, a program that invokes the compiler with input parameters you determine based on various factors. 本质上,make文件是一个程序,该程序使用您根据各种因素确定的输入参数来调用编译器。 It will also invoke the linker to tie it all together. 它还将调用链接器以将所有链接捆绑在一起。 How you go about this varies wildly from one implementation to another, so "How do I create a make file" is just about as broad as "how do I write a program?" 从一个实现到另一个实现,您的处理方式千差万别,因此“如何创建make文件”与“如何编写程序”差不多。 which makes answering it here rather challenging. 这使得在这里回答问题颇具挑战性。 However, to get you started... 但是,为了让您入门...

I use Visual Studio as my IDE and I am using NMake. 我将Visual Studio用作IDE,并且正在使用NMake。 I actually have 2 layers of make files. 我实际上有2层make文件。 The outer layer is what is called when I say "build" from my IDE and it is very short: 当我从IDE中说“ build”时,就是所谓的外层,它很短:

# Pick one of the following (for LOG_PRINTF messages)
#CompileWithLogSys = -DLOGSYS_FLAG 
CompileWithLogSys =

all:
    $(MAKE) /i /f coreBuild.smk /a TerminalType=$(Configuration) CompileWithLogSys=$(CompileWithLogSys) VMACMode=Multi
    $(MAKE) /i /f coreBuild.smk /a TerminalType=$(Configuration) CompileWithLogSys=$(CompileWithLogSys) VMACMode=Single

Lines starting with # are comments. 以#开头的行是注释。

This outer file makes it really easy for me to toggle a few things when I want to build different variations. 当我要构建其他变体时,此外部文件使我真的很容易切换一些内容。 You can see that I have turned OFF compliation with LogSys. 您可以看到我已经关闭了与LogSys的兼容。 The more important thing the 2-layer approach gives me is an easy way to compile 2 different versions with a single command to build. 2层方法给我带来的更重要的事情是使用一个构建命令即可编译2个不同版本的简便方法。 This runs nmake with "VMACMode" set to "Multi" and then runs it again with it set to "Single". 这会将nmake的“ VMACMode”设置为“ Multi”,然后再次运行它(将其设置为“ Single”)。 The inner make file will see that parameter and compile to a different root folder for each so in the end I wind up with 2 folders, each with a different version. 内部make文件将看到该参数,并为每个参数编译到一个不同的根文件夹,因此最后我得到了两个文件夹,每个文件夹具有不同的版本。

You can do a web search on "nmake parameters" to see what things like /i and /f do, as well as other options I'm not using here. 您可以在“ nmake参数”上进行网络搜索,以查看/ i和/ f之类的功能以及我在此处未使用的其他选项。 However, I would like to direct your attention to TerminalType=$(Configuration) . 但是,我想把您的注意力转向TerminalType=$(Configuration) In Visual Studio, you can select from a dropbox if you want "Debug" or "Release". 在Visual Studio中,如果要“调试”或“发布”,则可以从下拉框中选择。 Those 2 options are the default options, but you can change them; 这两个选项是默认选项,但是您可以更改它们。 in my case, I have modified them to "eVo" and "Vx". 就我而言,我已经将它们修改为“ eVo”和“ Vx”。 Now I just select in my drop down box which version I want to compile for and that gets passed in. Alternately, I could just hard code both into my outer make file. 现在,我只需在下拉框中选择要编译的版本并将其传递。或者,我可以将这两个版本都硬编码到我的外部make文件中。 That's just preference. 那只是偏爱。

My inner make file (which is named "coreBuild.smk") gets much more interesting. 我的内部make文件(名为“ coreBuild.smk”)变得更加有趣。 Generally, you start by defining variables, such as "include paths": 通常,您首先定义变量,例如“ include path”:

# Includes
SDKIncludes = -I$(EVOSDK)\include
ACTIncludes = -I$(EVOACT)include
VCSIncludes = -I$(EVOVCS)include
EOSIncludes = -I$(EOSSDK)\include\ssl2

And/Or libraries: 和/或库:

#Libraries
ACTLibraries    = $(EVOACT)OutPut\RV\Files\Static\Release

#Others you may want to include, but I am not using:
#LOGSYSLibraries = $(EVOVMAC)\Output\RV\Lib\Files\Debug
#EOSLibraries   = $(EOSSDK)\lib

As well as the path(s) to your files 以及文件的路径

#  App Paths
AppIncludes = .\include
SrcDir      = .\source
ObjDir      = .\obj
OutDir      = .\Output\$(TerminalType)\$(VMACMode)\Files
ResDir      = .\Resource

I also like to define my project name here: 我也想在这里定义我的项目名称:

ProjectName = MakeFileTest

Note that OutDir uses the TerminalType and VMACMode that we passed in in order to go to a unique folder. 请注意, OutDir使用我们传入的TerminalTypeVMACMode进入唯一的文件夹。

Next, you would generally set your compiler options 接下来,通常将设置编译器选项

#   Compiler Options
#  Switch based on terminal type
!IF "$(TerminalType)"=="eVo"
CompilerCompatibility=-p
DefineTerminalType = -DEVO_TERMINAL
!ELSE
CompilerCompatibility=
DefineTerminalType = -DVX_TERMINAL
!ENDIF

#  Switch based on Multi or Single mode (VMACMode)
!if "$(VMACMode)"=="Multi"
VMACIncludes = -I$(EVOVMAC)include
DefineMulti = -DMULTI_APP_ENABLED
!else
VMACIncludes = 
DefineMulti = 
!endif

An interesting thing to note above is the -DMULTI_APP_ENABLED . 上面要注意的一个有趣的事情是-DMULTI_APP_ENABLED The program I wrote has some blocks that are dependent on #ifdef MULTI_APP_ENABLED . 我编写的程序有一些取决于#ifdef MULTI_APP_ENABLED块。 This is not any special name--it's just one I came up with, but the compiler will define it right before it starts compiling my code, so I can turn those code blocks on and off right here. 这不是一个特殊的名称,它只是我想出的一个名称,但是编译器会在开始编译我的代码之前对其进行定义,因此我可以在此处打开和关闭这些代码块。

Next, we are going to kinda' gather everything together. 接下来,我们将有点'把所有东西收集在一起。 We will start by defining a new var, "Includes" and it will have the flag "-I" (to indicate "include" and then all the things we said above that we wanted to include: 我们将从定义一个新的变量“ Includes”开始,它将具有标志“ -I”(表示“ include”,然后是上面我们想要包含的所有内容):

Includes    = -I$(AppIncludes) $(SDKIncludes) $(ACTIncludes) $(VMACIncludes) $(VCSIncludes)

Note that you could just type everything long hand here and not go through the extra steps of defining the vars in the first place, but it makes it easier to read, so I think this is pretty normal. 请注意,您可以在此处直接键入所有内容,而不必首先执行定义var的额外步骤,但这使它更易于阅读,因此我认为这很正常。

We do pretty much the same thing with compiler options, although note that the specific flags (ex, "-D" "-p") were already included in the original var declarations, so we leave them out here: 尽管注意到特定的标志(例如,“-D”和“ -p”)已经包含在原始var声明中,但是我们使用编译器选项做的事情几乎相同,因此我们在此处将其省略:

COptions    =$(CompilerCompatibility) $(CompileWithLogSys) $(DefineTerminalType) $(DefineMulti) -DDEV_TOGGLES_FOR_SYNTAX 

Next we set a variable that will tell the linker where the object files are that it needs to stitch together. 接下来,我们设置一个变量,该变量将告诉链接器目标文件需要缝合在一起的位置。 Note that if you insert new lines, as I have, you need the '\\' to tell it that it continues on the next line 请注意,如果像我一样插入新行,则需要使用“ \\”告诉它继续在下一行

# Dependencies
AppObjects = \
        $(ObjDir)\$(ProjectName).o \
        $(ObjDir)\Base.o \
        $(ObjDir)\printer.o \
        $(ObjDir)\UI.o \
        $(ObjDir)\Comm.o

We will also set one for any libaries we want to link in: 我们还将为要链接的任何库设置一个:

Libs = $(ACTLibraries)\act2000.a

OK, next we have to sign the file(s). 好的,接下来我们必须对文件签名。 We are trying to tell nMake that we also will be creating the resource file and compiling the actual code. 我们试图告诉nMake我们还将创建资源文件并编译实际代码。 If we are doing a multi-app build, then pseudoOut depends on the .res and the .out files. 如果我们要进行多应用程序构建,则pseudoOut取决于.res和.out文件。 If not, then it just depends on the .out, because there is no .res. 如果不是,则仅取决于.out,因为没有.res。 If the the dependent file(s) has/have changed more recently than pseudoOut, then run commands vrxhdr..., filesignature..., and move... NOTE that the indentations seen below are required for nMake to work properly. 如果从属文件的更改时间比伪输出更新的时间最近,请运行命令vrxhdr ...,filesignature ...和move...。请注意,以下所示的缩进是nMake正常工作所必需的。

!if "$(VMACMode)"=="Multi"
pseudoOut : $(ResDir)\$(ProjectName).res $(OutDir)\$(ProjectName).out
!else
pseudoOut : $(OutDir)\$(ProjectName).out 
!endif
#   This calls vrxhdr: the utility program that fixes the executable program’s header required to load and run the program. Vrxhdr is needed when you want to move a shared library around on the terminal.
    $(EVOSDK)\bin\vrxhdr -s 15000 -h 5000 $(OutDir)\$(ProjectName).out

# do the signing using the file signature tool and the .fst file associated with this TerminalType.
    "$(VSFSTOOL)\filesignature" $(TerminalType)$(VMACMode).fst -nogui
    @echo __________________ move files to out directory __________________
# rename the .p7s file we just created 
    move $(OutDir)\$(ProjectName).out.p7s $(OutDir)\$(ProjectName).p7s

!if "$(VMACMode)"=="Multi"
    copy $(ResDir)\imm.ini $(OutDir)\imm.ini
    copy $(ResDir)\$(ProjectName).INS $(OutDir)\$(ProjectName).INS
    copy $(ResDir)\$(ProjectName).res $(OutDir)\$(ProjectName).res
!endif
    @echo *****************************************************************

Note that the "echo" commands are just to help me read my output logs, as needed. 请注意,“ echo”命令只是为了帮助我根据需要读取输出日志。

OK, now we link. 好,现在我们链接。

"WAIT!" “等待!” I can hear you saying, "We haven't compiled yet, we already issued a command to sign, and now we are linking? This is totally out of order!" 我能听到您说:“我们还没有编译,我们已经发出了签名命令,现在我们要链接?这完全乱了!” Yes and no. 是的,没有。 We haven't actually issued the command to sign yet, we have merely told nmake that we may want to do that and how to do it if we decide so to do. 我们实际上还没有发出要签名的命令,我们只是告诉nmake我们可能想要这样做以及如果我们决定这样做的话该怎么做。 Similarly, we aren't issuing the command to link yet, we are just telling nmake how to do it when we are ready. 同样,我们尚未发出要链接的命令,只是告诉nmake准备就绪后该如何做。

#  Link object files
$(OutDir)\$(ProjectName).out : $(AppObjects)
    $(EVOSDK)\bin\vrxcc $(COptions) $(AppObjects) $(Libs) -o $(OutDir)\$(ProjectName).out

Remember that mutli-app programs need a .res file. 请记住,mutli-app程序需要一个.res文件。 Single apps don't. 单个应用程序没有。 The following will actually build the .res file, as needed. 下面将根据需要实际构建.res文件。

!if "$(VMACMode)"=="Multi"
#  compile resource file
$(ResDir)\$(ProjectName).res : $(ResDir)\$(ProjectName).rck
    $(EVOTOOLS)rck2 -S$(ResDir)\$(ProjectName) -O$(ResDir)\$(ProjectName) -M
!endif

Remember those AppObjects? 还记得那些AppObjects吗? We are finally ready to make them. 我们终于准备好制造它们了。 I'm using the following flags 我正在使用以下标志

  • -c = compile only -c =仅编译
  • -o = output file name -o =输出文件名
  • -e"-" => -e redirect error output from sub-tools to... "-" to stdout. -e"-" => -e将错误输出从子工具重定向到... "-"到stdout。 (These are all then redirected via pipe | ) (然后全部通过管道|重定向)

Again, wherever you got your VRXSDK, you should also be able to get some documentation from VeriFone. 同样,无论您在哪里获得VRXSDK,都应该能够从VeriFone获得一些文档。 See "Verix_eVo_volume 3", page 59 for more details on the flags 有关标志的更多详细信息,请参见第59页的“ Verix_eVo_volume 3”

$(ObjDir)\$(ProjectName).o : $(SrcDir)\$(ProjectName).c
!IF !EXISTS($(OutDir))
    !mkdir $(OutDir)
!ENDIF
    -$(EVOSDK)\bin\vrxcc -c $(COptions) $(Includes) -o $(ObjDir)\$(ProjectName).o $(SrcDir)\$(ProjectName).c -e"-" | "$(EVOTOOLS)fmterrorARM.exe"

$(ObjDir)\Base.o : $(SrcDir)\Base.c 
  $(EVOSDK)\bin\vrxcc -c $(COptions) $(Includes) -o $(ObjDir)\base.o $(SrcDir)\Base.c -e"-" | "$(EVOTOOLS)fmterrorARM.exe"

$(ObjDir)\myprinter.o : $(SrcDir)\printer.c 
  $(EVOSDK)\bin\vrxcc -c $(COptions) $(Includes) -o $(ObjDir)\printer.o $(SrcDir)\printer.c -e"-" | "$(EVOTOOLS)fmterrorARM.exe"

$(ObjDir)\UI.o : $(SrcDir)\UI.c 
  $(EVOSDK)\bin\vrxcc -c $(COptions) $(Includes) -o $(ObjDir)\UI.o $(SrcDir)\UI.c -e"-" | "$(EVOTOOLS)fmterrorARM.exe"

$(ObjDir)\Comm.o : $(SrcDir)\Comm.c 
  $(EVOSDK)\bin\vrxcc -c $(COptions) $(Includes) -o $(ObjDir)\Comm.o $(SrcDir)\Comm.c -e"-" | "$(EVOTOOLS)fmterrorARM.exe"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM