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

6
Figure 3: Creating a command-line switch
Use the following command line to build the application with cadvise:
$ USE_CADVISE=yes gmake
cadvise -pdb YourApplication.pdb aCC -c -Ae -O -I.
source1.c source2.c
source1.c:
source2.c:
cadvise -pdb YourApplication.pdb aCC -o YourApplication
source1.o source2.o
Method 2: Introducing a cadvise-specific target
You can introduce a new target for integrating cadvise into the build process. Figure 4 shows the
introduction of a new target.
# 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)
# Conditional switch option
ifeq ($(USE_CADVISE),yes)
CADVISE=cadvise
CADVISE_OPTS= -pdb YourApplication.pdb
endif
# Build tools and options
# Use aCC as the default C compiler
CC = $(CADVISE) $(CADVISE_OPTS) aCC
# Flags
CFLAGS = -c -Ae -O -I.
# Use aCC as the linker
LD = $(CADVISE) $(CADVISE_OPTS) aCC
LDFLAGS = -o
# Application target and dependencies
YourApplication: $(OBJECTS)
$(LD) $(LDFLAGS) $@ $(OBJECTS) $(LIBS)
# .o files depend on .c files
$(OBJECTS): includes.h
$(CC) $(CFLAGS) $(SOURCES)
# Clean built files
clean:
rm -rf *.o *~ YourApplication core