From 3debd647438eff6f8a67cbb2e4d89c218653ec6d Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Thu, 21 Feb 2002 11:48:33 +0000 Subject: [PATCH] Laurent Rineau: create_makefile is back, with a new syntax for moc source file. --- Packages/Qt_widget/create_makefile_qt | 168 ++++++++++++++++++ .../Qt_widget/demo/Qt_widget/constrained.C | 2 +- .../Qt_widget/include/CGAL/IO/Qt_widget.h | 4 - Packages/Qt_widget/src/CGALQt/Qt_widget.C | 2 +- 4 files changed, 170 insertions(+), 6 deletions(-) create mode 100755 Packages/Qt_widget/create_makefile_qt diff --git a/Packages/Qt_widget/create_makefile_qt b/Packages/Qt_widget/create_makefile_qt new file mode 100755 index 00000000000..d3eec1bc703 --- /dev/null +++ b/Packages/Qt_widget/create_makefile_qt @@ -0,0 +1,168 @@ +#!/bin/sh +# +# This script creates a CGAL makefile with entries for all .C files in the +# current directory. +# +# Usage: create_makefile [-options] [outputfile] +# +# -d create a default CGAL makefile +# -t create a makefile for the test suite +# -w create a makefile with flags for LEDA windows +# -g create a makefile with flags for GEOWIN +# -q create a makefile with support for QT + +#VERSION=2.0 + +header() +{ + echo "#---------------------------------------------------------------------#" + echo "# $1" + echo "#---------------------------------------------------------------------#" +} + +create_makefile_entry() +{ + local CFILE MOC_FROM MOCFILE + CFILE=$1.C + MOCFILE="" + if [ -n "$QT" ]; then + if MOC_FROM=`awk 'BEGIN{ FS=":"; COUNT=0 } \ + /\/\/ *moc_source_file *:/ {print $2; COUNT++} \ + END{ exit COUNT==0 }' $CFILE`; then + MOCFILE=$1.moc + echo "$MOCFILE: $MOC_FROM" + echo " \$(QT_MOC) -o $MOCFILE \$<" + echo + echo "$1\$(OBJ_EXT): $MOCFILE" + echo + fi + fi + if grep -q 'main *(' $CFILE ; then + echo "$1\$(EXE_EXT): $1\$(OBJ_EXT)" + echo " \$(CGAL_CXX) \$(LIBPATH) \$(EXE_OPT)$1 $1\$(OBJ_EXT) \$(LDFLAGS)" + echo + fi; +} + +create_makefile() +{ + echo "# Created by the script create_makefile" + echo "# This is the makefile for compiling a CGAL application." + echo + header "include platform specific settings" + echo "# Choose the right include file from the /make directory." + echo + echo "# CGAL_MAKEFILE = ENTER_YOUR_INCLUDE_MAKEFILE_HERE" + echo "include \$(CGAL_MAKEFILE)" + echo + header "compiler flags" + echo + echo "CXXFLAGS = \\" + if [ ! -z "$TESTSUITE" ] ; then + echo " \$(TESTSUITE_CXXFLAGS) \\" + echo " \$(EXTRA_FLAGS) \\" + fi + echo " \$(CGAL_CXXFLAGS) \\" + if [ -d include ] ; then + echo " -Iinclude \\" + fi + echo " \$(LONG_NAME_PROBLEM_CXXFLAGS) \\" + echo " \$(DEBUG_OPT)" + echo + header "linker flags" + echo + echo "LIBPATH = \\" + if [ ! -z "$TESTSUITE" ] ; then + echo " \$(TESTSUITE_LIBPATH) \\" + fi + if [ -z "$LEDAWINDOWS" ] ; then + echo " \$(CGAL_LIBPATH)" + else + echo " \$(CGAL_WINDOW_LIBPATH)" + fi + echo + echo "LDFLAGS = \\" + if [ ! -z "$TESTSUITE" ] ; then + echo " \$(TESTSUITE_LDFLAGS) \\" + fi + echo " \$(LONG_NAME_PROBLEM_LDFLAGS) \\" + if [ -n "$QT" ] ; then + echo " \$(CGAL_QT_LDFLAGS) \\" + fi + if [ -n "$GEOWIN" ] ; then + echo " \$(CGAL_GEOWIN_LDFLAGS)" + elif [ -z "$LEDAWINDOWS" ] ; then + echo " \$(CGAL_LDFLAGS)" + else + echo " \$(CGAL_WINDOW_LDFLAGS)" + fi + echo + header "target entries" + echo + printf "all: " + for file in `ls *.C` ; do + printf "\\\\\n `basename $file .C`\$(EXE_EXT) " + done + echo + echo + for file in `ls *.C` ; do + base=`basename $file .C` + create_makefile_entry $base + done + printf "clean: " + for file in `ls *.C` ; do + printf "\\\\\n `basename $file .C`.clean " + done + printf "\n\n" + header "suffix rules" + echo + echo ".C\$(OBJ_EXT):" + echo " \$(CGAL_CXX) \$(CXXFLAGS) \$(OBJ_OPT) \$<" + echo +} + +usage() +{ + echo "Usage: create_makefile [-options] [outputfile]" + echo + echo "-d create a default CGAL makefile" + echo "-t create a makefile for the test suite" + echo "-w create a makefile with flags for LEDA windows" + echo "-g create a makefile with flags for GEOWIN" + echo "-q create a makefile with flags for QT" +} + +case $# in + 0) usage + exit 1 +esac + +for i do + case $i in + -d) ;; + -t) TESTSUITE='y';; + -w) LEDAWINDOWS='y';; + -g) GEOWIN='y';; + -q) QT='y';; + -*) usage + exit 1;; + *) if [ -z "$OUTPUTFILE" ] ; then + OUTPUTFILE=$i + else + usage + exit 1 + fi;; + esac +done + +if [ -z "$OUTPUTFILE" ] ; then + OUTPUTFILE=makefile +fi + +if [ -f ${OUTPUTFILE} ] ; then + echo "moving $OUTPUTFILE to ${OUTPUTFILE}.bak ..." + mv -f $OUTPUTFILE ${OUTPUTFILE}.bak +fi +create_makefile > $OUTPUTFILE +echo "created $OUTPUTFILE ..." + diff --git a/Packages/Qt_widget/demo/Qt_widget/constrained.C b/Packages/Qt_widget/demo/Qt_widget/constrained.C index d4027893a4c..b78d72938ff 100644 --- a/Packages/Qt_widget/demo/Qt_widget/constrained.C +++ b/Packages/Qt_widget/demo/Qt_widget/constrained.C @@ -234,7 +234,7 @@ private: Constrained_triangulation ct; }; -// CGAL_MOC_FROM("constrained.C") +// moc_source_file : constrained.C #include "constrained.moc" int diff --git a/Packages/Qt_widget/include/CGAL/IO/Qt_widget.h b/Packages/Qt_widget/include/CGAL/IO/Qt_widget.h index 0fab8cdd747..cb6592adc75 100644 --- a/Packages/Qt_widget/include/CGAL/IO/Qt_widget.h +++ b/Packages/Qt_widget/include/CGAL/IO/Qt_widget.h @@ -33,10 +33,6 @@ #include #include -/* Define an empty macro with parameter - Used by create_makefile */ -//#define CGAL_MOC_FROM(filename) - namespace CGAL { class Qt_widget_tool; diff --git a/Packages/Qt_widget/src/CGALQt/Qt_widget.C b/Packages/Qt_widget/src/CGALQt/Qt_widget.C index fd3eb863884..ad9706f5096 100644 --- a/Packages/Qt_widget/src/CGALQt/Qt_widget.C +++ b/Packages/Qt_widget/src/CGALQt/Qt_widget.C @@ -452,7 +452,7 @@ void Qt_widget::redraw() } // namespace CGAL -//CGAL_MOC_FROM("../../include/CGAL/IO/Qt_widget.h") +// moc_source_file: ../../include/CGAL/IO/Qt_widget.h #include "Qt_widget.moc" #endif