Complete.Org: Mailing Lists: Archives: freeciv-dev: August 2004:
[Freeciv-Dev] Re: (PR#8640) Target "*.ruleset" at data/nation/Makefile
Home

[Freeciv-Dev] Re: (PR#8640) Target "*.ruleset" at data/nation/Makefile

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] Re: (PR#8640) Target "*.ruleset" at data/nation/Makefile
From: "Marko Lindqvist" <marko.lindqvist@xxxxxxxxxxx>
Date: Wed, 18 Aug 2004 08:36:04 -0700
Reply-to: rt@xxxxxxxxxxx

<URL: http://rt.freeciv.org/Ticket/Display.html?id=8640 >

Marko Lindqvist wrote:
  >   2. .PHONY target is used to force ruleset list update in case some
> ruleset is removed. There is at least two other ways to do same thing 
> while .PHONE is way preferred by gnu make.

  For any other make it's just unused target and they miss some 
not-so-important Makefile functionality.

>   3. Character '@' is used to suppress irrelevant output. This might 
> not work with some make programs.

  Removed

>   4. I strip .ruleset suffix from file names when I write 
> ruleset_list.txt. I like having it listing nation names without extra 
> suffix even if it's not used for anything.

  Bute of course this generated file should be usable nations.ruleset, 
so it might have some further use too. Named as nation_list.txt, though.


  - Caz

#!/bin/sh
#
# Regenerate Makefile.am based on actual contents of directory.
# This is all so 'make distcheck' will work.
#

# We need to know where rulesets really are even if called from builddir.
RSDIR=`dirname $0`
SED_ESCAPED_RSDIR=`echo $RSDIR | sed -e 's/\//\\\\\\//g'`

# Since following block is written to Makefile.am as is, I haven't
# added Makefile.am generating specific comments into it as their escape
# characters would get modified anyway (so comments in Makefile.am would be 
inccorrect).
# Some heavy escaping is used so Makefile.am turns out right, with all escape 
characters
# it in turn requires.

# Makefile.am.sh         : sed -e 's/\\//\\\\\\\\\\\\//g'
# Output to Makefile.am  : sed -e 's/\//\\\\\\//g'
# sed_escaped_srcdir contains          '\\\/' for every path delimeter
# shell appends variable               '\/'   delimeters are correctly escaped 
for sed

cat <<EOF
## Process this file with automake to produce Makefile.in

# In case some ruleset is removed, provide nation list
# update in rule 'all'.
# Too bad we cannot put this before automake generated Makefile
# regeneration rules. So we still used old Makefile versions while running
# make this time.
all : update_nation_list

## Override automake so that "make install" puts these in proper place:
pkgdatadir = \$(datadir)/@PACKAGE@/nation

pkgdata_DATA = \\
`find $RSDIR/ -name "*.ruleset" -print | sed -e "s/$SED_ESCAPED_RSDIR\///" -e 
's/.*ruleset$/            & \\\/' -e '$s/.$//'`

EXTRA_DIST = \$(pkgdata_DATA) Makefile.am.sh nation_list.txt

# Command to update nation list
RSL_UPDATE=( SED_ESCAPED_SRCDIR=\`echo \$(srcdir) | sed -e 
's/\\//\\\\\\\\\\\\//g'\` ; OLD_LIST=\`if test -e \$(srcdir)/nation_list.txt ; 
then cat \$(srcdir)/nation_list.txt ; else echo empty ; fi\` ; NEW_LIST=\`echo 
-e "; Autogenerated list of nation ruleset files.\\n; Do not edit, but run 
'make update_nation_list' to 
regenerate.\\n;\\n[datafile]\\ndescription=\\"Autogenerated nations data for 
Freeciv\\"\\noptions=\\"1.9\\"\\n" ; ls -1 \$(srcdir)/*.ruleset | grep -v 
barbarian.ruleset | sed -e "s/\$\$SED_ESCAPED_SRCDIR/\\*include \\"nation/" -e 
"s/\$\$/\"/" ; echo -e "\\n*include \\"nation/barbarian.ruleset\\"" \` ; if 
test "x\$\$OLD_LIST" != "x\$\$NEW_LIST" ; then echo "\$\$NEW_LIST" > 
\$(srcdir)/nation_list.txt ; echo "Nation list changed" ; fi )

.PHONY : update_nation_list

# This rule always updates nation list.
# Compared to nation_listt.txt:
#   Pros: This updates nation list also when ruleset is removed.
#   Cons: Every rule that has this as prerequisite is rebuilt always too.
update_nation_list :
        \$(RSL_UPDATE)

# This rule rebuils nation list if new ruleset is added.
# If existing ruleset changes, list is not rebuilt but
# rules listing this as prereq will be built.
# See also rule update_nation_list.
nation_list.txt : \$(srcdir)/*.ruleset
        \$(RSL_UPDATE)

# If ruleset file is removed, automake generated rule 'all-am'
# wants to know how to regenerate it. So we provide dummy rule
# to satisfy it. This works in most cases, but 'make dist' or
# 'make install' will fail when they actually attempt to copy
# nonexistent rulesets.
%.ruleset :
        echo "Ruleset \$@ missing, probably removed since last Makefile.am 
update"

# nation_list.txt is rebuilt before Makefile.am if new ruleset is added.
# We can't use update_nation_list as prereq here, since it
# would lead to recursive loop. This means that if ruleset is just removed,
# generated Makefile.am is not necessarily upto date.
\$(srcdir)/Makefile.am: Makefile.am.sh nation_list.txt
        sh \$(srcdir)/Makefile.am.sh > \$(srcdir)/Makefile.am

EOF

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