automake
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Part 2: Add Cleanfiles for User Defined Special Sources [Re: How to


From: Vincent Torri
Subject: Re: Part 2: Add Cleanfiles for User Defined Special Sources [Re: How to add new Makefile-Rules through Configure?]
Date: Tue, 10 Mar 2015 11:54:37 +0100

On Tue, Mar 10, 2015 at 10:47 AM, Marc Wäckerlin <address@hidden> wrote:
> Thank you for the answers.
>
>
> The question remains:
>
> Isn't there a proper way to add makefile rules from within a configure.ac
> script?
>
>
> Am 10.03.2015 00:46, schrieb Peter Johansson:
>>
>> On 03/09/2015 06:34 PM, Marc Wäckerlin wrote:
>>>
>>> Just to state my intention: I want to ad a couple of M4-Macros to support
>>> users of now unsupported build tools, namely doxygen, Qt, dpkg-buildpackage,
>>> rpmbuild, ...; then I will deliver those as M4 macro library that can be
>>> included in configure.ac and that should do as much as possible
>>> "automagically" - as usual within the autotools.
>>
>>
>> I have a macro YAT_SVN_RELEASE that I use in several projects
>> http://dev.thep.lu.se/yat/svn/trunk/m4/yat_svn_release.m4
>
>
> Ok, I see, you generate a separate auxiliary.am file with your rules.
>
> But then the user of your macro still has to include that auxiliary.am in
> his makefile. My intention is, to push new rules from configure.ac to a
> makefile without any other user interaction than including my m4 macro or
> calling my m4 function ("user" here means the programmer that uses my m4
> environment).
>
>
>> You may also find AX_ADD_AM_MACRO_STATIC useful
>>
>> http://www.gnu.org/software/autoconf-archive/ax_add_am_macro_static.html#ax_add_am_macro_static
>
>
> Hmm, one option could be to append rules to an existing makefile.in file ...
>
> Is that less evil than my variable-hack?
>
>
> This works, but is it "acceptable" coding?
>
> configure.ac:
> --------------------------------------------------------
> AC_CONFIG_FILES([makefile])
> cat >> makefile.in <<EOF
> do-a-test:
>         @echo "Hey, it works in project: address@hidden@"
> EOF
> --------------------------------------------------------
>>
>> make do-a-test
>
> Hey, it works in project: libpcscxx-3.1.282
> --------------------------------------------------------
>
> and is it better than this trick:
>
> configure.ac:
> --------------------------------------------------------
>   MY_DIRTY_TRICK_TO_ADD_CODE_TO_MAKEFILE='
> do-a-test:
>         @echo "Hey, it works in project: address@hidden@"'
>   AC_SUBST(MY_DIRTY_TRICK_TO_ADD_CODE_TO_MAKEFILE)
> --------------------------------------------------------
>>
>> make do-a-test
>
> Hey, it works in project: address@hidden@
> --------------------------------------------------------
>
> → obviousely, this does not work for @address@hidden ;)
> (not a problem for me)
>
>
> From the functionality perspective, the variable-trick puts a rule in every
> makefile, where the append-trick puts a rule in a specific makefile.
> Sometime the first is better, sometimes the latter.
>
>
> Both hacks do the trick, but both are still a hack, so again: Is there a
> better way?
>
> Any comments on what is a proper solution?
>
> Requirements fo a solution:
>  - Add makefile rules from within configure.ac
>  - No maual changes in makefile.am files required

imho, configure.ac is for configuring the project, not defining 'make'
rules. These 'make' rules should go into Makefile.am :

do-a-test:
        @echo "Hey, it works in project: $(PACKAGE_NAME)-$(PACKAGE_VERSION)"

Vincent Torri


>
>
>
>
> Just for your information, actually my m4 macro offers:
>
> Debian build rule, to be added in top makefile:
> --------------------------------------------------------
> AC_DEFUN([AX_USE_DEBIAN_PACKAGING], [
>   README_DEB=$(tail -n +3 README | sed -e 's/^$/./g' -e 's/^/ /g')
>   AC_SUBST(README_DEB)
>   _AM_SUBST_NOTMAKE([README_DEB])
>   AC_CONFIG_FILES([debian/changelog debian/control])
>   AX_DEBIAN_MAKE_RULES='
> EXTRA_DIST += ${top_srcdir}/debian
> DISTCLEANFILES += debian/changelog debian/control
> ifeq (${subdir},.)
> all:
> clean-local: clean-debian-targets
> clean-debian-targets:
>         -rm -rf
> ${PACKAGE_NAME}_${PACKAGE_VERSION}~${DISTRO}.${BUILD_NUMBER}.{dsc,tar.gz}
> ${PACKAGE_NAME}_${PACKAGE_VERSION}~${DISTRO}.${BUILD_NUMBER}*.changes
> $(shell sed -n '"'"'s,Package:
> \(.*\),\1_${PACKAGE_VERSION}~${DISTRO}.${BUILD_NUMBER}*.deb,p;'"'"'
> debian/control)
> deb: distdir
>         cd ${distdir} && ( export CFLAGS="${CFLAGS}"; export
> CPPFLAGS="${CPPFLAGS}"; export  CXXFLAGS="${CXXFLAGS}"; export
> LDFLAGS="${LDFLAGS}"; export DEB_CFLAGS_APPEND="${CFLAGS}"; export
> DEB_CPPFLAGS_APPEND="${CPPFLAGS}"; export
> DEB_CXXFLAGS_APPEND="${CXXFLAGS}"; export  DEB_LDFLAGS_APPEND="${LDFLAGS}";
> dpkg-buildpackage )
> .PHONY: clean-debian-targets deb
> endif'
>   AC_SUBST(AX_DEBIAN_MAKE_RULES)
> ])
> --------------------------------------------------------
>
>
> And for qt:
> --------------------------------------------------------
> AC_DEFUN([AX_CXX_CHECK_QT], [
>   qt_modules="$2"
>   AX_CXX_QT_TOOLS # detect moc, uic, ...
>   HAVE_$1=0
>   PKG_CHECK_MODULES([$1], [${qt_modules//Qt/Qt5}], [
>     HAVE_$1=1
>     AC_DEFINE([HAVE_$1])
>     AM_CPPFLAGS+=" ${$1_CFLAGS}"
>     AM_CXXFLAGS+=" ${$1_CFLAGS}"
>     LIBS+=" ${$1_LIBS}"
>   ], [
>     PKG_CHECK_MODULES([$1], [${qt_modules}], [
>       HAVE_$1=1
>       AC_DEFINE([HAVE_$1])
>       AM_CPPFLAGS+=" ${$1_CFLAGS}"
>       AM_CXXFLAGS+=" ${$1_CFLAGS}"
>       LIBS+=" ${$1_LIBS}"
>     ], [HAVE_$1=0])
>   ])
>   AM_CONDITIONAL(HAVE_$1, test $HAVE_$1 -eq 1)
>   AC_SUBST(AM_CPPFLAGS)
>   AC_SUBST(AM_CXXFLAGS)
>   AX_ADDITIONAL_QT_RULES_HACK='
> %_ui.hxx: %.ui
>         ${UIC} -o address@hidden $<
>
> moc_%.cxx: %.hxx
>         ${MOC} -o address@hidden $<'
>   AC_SUBST(AX_ADDITIONAL_QT_RULES_HACK)
> ])
> --------------------------------------------------------
>
>
> Thank you
> Regards
> Marc
> --
> Marc Wäckerlin
> http://marc.wäckerlin.ch
> http://marc.waeckerlin.org
>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]