编译appweb源代码

Building with Make or Nmake

This document describes the process to build the software from source using Make or Nmake on Windows. First make sure you have read the Building Overview to prepare your build environment.

Platform Makefiles

MakeMe can create a suite of generated, pre-configured Makefiles for common platforms. These are simple makefiles that build a default configuration for a specific operating system. These makefiles are typically provided under the ./projects directory.

A top level Makefile is also provided that detects your operating system and CPU architecture and then invokes the appropriate project Makefile for your system. For example:

复制代码
$ make
make --no-print-directory -f projects/NAME-macosx-default.mk all

Windows Nmake

On Windows, a make.bat file is provided to to invoke nmake. The make.bat file first invokes projects/windows.bat which runs the Visual Studio vcvarsall.bat procedure to setup the necessary Visual Studio environment variables for compiling.

To build on Windows with nmake, type:

复制代码
$ make
nmake -f projects\NAME-windows.nmake

Modifying the Makefile Defaults

You do not use a configure program when building via Make, that is used only for building with MakeMe. Rather, you supply configuration options directly to Make. These options override default values defined by the projects/NAME-OS-default.mk makefile and by the projects/NAME-OS-debug-me.h file. For example, to disable use of SQLite:

复制代码
$ make ME_COM_SQLITE=0 

Configurable components are enabled by setting their corresponding ME_COM_NAME option to 1. Disable by setting to zero. Some components requires a path to locate libraries and headers. Use ME_COM_NAME_PATH to define the path to the component.

By defining make variables such as CC and CFLAGS, you can modify the compiler options. This is the also the technique used when cross-compiling.

To see the list of configurable options, run make help:

复制代码
$ make help
usage: make [clean, compile, install, run, uninstall]
The default configuration can be modified by setting make variables
Set to 0 to disable and 1 to enable:
  PROFILE          # Select default or static for static linking
  ME_EJS_DB        # Enable database support, ejs.db
  ME_EJS_MAIL      # Enable mail support, ejs.mail
  ME_EJS_MAPPER    # Enable database mapper support, ejs.mapper
  ME_EJS_TAR       # Enable tar support, ejs.tar
  ME_EJS_TEMPLATE  # Enable template support, ejs.template
  ME_EJS_WEB       # Enable web support, ejs.web
  ME_EJS_ZLIB      # Enable zlib support, ejs.zlib
  ME_ESP_MDB       # Enable ESP MDB database support
  ME_ESP_SDB       # Enable ESP SQLite database support
  ME_MPR_LOGGING   # Enable application logging
  ME_MPR_TRACING   # Enable debug tracing
  ME_COM_CGI       # Enable the CGI handler
  ME_COM_DIR       # Enable the directory listing handler
  ME_COM_EJSCRIPT  # Enable the Ejscript handler
  ME_COM_ESP       # Enable the ESP web framework
  ME_COM_EST       # Enable the EST SSL stack
  ME_COM_OPENSSL   # Enable the OpenSSL SSL stack
  ME_COM_PHP       # Enable the PHP framework
  ME_COM_SQLITE    # Enable the SQLite database
  ME_ROM           # Build for ROM without a file system

For example, to disable CGI:
  ME_COM_CGI=0 make

Other make variables:
  ARCH               # CPU architecture (x86, x64, ppc, ...)
  OS                 # Operating system (linux, macosx, windows, vxworks)
  CC                 # Compiler to use 
  LD                 # Linker to use
  DEBUG              # Set to debug or release for debug or optimized builds
  CONFIG             # Output directory for built items.
  CFLAGS             # Add compiler options. For example: -Wall
  DFLAGS             # Add compiler defines. For example: -DCOLOR=blue
  IFLAGS             # Add compiler include directories.
  LDFLAGS            # Add linker options
  LIBPATHS           # Add linker library search directories.
  LIBS               # Add linker libraries. For example: -lpthreads
  PROFILE            # Build profile, used in output products directory name

Installing with Make

You can install the newly built software via:

复制代码
sudo make install

You can remove by:

复制代码
sudo make uninstall

Must Use Exact Same Options

It is essential when invoking make install, that you provide the same make flags and options as you did when compiling. This is because the Makefile will conditionally install only the selected components for those options.

For example, to build and install PHP, use the same options for the compile and install commands:

复制代码
$ make ME_COM_PHP=1 ME_COM_PHP_PATH=/usr/src/php compile
$ sudo make ME_COM_PHP=1 ME_COM_PHP_PATH=/usr/src/php install

