Hi Monks,

I have a somehow "inverted" Perl problem here.

I have a lot of small applications I wrote over the time that depend on a bunch of common source files (tools). This is stuff where I never bothered to "autoconf" anything and which is expected to run on both win32 and Unix/Linux (for win32, there will be VC6/VC2005 config stuff in the appropriate dirs).

When using an Unix/Linux Makefile template (since aeons), I throwed in at some point a line that determines the applications name which is going to get built. E.g.: If I have an Unix app to build in "../sources/applications/worlddomination":

sources | +---applications | | | +---loveandpeace | | | | | +---unix | | | | | +---win32 | | | +---worlddomination | | | +---unix | | | +---win32 | +---tools--- ...

there will be a (generic) Makefile in the "./worlddomination/unix" directory that emits a:

.SUFFIXES: .cxx .cpp .c .o # APPNAME is the parent directory of the current one APPNAME = ${shell perl -MCwd -e 'print +(split/\//,cwd)[-2]'} EXE = ${APPNAME} ... (the usual stuff follows) ...

and makes an application "worlddomination" (does in most cases work). I'm not a makefile guru and therefore my question: How can this be done *simpler* with one or two shell commands (I feel the Perl invocation of ${shell perl -MCwd -e 'print +(split/\//,cwd)[-2]'} is somehow a big hammer for this purpose).

Regards & Thanks

mwa


In reply to Getting rid of Perl in Makefiles by mwah

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.