#!/bin/sh #genMakefile - a script to generate a Makefile. #Copyright (C) 2005 Daniel Brewer #This program is free software; you can redistribute it and/or #modify it under the terms of the GNU General Public License #as published by the Free Software Foundation; either version 2 #of the License, or (at your option) any later version. #This program is distributed in the hope that it will be useful, #but WITHOUT ANY WARRANTY; without even the implied warranty of #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #GNU General Public License for more details. #http://www.gnu.org/copyleft/gpl.html echo "Welcome to Daniel's simple Makefile generator" echo "Please ensure all *.cc and *.h are in this directory" echo -n "Enter the name of the program (must have a corresponding .cc file): " read prog srcdir=./src headdir=./headers echo "#This Makefile was automatically produced by Daniel Brewer's Makefile generator on $(date)" > Makefile echo "CC = g++" >> Makefile echo "SRCDIR = $srcdir" >> Makefile echo "HEADDIR = $headdir" >> Makefile echo "PREFIX = /usr" >> Makefile echo "vpath %.cc \$(SRCDIR)" >> Makefile echo "vpath %.h \$(HEADDIR)" >> Makefile echo "#CFLAGS = -Wall -g -I\$(HEADDIR)" >> Makefile echo "#CFLAGS = -Wall -g -pg -I\$(HEADDIR)" >> Makefile echo "CFLAGS = -Wall -pipe -fastf -mcpu=7450 -mtune=7450 -I\$(HEADDIR)" >> Makefile echo "#CFLAGS = -Wall -pipe -fastf -mcpu=G3 -mtune=G3 -I\$(HEADDIR)" >> Makefile echo "#CFLAGS = -Wall -pipe -fastf -mcpu=G5 -mtune=G5 -I\$(HEADDIR)" >> Makefile echo "LIBS = -lm" >> Makefile echo "OBJECTS = \\" >> Makefile cd $srcdir for f in *.cc; do echo "${f%cc}o \\" >> ../Makefile done cd .. echo " " >> Makefile echo ".SUFFIXES: .cc .o" >> Makefile echo " " >> Makefile echo ".cc.o:" >> Makefile echo " \$(CC) \$(CFLAGS) -c $<" >> Makefile echo " " >> Makefile echo ".o:" >> Makefile echo " \$(CC) \$(CFLAGS) $^ -o \$@ \$(LIBS)" >> Makefile echo " " >> Makefile echo "$prog: \$(OBJECTS)" >> Makefile for f in $srcdir/*.cc; do TEMP=$(exec /usr/bin/cc -MM -I$headdir $f) echo "$TEMP" >> Makefile done echo " " >> Makefile echo "clean:" >> Makefile echo " rm -f \$(OBJECTS)" >> Makefile echo " rm -f *~" >> Makefile echo " " >> Makefile echo "install: $prog" >> Makefile echo " mkdir -p \$(PREFIX)/bin" >> Makefile echo " rm -f \$(PREFIX)/bin/$prog" >> Makefile echo " cp $prog \$(PREFIX)/bin/$prog" >> Makefile echo "Makefile successfully created!!!!!"