License Public Domain
Lines 28
Keywords
make (1) makefile (1) tcsh (2)
Permissions
Owner: Jesse I.
Viewable by Everyone
Editable by Jesse I.

Create a Makefile Atom Feed 1

In Brief This file (written in tcsh) creates a makefile based on what .cpp files you have in the current directory and finds their dependencies.
# 's
 1#! /bin/tcsh
2
3set makefile = "Makefile"
4set files
5set objects
6set arg = "-Wall -ansi -g"
7
8if($1 == '') then
9 echo "Executable name required."
10 echo "usage: makemake.sh executable_name"
11 exit
12endif
13
14rm -f $makefile
15
16foreach file("`ls *.cpp`")
17 set files = ($files $file)
18 set objects = ($objects ${file:r}.o)
19end
20
21echo "$1 : $objects " >>! $makefile
22echo " g++ $arg -o $1 $objects " >> $makefile
23
24foreach file ($files)
25 echo " " >> $makefile
26 echo -n "${file:r}.o: $file " >> $makefile
27 grep '#include ".*"' $file | awk -F\" '{printf "%s ", $2}' >> $makefile
28 echo "" >> $makefile
29 echo " g++ $arg -c $file" >> $makefile
30
31end
32
33
34 echo "\nclean:" >> $makefile
35
36
37 echo " rm -f $1 $objects" >> $makefile

This file (written in tcsh) creates a makefile based on what .cpp files you have in the current directory and finds their dependencies.