Makefile Generation |
15 |
![]() |
This section gives step-by-step instructions for creating a Makefile with templates and then updating the Makefile when a second design file is added to the application.
XD_C_PROGRAMS=\
myapp
XD_C_PROGRAM_OBJECTS=\
myapp.o
XD_C_PROGRAM_SOURCES=\
myapp.c
XD_C_STUB_OBJECTS=\
app_stubs.o
XD_C_STUB_SOURCES=\
app_stubs.c
myapp: myapp.o $(XD_C_OBJECTS) $(XD_C_STUB_OBJECTS)
$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o myapp myapp.o $(XD_C_OBJECTS) $(XD_C_STUB_OBJECTS) $(MOTIFLIBS) $(LDLIBS)
myapp.o: myapp.c
$(CC) $(CFLAGS) $(CPPFLAGS) -c myapp.c
app_stubs.o: app_stubs.c
$(CC) $(CFLAGS) $(CPPFLAGS) -c app_stubs.c
XD_C_PROGRAMS=\
myapp
XD_C_PROGRAM_OBJECTS=\
myapp.o
XD_C_PROGRAM_SOURCES=\
myapp.c
XD_C_OBJECTS=\
error.o
XD_C_SOURCES=\
error.c
XD_C_STUB_OBJECTS=\
error_stubs.o\
app_stubs.o
XD_C_STUB_SOURCES=\
error_stubs.c\
app_stubs.c
myapp: myapp.o $(XD_C_OBJECTS) $(XD_C_STUB_OBJECTS)
$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o myapp\
myapp.o $(XD_C_OBJECTS)\
$(XD_C_STUB_OBJECTS) $(MOTIFLIBS)\
$(LDLIBS)
myapp.o: myapp.c
$(CC) $(CFLAGS) $(CPPFLAGS) -c myapp.c
error.o: error.c
$(CC) $(CFLAGS) $(CPPFLAGS) -c error.c
app_stubs.o: app_stubs.c
$(CC) $(CFLAGS) $(CPPFLAGS) -c app_stubs.c
error_stubs.o: error_stubs.c
$(CC) $(CFLAGS) $(CPPFLAGS) -c error_stubs.c
At the end of the generated list of includes, add the following line:
#include <error.h>Add functionality to the button_pressed callback stub. This callback pops up the error dialog when the button is pressed:
void
button_pressed (Widget w, XtPointer client_data, XtPointer call_data )
{
if ( error_shell == NULL )
create_error_shell (XtParent (XtParent (w) ) );
XtManageChild ( error_box );
}Add functionality to the cancel_error callback. This function pops down the error dialog when the user presses the "Cancel" button.
void
cancel_error (Widget w, XtPointer client_data, XtPointer call_data )
{
XtUnmanageChild ( error_box );
}
XENVIRONMENT=myapp.res export XENVIRONMENT
-I../hdrsto the end of the CFLAGS line in the Makefile.
The change to CFLAGS is retained when you regenerate the Makefile with the "New makefile" toggle off. It is only lost if you generate a new Makefile.
#WorkShop Visual:XDG_C_OBJECT: XDG_C_SOURCE
#WorkShop Visual: $(CC) $(CFLAGS) $(CPPFLAGS) -c XDG_C_SOURCEEach time you update the Makefile to add a file to your application, WorkShop Visual generates a template instance for each relevant template. These instances contain the actual build commands for your application.
Template instances are marked with a "DO NOT EDIT" comment at the beginning and at the end. A typical instance of the template shown above looks like:
#DO NOT EDIT >>>
error.o: error.c
$(CC) $(CFLAGS) $(CPPFLAGS) -c error.c
#<<< DO NOT EDITTemplate instances should not be edited because your edits may be lost the next time you generate the Makefile. Instead, to change the build commands, edit the corresponding template lines. After you edit a template line, delete any instances of that template line that already exist in the Makefile. The instances are found just after the template line.
For example, to build all C files for debugging, you would:
#WorkShop Visual: $(CC) $(CFLAGS) $(CPPFLAGS) -c XDG_C_SOURCE
visu.motifMakeTemplateFile: $VISUROOT/make_templates/motif
visu.mmfcMakeTemplateFile: $VISUROOT/make_templates/mfcThere are two resources so that you can have different templates customized to pick up the appropriate class libraries. The value for the resource can contain environment variables which will be expanded by /bin/sh.
If WorkShop Visual cannot find the file specified, it will fall back to the template specified in the WorkShop Visual resource file, using the makefileTemplate application resource. To make a change to the template apply globally to all new Makefiles, edit the resource file. For details, see the Configuration chapter.
WorkShop Visual refers to the template only when you generate a new Makefile. To change templates in an existing Makefile, edit the file by hand as described in the previous section, or delete the file and start over.
make dependThis operation invokes the makedepend utility, which scans the existing makefile and appends a standard dependency list. Use man makedepend for more information.
solaris 2.x
#XINCLUDES=-I/opt/SUNWmotif/include -I/usr/dt/include
#XLIBS=-L/opt/SUNWmotif/lib -L/usr/dt/lib -L/usr/openwin/lib
...XINCLUDES and XLIBS specify the extensions to the included directory and library path respectively.
The motif template is used for makefiles generated in non-Windows mode and the mfc template is used for generating makefiles for Motif XP in Windows mode.