Using HP Code Advisor in Application Builds: [HP Code Advisor] White Paper

8
Figure 5: Implementing custom actions to check code quality
# This is a sample Makefile
# This is used to illustrate how Cadvise can be incorporated into
# application builds
# List of source code files
SOURCES = source1.c source2.c
# Create a list of the object files using macro substitutions
OBJECTS = $(SOURCES:.c=.o)
# Build tools and options
# Use aCC as the default C compiler
CC = aCC
# Flags
CFLAGS = -c -Ae -O -I.
# Use aCC as the linker
LD = aCC
LDFLAGS = -o
# Application target and dependencies
YourApplication: $(OBJECTS)
$(LD) $(LDFLAGS) $@ $(OBJECTS) $(LIBS)
# Basic implementation of customized actions
cadvise-YourApplication:
make CADVISE=cadvise CADVISE_OPTS="-pdb YourApplication.pdb"
YourApplication
cadvise report -severity all -pdb YourApplication.pdb -
basepdb:new > new_diagnostics
if [ -f new_diagnostics ] ; \
then \
echo "New diagnostics introduced. Please verify them.\n" ; \
cat new_diagnostics ; \
exit 1 ; \
fi ;
# .o files depend on .c files
$(OBJECTS): includes.h
$(CC) $(CFLAGS) $(SOURCES)
# Clean built files
clean:
rm -rf *.o *~ YourApplication core