www.delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1999/09/01/04:58:14

Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT sourceware DOT cygnus DOT com>
List-Subscribe: <mailto:cygwin-subscribe AT sourceware DOT cygnus DOT com>
List-Archive: <http://sourceware.cygnus.com/ml/cygwin/>
List-Post: <mailto:cygwin AT sourceware DOT cygnus DOT com>
List-Help: <mailto:cygwin-help AT sourceware DOT cygnus DOT com>,
<http://sourceware.cygnus.com/ml/#faqs>
Sender: cygwin-owner AT sourceware DOT cygnus DOT com
Delivered-To: mailing list cygwin AT sourceware DOT cygnus DOT com
Message-ID: <C2D7D58DBFE9D111B0480060086E96358D71D5@gftmail.gft.de>
From: "Schaible, Joerg" <Joerg DOT Schaible AT gft DOT de>
To: "'cygwin-list'" <cygwin AT sourceware DOT cygnus DOT com>
Subject: Magic variables for make and Cygwin drive mapping
Date: Wed, 1 Sep 1999 10:56:08 +0200
MIME-Version: 1.0
X-Mailer: Internet Mail Service (5.5.2448.0)
X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id EAA08321

Hello,

writing currently GNU make compatible make files for different plattforms I
also have to deal with the Cygwin naming scheme using absolute paths within
the system. The make rules and Cygwin tools handle the Cygwin drive mapping,
the probably needed DOS/Win-based tools won't. So I have defined the
following variables to deal with the situation within the rules.

To convert your own file names or directory lists just have a look at the
first variable RT and replace the $@ by your variable. The "macro" will
preserve the sequence. You may test your variables with the debug targets at
the end (e.g. make for.TEST TEST="a b c d e f").

Hope others will find this helpfull.

Greetings
Jörg


------------------------------ cygwin path converter variables
-----------------------------------------

# Special variables to deal with cygwin

ifeq ($(OSTYPE),cygwin32)

ALLDRIVES       := a b c d e f g h i j k l m n o p q r s t u v w x y z
CYGWINROOTDRIVE := c
CYGWINMAPPING   := //
#CYGWINMAPPING   := /cygwin/

# Rule target
RT = $(strip $(subst /,\\,$(foreach directory,$@,$(foreach
drive,$(ALLDRIVES),$(filter $(drive):/%,$(patsubst
//$(drive)/%,$(drive):/%,$(directory)))) $(patsubst
/%,$(CYGWINROOTDRIVE):/%,$(filter-out $(CYGWINMAPPING)%,$(directory))))))
# First dependend
RF = $(strip $(subst /,\\,$(foreach directory,$<,$(foreach
drive,$(ALLDRIVES),$(filter $(drive):/%,$(patsubst
//$(drive)/%,$(drive):/%,$(directory)))) $(patsubst
/%,$(CYGWINROOTDRIVE):/%,$(filter-out $(CYGWINMAPPING)%,$(directory))))))
# Newer dependend
RN = $(strip $(subst /,\\,$(foreach directory,$?,$(foreach
drive,$(ALLDRIVES),$(filter $(drive):/%,$(patsubst
//$(drive)/%,$(drive):/%,$(directory)))) $(patsubst
/%,$(CYGWINROOTDRIVE):/%,$(filter-out $(CYGWINMAPPING)%,$(directory))))))
# All dependend
RA = $(strip $(subst /,\\,$(foreach directory,$^,$(foreach
drive,$(ALLDRIVES),$(filter $(drive):/%,$(patsubst
//$(drive)/%,$(drive):/%,$(directory)))) $(patsubst
/%,$(CYGWINROOTDRIVE):/%,$(filter-out $(CYGWINMAPPING)%,$(directory))))))
# Stem of rule target
RS = $(strip $(subst /,\\,$(foreach directory,$*,$(foreach
drive,$(ALLDRIVES),$(filter $(drive):/%,$(patsubst
//$(drive)/%,$(drive):/%,$(directory)))) $(patsubst
/%,$(CYGWINROOTDRIVE):/%,$(filter-out $(CYGWINMAPPING)%,$(directory))))))

# Rule target without extension
RTB = $(strip $(subst /,\\,$(foreach directory,$(basename $@),$(foreach
drive,$(ALLDRIVES),$(filter $(drive):/%,$(patsubst
//$(drive)/%,$(drive):/%,$(directory)))) $(patsubst
/%,$(CYGWINROOTDRIVE):/%,$(filter-out $(CYGWINMAPPING)%,$(directory))))))
# First dependend without extension
RFB = $(strip $(subst /,\\,$(foreach directory,$(basename $<),$(foreach
drive,$(ALLDRIVES),$(filter $(drive):/%,$(patsubst
//$(drive)/%,$(drive):/%,$(directory)))) $(patsubst
/%,$(CYGWINROOTDRIVE):/%,$(filter-out $(CYGWINMAPPING)%,$(directory))))))

# Rule target directory
RTD = $(strip $(subst /,\\,$(foreach directory,$(@D),$(foreach
drive,$(ALLDRIVES),$(filter $(drive):/%,$(patsubst
//$(drive)/%,$(drive):/%,$(directory)))) $(patsubst
/%,$(CYGWINROOTDRIVE):/%,$(filter-out $(CYGWINMAPPING)%,$(directory))))))
# First dependend directory
RFD = $(strip $(subst /,\\,$(foreach directory,$(<D),$(foreach
drive,$(ALLDRIVES),$(filter $(drive):/%,$(patsubst
//$(drive)/%,$(drive):/%,$(directory)))) $(patsubst
/%,$(CYGWINROOTDRIVE):/%,$(filter-out $(CYGWINMAPPING)%,$(directory))))))

else

# Rule target
RT = $@
# First dependend
RF = $<
# Newer dependend
RN = $<
# All dependend
RA = $^
# Stem of rule target
RS = $*

# Rule target without extension
RTB = $(basename $@)
# First dependend without extension
RFB = $(basename $<)

# Rule target directory
RTD = $(@D)
# First dependend directory
RFD = $(<D)

endif

------------------------------ debug targets
-----------------------------------------

ECHO = echo -e

echo.%:
    @$(ECHO) $(subst \,\\,$($(patsubst echo.%,%,$@)))

for.%:
    @for i in $(subst \,\\,$($(patsubst for.%,%,$@))); do $(ECHO) $$i; done



--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019