Deploying

If you need to deploy to a different system or capture the build products, you can install to a specific directory via:

复制代码
make deploy

This will install to the deploy directory under the output platform directory.

Cross Compiling with Make

Building a product for platform different to that of the local system is called cross compiling. Sometimes this compiling is just for a different instruction set (say x64 instead of x86). Other times, it is for a completely different operating system and/or CPU architecture. In such cases, a cross-compiler is typically required to build for the target platform.

To cross compile, you invoke the relevant project makefile and pass the required CPU architecture as a make variable. For example, to cross compile for VxWorks on ARM:

复制代码
make -f projects/NAME-vxworks-default.mk ARCH=arm PROFILE=debug

When make runs, it places the output products (executables, libraries and objects) in a platform-specific output directory. This is named using the form: OS-ARCH-PROFILE. For example: vxworks-arm-debug. In this manner, make can be invoked multiple times, once for each target platform and the results will be captured in separate platform output directories. Some of the supported architectures for the ARCH field are: arm, mips, ppc, x64 and x86. The PROFILE is a descriptive name chosen by you for your configuration.

If there is not a makefile for your target operating system, copy the closest makefile and edit to suit your target platform.

Specifying the CPU

The build will use the generic CPU type within the specified architecture. To override the default choice and specify a CPU type within an architecture, use the CPU variable. For example:

复制代码
make OS=vxworks ARCH=arm CPU=arm7tdmi

Specifying a Tool Chain

You may need to specify where Make can locate your cross-compiler and other tools. You can supply these via the make variables: CC, CFLAGS, DFLAGS, IFLAGS, LD and LDFLAGS.

For example:

复制代码
make CC=/opt/bin/ccarm.exe LD=/opt/bin/ccarm.exe ARCH=arm PROFILE=release
    -f projects/NAME-vxworks-default.mk 

Supporting OpenSSL

If OpenSSL is required to provide SSL support, you must specify the path to the OpenSSL source directory. For example:

复制代码
make ME_COM_OPENSSL=1 ME_COM_OPENSSL_PATH=/path/to/openssl compile

If you are using a binary OpenSSL distribution, provide the path where the OpenSSL libraries are located (typically /usr/lib).

复制代码
make ME_COM_OPENSSL=1 ME_COM_OPENSSL_PATH=/usr/lib compile

Static Building

If you require a static build without the ability to dynamically load modules, use the static makefile profile. For example:

复制代码
make PROFILE=static

Some web frameworks such as ESP and Ejscript may have reduced functionality in static builds.

Building for VxWorks

Before building for VxWorks, you must define the WIND_* environment variables via the wrenv.sh script provided with VxWorks. This defines the WIND_BASE, WIND_HOST_TYPE and other required environment variables.

The command below runs wrenv.sh and defines the WIND variables in the current shell's environment.

复制代码
eval `/WindRiver/wrenv.sh -p vxworks-6.8 -o print_env -f sh`

Once defined, you can invoke make.

复制代码
make OS=vxworks

If you require a static build, set the profile to "static".

复制代码
make OS=vxworks PROFILE=static
相关推荐
hoiii18714 小时前
STM32 开发板上用 USART 实现 Modbus 协议控制设备的方案
stm32·单片机·嵌入式硬件
Lucky_ldy14 小时前
51单片机的学习上(结合中科协的个人自用笔记)
嵌入式硬件·学习·51单片机
全球通史14 小时前
Jetson Nano 双摄像头芯片检测视觉系统:小尺度难定位问题解决,从零开始实现教程说明
嵌入式硬件·算法·ubuntu·性能优化
崇山峻岭之间14 小时前
单片机RTC实验
单片机·嵌入式硬件·实时音视频
踏着七彩祥云的小丑15 小时前
嵌入式测试学习第 21 天:常见硬件故障现象:不开机、死机、串口无输出
单片机·嵌入式硬件
chuwengeileyan11 天前
过零比较器 proteus
嵌入式硬件
foundbug9991 天前
51单片机 PT100 温度测量程序
单片机·嵌入式硬件·51单片机
星夜夏空991 天前
STM32单片机学习(21) —— I2C通信
stm32·单片机·学习
qq_333120971 天前
深入探讨8051单片机C351语言及编译器应用
单片机·嵌入式硬件·51单片机