This is the mail archive of the cygwin@sourceware.cygnus.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Magic variables for make and Cygwin drive mapping


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@sourceware.cygnus.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]