Using a Non-PWB Makefile

PWB makefiles are highly structured and stylized makefiles that are generated from the rules in the project template and a list of files that you supply. Many projects have existing makefiles that PWB can't read because they do not have this stylized structure. These makefiles are called non-PWB or “foreign” makefiles.

You can still take advantage of many of PWB's project features with non-PWB makefiles. The features that cannot be used are shown as unavailable menu items. Note that a PWB makefile is not required to use the Source Browser—all you need to have is a browser database. For information on building a browser database, see “Building Databases for Non-PWB Projects” on page 104 and Chapter 21.

Before continuing, consider the following makefile, which builds a version of the COUNT project:

#

# CNT.MAK - A simple non-PWB makefile for building

# the PWB tutorial example program COUNT.EXE .

#

# NOTE: The LIBS macro assumes the explicit protected-mode

#library name. If you have installed with different

#names, you must change the LIBS macro.

#

#

# Macros

#

CC= cl

CFLAGS= /Oc /qc

LFLAGS= /NOD:SLIBCE.LIB /NOE /NOI /EXE /FAR /PACKC

LINKER= link

OBJS= COUNT.OBJ COUNTBUF.OBJ COUNTCH.OBJ

STDOBJS = SETARGV.OBJ

LIBS= SLIBCEP

#

# The "all" target.

# Building 'all' builds COUNT.EXE.

#

all: COUNT.EXE

#

# The file suffixes NMAKE needs to "know" about

# for this project.

#

.SUFFIXES:

.SUFFIXES: .obj .c

#

# An inference rule to make an object file from a

# C source file.

#

.c.obj :

$(CC) /c $(CFLAGS) /Fo$@ $<

#

# The description block for building COUNT.EXE

# from the object files and libraries.

#

COUNT.exe : $(OBJS)

$(LINKER) $(LFLAGS) $(OBJS) $(STDOBJS),$@,,$(LIBS);

# The 'clean' target. Delete intermediate files

# that might be clutter after a release build

#

clean :

-del *.obj

-del *.mdt

-del *.ilk

-del *.sym

This makefile is written for NMAKE. Even though PWB cannot read it as a PWB makefile, you can use CNT.MAK as a project makefile in PWB without having to change it.

CNT.MAK defines two primary targets, all and clean. By default, NMAKE builds the first target in your makefile. The first target is commonly called all and is used to build the main targets of a project. Other targets in the makefile are used to build the all targets or describe additional functionality. For example, the clean target in this makefile deletes some intermediate files from disk.

·To use CNT.MAK in PWB:

1.From the Project menu, choose Open Project.

2.Select CNT.MAK.

3.Turn on the Use as a Non-PWB Makefile check box.

The Open Project dialog box appears.

4.Choose OK.

Note :

A PWB makefile cannot be edited or modified when it is the open project. However, PWB does not disable modification of non-PWB makefiles. You can edit a non-PWB makefile, even when it belongs to the currently open project.

The LIBS macro in CNT.MAK assumes the explicit protected-mode library name. If you have installed with different names, or you want to use a different library, you must change the LIBS macro to contain the name of the library you are using.

You can now use the Build, Rebuild All, and Build Target commands from the Project menu. The Build and Rebuild All commands work as they do with a PWB makefile by building the first target. However, the Language Options commands and the LINK Options command on the Options menu are unavailable. You set options by editing the makefile.

·To build the clean target:

1.From the Project menu, choose Build Target.

PWB displays the Build Target dialog box where you can specify the target name(s).

2.Type clean in the Target text box.

3.Choose Build.

PWB builds the clean target instead of the first target in the makefile (in this case, all).

When you close a non-PWB project, PWB saves the environment, window layout, and file history just as it does for a PWB project.