#!/bin/sh ############################################################## makeconf.makefile ######################## A Makefile-making script by Fatih Demir [ kabalak@gmx.net ] ############################################################## R 0.2 - 5 Dec. 1999 ########################################## The variables ep=" [ kabalak@gmx.net ] " N=0.2 wsite=" http://kabalak2001.tripod.com " cizgi="---------------------------------------------------------------------------" im="|" tarih=`date +%d.%m.%Y\ %H:%M` ########################################## The procedures function mm_oku () { echo "$im makeconf.makefile $N" [ -f Makefile ] && mv Makefile Makefile_old && echo "$im Moved existing Makefile to Makefile_old" echo "$im" echo "$im The compiler to use : " ; read -p "$im > " comp case $comp in "") echo "$im You didn't specify a compiler , assuming to use gcc .." export mm_comp=gcc ;; *) export mm_comp=$comp ;; esac echo "$im Any special c(++)flags to use : " ; read -p "$im >" cfl case $cfl in "") echo "$im Using standard C(++)Flags ..." ;; *) export mm_cfl="$cfl" ;; esac echo "$im Additional include paths ?" ; read -p "$im >" incp case $incp in "") echo "$im Using standard include paths ..." export mm_inc="-I -I. -I.. -I/usr/include -I/usr/local/include " ;; *) echo "$im Give in your additional include paths (with leading -I ) : " read -p "$im >" inc_p case $inc_p in "") echo "$im Using standard include paths ..." export mm_inc="-I -I. -I.. -I/usr/include -I/usr/local/include " ;; *) export mm_inc="-I -I. -I.. -I/usr/include -I/usr/local/include $inc_p " ;; esac ;; esac echo "$im Include debug information ? " ; read -p "$im >" kar case $kar in y|yes|Yes|YES) echo "$im Which debug level 1-3 :" ; read -p "$im >" dlvl case $dlvl in "") echo "$im Using debug level 1 ..." export mm_dfl="-g1" ;; *) if test $dlvl -lt 3 && test $dlvl -gt 0 ; then echo "$im Using debug level $dlvl" export mm_dfl="-g$dlvl" fi ;; esac ;; *) echo "$im Will not include any debugging information ..," export mm_dfl="" ;; esac echo "$im Make any optimization ? " ; read -p "$im >" kar case $kar in y|yes|Yes|YES) echo "$im Which optimization level 1-9 :" ; read -p "$im >" olvl case $olvl in "") echo "$im Using optimization level 2 ..." export mm_ofl="-O2" ;; *) if test $olvl -lt 10 && test $olvl -gt 0 ; then echo "$im Using optimization level $olvl" export mm_ofl="-O$dlvl" fi ;; esac ;; *) echo "$im Will not use any optimization ..." export mm_ofl="" ;; esac echo "$im Your input files : " ; read -p "$im >" ifl case $ifl in "") echo "$im You didn't give a input file / input files , exitting ..." exit 1 ;; *) for i in $ifl do [ -f $i ] || dosya_yok done echo "$im Using $ifl as the input files " export mm_if="$ifl" ;; esac echo "$im Your output programm : " ; read -p "$im >" ofl case $ofl in "") echo "$im You didn't give a name to the output product " echo "$im Using \"MyProgramm\" as output product name ..." export mm_of=MyProgramm ;; *) echo "$im Specifying $ofl as the output product ..." export mm_of="$ofl" ;; esac echo "$im The current version of $mm_of : " ; read -p "$im >" ofv case $ofv in "") echo "$im Assuming that this is version 0.1 ... " export mm_v=0.1 ;; *) echo "$im Version of $mm_of is set to $ofv ..." export mm_v=$ofv ;; esac echo "$im Your linking flags : " ; read -p "$im >" lfl case $lfl in "") echo "$im Using the standard \"-lm -lc\" flags .." export mm_lfl="-lm -lc" ;; *) echo "$im Using $lfl as linking flags ..." export mm_lfl="$lfl" ;; esac echo "$im Define a default installation path :" ; read -p "$im >" i_p case $i_p in "") echo "$im Using /usr/local/bin as default installation path ..." export mm_ip=/usr/local/bin ;; *) echo "$im Using $i_p as default installation path ..." export mm_ip=$i_p ;; esac mm_yaz function dosya_yok () { echo "$im The file $i doesn't exist !" echo "$im Exitting .." exit 1 } } function mm_yaz () { echo "## This is the Makefile for $mm_of " >> Makefile echo "## -> It was generated with makeconf.makefile R $N by $USER on $HOSTNAME" >> Makefile echo "COMPILER=$mm_comp" >> Makefile echo "INC=$mm_inc" >> Makefile echo "CFLAGS=$mm_cfl" >> Makefile echo "OPT_LEVEL=$mm_ofl" >> Makefile echo "DEBUG_LEVEL=$mm_dfl" >> Makefile echo "LDFLAGS=$mm_lfl" >> Makefile echo "VERSION=$mm_v" >> Makefile echo "OF=$mm_of" >> Makefile echo $mm_if > ~/.mm_temp && sed -e s/\.[cC]../.o/g ~/.mm_temp > ~/.mm_objs grep -sq .[cC] ~/.mm_temp && export mm_c=1 grep -sq .[cC].. ~/.mm_temp && export mm_c=0 [ -f ~/.mm_temp ] && rm -f ~/.mm_temp echo "OBJECTS=`cat ~/.mm_objs`" >> Makefile [ -f ~/.mm_objs ] && rm -f ~/.mm_objs echo "INSTALL_PATH=$mm_ip" >> Makefile echo "" >> Makefile case $mm_c in 1) echo "%.o : %.c" >> Makefile ;; 0) echo "%.o : %.cpp" >> Makefile ;; esac echo -e '\t@echo Compiling $@' >> Makefile echo -e '\t@$(COMPILER) $(CFLAGS) $(INC) $(DEBUG_LEVEL) $(OPT_LEVEL) -c $< -o $@' >> Makefile echo "" >> Makefile echo 'all:$(OBJECTS)' >> Makefile echo -e '\t@echo Compiling and Linking $(OF) ' >> Makefile echo -e '\t@$(COMPILER) $(CFLAGS) $(INC) $(DEBUG_LEVEL) $(OPT_LEVEL) -o $(OF) $(OBJECTS) $(LDFLAGS)' >> Makefile echo "" >> Makefile echo 'clean:$(OBJECTS) $(OF)' >> Makefile echo -e '\t@echo Cleaning object files ...' >> Makefile echo -e '\t@[ -f $(OF) ] && rm -f $(OF)' >> Makefile echo -e '\t@rm -f $(OBJECTS)' >> Makefile echo -e '\t@echo Finished with cleaning ' >> Makefile echo "" >> Makefile echo 'install:$(OF)' >> Makefile echo -e '\t@echo Installing $(OF) to $(INSTALL_PATH) ...' >> Makefile echo -e '\t@[ -d $(INSTALL_PATH) ] || mkdir -p $(INSTALL_PATH)' >> Makefile echo -e '\t@mv -f $(OF) $(INSTALL_PATH)' >> Makefile echo -e '\t@[ -f $(INSTALL_PATH)/$(OF) ] || @echo An error ocured ' >> Makefile echo -e '\t@echo Installed $(OF) to $(INSTALL_PATH)' >> Makefile echo "" >> Makefile echo 'uninstall:$(INSTALL_PATH)/$(OF)' >> Makefile echo -e '\t@echo Uninstalling $(OF) ....' >> Makefile echo -e '\t@rm -f $(INSTALL_PATH)/$(OF)' >> Makefile echo -e '\t@echo Finished with uninstall' >> Makefile echo "" >> Makefile echo 'dist:Makefile *' >> Makefile echo -e '\t@echo Packing distribution package for $(OF)' >> Makefile echo -e '\t@mkdir $(OF)-$(VERSION)' >> Makefile echo -e '\t@cp * $(OF)-$(VERSION)/' >> Makefile echo -e '\t@tar -czhf $(OF)-$(VERSION).tar.gz $(OF)-$(VERSION)' >> Makefile echo -e '\t@echo Finished with packing ' >> Makefile echo "" >> Makefile echo 'help:Makefile' >> Makefile echo -e '\t@echo The targets of this Makefile are :' >> Makefile echo -e '\t@echo\tall\t\tCompile the programm' >> Makefile echo -e '\t@echo\tinstall\t\tInstall $(OF) to $(INSTALL_PATH)' >> Makefile echo -e '\t@echo\tuninstall\t\tRemove $(OF) from $(INSTALL_PATH)' >> Makefile echo -e '\t@echo\tdist\t\tMake a distribution package of $(OF)' >> Makefile echo -e '\t@echo\tclean\t\tRemove the object files ' >> Makefile echo -e '\t@echo\thelp\t\tShows this help ' >> Makefile echo "" >> Makefile } function mm_mededi () { echo "$cizgi" echo "$im > makeconf.makefile R $N by " echo "$im" echo -e "$im > \t Fatih Demir $ep " echo "$im" echo "$im > This script will help you to make \"good\" Makefiles without autoXYZ* ." echo "$im > Try it with this script and mail me if you have more ideas for this script !" echo "$im" echo "$cizgi" exit 3 } function mm_nesili () { echo "$cizgi" echo "$im > makeconf.makefile R $N by " echo "$im" echo -e "$im > \t Fatih Demir $ep " echo "$im" echo "$im > Written on 5th December 1999 " echo "$im" echo "$im > Website : $wsite" echo "$im" echo "$cizgi" exit 3 } ############################################ The main loop case $1 in --help|-help|-h|-?) mm_mededi ;; --version|-version|-v) mm_nesili ;; *) mm_oku ;; esac