编译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
相关推荐
Freak嵌入式11 小时前
MCU 低功耗模式解析:时钟门控、电源门控、深度休眠
人工智能·python·单片机·嵌入式硬件·开源·依赖倒置原则·micropython
国科安芯11 小时前
FreeRTOS RISC-V 浮点上下文切换移植:在 IAR 工程中完整保存 FPU 寄存器
java·开发语言·单片机·嵌入式硬件·算法·系统架构·risc-v
躺不平的理查德12 小时前
STM32时钟树(Clock Tree)
stm32·单片机·嵌入式硬件
Javenwww13 小时前
STM32中DMA的使用——串口数据的DMA传输
单片机
qq_4017004113 小时前
经典的电压基准源电路
单片机·嵌入式硬件
茯苓gao14 小时前
嵌入式开发笔记:电机参数辨识与自学习完全指南——从电气参数到机械特性的深度解析
笔记·嵌入式硬件·学习
西安景驰电子14 小时前
PCIe 授时卡原理及应用
运维·服务器·windows·单片机·嵌入式硬件·fpga开发
派勤电子15 小时前
5G物联网网关工控主板选型指南(超小尺寸工业级嵌入式硬件解决方案)
嵌入式硬件·工业网关·工控主板·工控主板选型·嵌入式工控主板·5g物联网网关·超小尺寸工控主板
&Hello Code16 小时前
2.一套可落地的 STM32 六层架构:基础工程框架搭建
stm32·嵌入式硬件·架构
sramdram17 小时前
高速低功耗stt-mram工业级存储方案
嵌入式硬件·mram·stt-mram·低功耗stt-mram