MAKEFILES Purpose contain UNIX commands and will run

  • Slides: 4
Download presentation
MAKEFILES Purpose: contain UNIX commands and will run them in a specified sequence. Syntax

MAKEFILES Purpose: contain UNIX commands and will run them in a specified sequence. Syntax Definition: { Section-name: {unix command #1} … Examples: lab 5: ccbl lab 5 ap 1. cob runcbl lab 5 ap 1 ccbl lab 5 ap 2. cob runcbl lab 5 ap 2 ccbl lab 5 ap 3. cob runcbl lab 5 ap 3 ccbl lab 5 c. cob runcbl lab 5 ac For Your Information • Makefiles are a UNIX thing, not a COBOL thing • You MUST put the unix commands in a file named: makefile (lower case with no extension) • The directory you put the makefile in matters! • You can only have one makefile per directory. • Section names start in column 1 and end with a colon. The colon is immediately followed by a carriage return. • Anything that can be entered at the UNIX command prompt can be in the makefile. • Each command must be preceded by a TAB and is immediately followed by a carriage return • MAKEFILES ARE UNFORGIVING WHEN IT COMES TO WHITESPACE! • To execute… must be in the directory where the makefile is: % make section-name clean: rm -f *. acu lab 5*. dat cp /usr/class/cis 314/lab 5*in. dat. Makefiles 1

REMINDERS Two special folder names are useful when specifying relative paths: • The. folder

REMINDERS Two special folder names are useful when specifying relative paths: • The. folder represents the current folder. • The. . Folder represents the parent folder; the folder one level up in the folder hierarchy. • The ~ character can be used as a shortcut for getting to your home directory. -r in the copy command cp will copy the directory and all its files, including any subdirectories and their files to the target -f in the remove command the files will be removed without prompting the user chmod command --- --read, write, execute (rwx) mine, group, everyone Makefiles 2

ANOTHER MAKEFILE EXAMPLE • Currently in root directory • Directories that exist: ~/cobol/oldinfo •

ANOTHER MAKEFILE EXAMPLE • Currently in root directory • Directories that exist: ~/cobol/oldinfo • Want prelabout to compile and run the prelab file and show the output to the screen • Want movedir to create a new directory directly under the root directory, and copy all the information from ~/cobol/oldinfo to the new directory leaving nothing behind prelabout: cd cobol ccbl prelab. cob runcbl prelab more prelabout. dat movedir: mkdir cobolold cd cobolold cp –r ~/cobol/oldinfo/*. rm -f ~/cobol/oldinfo/* rmdir ~/cobol/oldinfo ls *. * Makefiles 3

ANOTHER EXAMPLE script file Deleting Unnecessary Files: As you work you create disk files,

ANOTHER EXAMPLE script file Deleting Unnecessary Files: As you work you create disk files, most of which do not need to be kept. These unnecessary files occupy disk space, and if not erased will eventually fill your disk quota. When this happens, you cannot save any other files, no matter how important. To help prevent this from occurring, there is a command called clean in the class directory (/usr/class/cis 314/). Copy it in to your home directory using the UNIX cp command, and every so often enter the command clean. This will delete any unnecessary files from your home directory, leaving you more disk space. Clean Example: chmod 700 * rm *~ rm *. int rm *. obj rm *. acu rm *. err rm *. list Makefiles 4