Build Code Analysis with Symbolic Evaluation
Ahmed Tamrawi, Hoan Anh Nguyen, Hung Viet Nguyen, Tien N. Nguyen

Introduction

Software building is the process that converts and integrates source code, libraries, and other required data in a software project into standalone deliverables and executable files. The build process is managed by a build tool, i.e. a program that coordinates and controls other programs. A build tool needs to execute the build commands according to the rules specified in build files, which are written in a build language supported by the tool. Popular build tools are GNU make, ant, and maven.

SYMake is an infrastructure and tool for the analysis of build code in GNU make. With a specific input environment, make first evaluates a Makefile into a dependency graph among concrete file names and commands. Then, it executes the commands with those files.

With such dynamic nature in make’s evaluation, it is challenging for developers to understand and maintain over time multiple large, complex, and dependent Makefiles. In brief, the dependency analysis for the build rules and the name analysis for the entity names are difficult. Thus, it is challenging to detect those Make-specific code smells and to automate refactorings in the static Make code before evaluation phase. Even automatic renaming in Make code is not straightforward as in product code.

We have used SYMake to develop algorithms and a tool to detect several types of code smells and errors in Makefiles, e.g. loops of recursive variables, cyclic dependencies, duplicate prerequisites, rule inclusion. Another SYMake’s application is a renaming tool for Makefile’s variables/targets whose names might be fragmented and come from multiple substrings.

Existing tools such as MAKAO (http://sailhome.cs.queensu.ca/~bram/makao/index.html) can only work on concrete dependency graph for a Makefile, thus it cannot support renaming/extracting, and code smell detections for Make code as in SYMake.