Makefiles1 MAKEFILES Purpose: contain UNIX commands and will run them in a specified sequence. Syntax Definition : { Section-name: {unix command #1} … } … Examples : lab5: ccbl lab5ap1.cob runcbl lab5ap1 ccbl lab5ap2.cob runcbl lab5ap2 ccbl lab5ap3.cob runcbl lab5ap3 ccbl lab5c.cob runcbl lab5ac clean: rm -f *.acu lab5*.dat cp /usr/class/cis314/lab5*in.dat. 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
Makefiles2 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
Makefiles3 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 *.* ANOTHER MAKEFILE EXAMPLE
Makefiles4 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/cis314/). 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 ANOTHER EXAMPLE script file