Login
Username:

Password:

Remember me



Lost Password?

Register now!

Sections

Who's Online
59 user(s) are online (42 user(s) are browsing Forums)

Members: 1
Guests: 58

rjd324, more...

Headlines

 
  Register To Post  

Get disk or volume name from a makefile
Quite a regular
Quite a regular


See User information
Hello everyone,

i have a little question:

i can i get the volume name of amiga system from a script (makefile)?

My volume name is AmigaOS
If i use pwd the system returns /AmigaOS, while if if i use cd the system returns AmigaOS:.

Now some scripts can't interpret as example /AmigaOS/Software/Development, while other doesn't understand AmigaOS:Software/Development.

There is a straight way to get (within a makefile) the volume name AmigaOS:?

thank you very much

Retired
Go to top
Re: Get disk or volume name from a makefile
Home away from home
Home away from home


See User information
I don't understand what result you are trying to get. You said pwd gives "/AmigaOS" while cd gives "AmigaOS:", so surely that is already the result you want?!?

Author of the PortablE programming language.
Go to top
Re: Get disk or volume name from a makefile
Quite a regular
Quite a regular


See User information
@ChrisH

hi Chris.

Thank you for the reply.

I get AmigaOS: if i type cd directly in the shell, but now within a makefile.

I would like to know if there is a special command to get this directly from the makefile.

Retired
Go to top
Re: Get disk or volume name from a makefile
Just can't stay away
Just can't stay away


See User information
@AmigaBlitter
Here is a small makefile that gets & prints the path and volume:
PATH := $(shell cd)
VOLNAME := $(shell C:cut $(PATHWORD=1 S=":")
VOLUME := $(VOLNAME):

all:
    @
C:echo $(PATH)
    @
C:echo $(VOLNAME)
    @
C:echo $(VOLUME)


If you want it to work when make is called from a *nix shell (sh), you'll need to use *nix commands (like ones in SDK:local/C) instead of Amiga commands.

Amiga X1000 with 2GB memory & OS 4.1FE + Radeon HD 5450

Go to top
Re: Get disk or volume name from a makefile
Quite a regular
Quite a regular


See User information
@xenic

Thank you for the script.

I will test this evening.

But what if i want to have the amiga standard dir

AmigaOS:Software/Development

if i have for example /AmigaOS/Software/Development

In that case i have to substitute the second "/" in the string.




Retired
Go to top
Re: Get disk or volume name from a makefile
Quite a regular
Quite a regular


See User information
Please try this on amiga and see what returns:

amigacurdir=`cd "\`dirname "$0"\`";pwd`

Retired
Go to top
Re: Get disk or volume name from a makefile
Home away from home
Home away from home


See User information
@AmigaBlitter

If your project is amigaos specific just use make which will then use the AmigaOS shell (as long as SHELL is not set to sh) other wise use gmake (or set SHELL to sh) and use the abc-shell and asociated commands. Avoid mixing them then you shouldn't need to worry about having the wrong kind of path.

I would suggest that perhaps there is a flaw in your makefile design if you need to worry to much about the absolute path of the current directory, normally relative paths should suffice. Ofcouse without a specific example of what you are doing it's hard to give more spefic advice.

String manipulation is possible with the makefile commands available but it's not the easist "programing language" ever writen. See the docs in the SDK....


Go to top
Re: Get disk or volume name from a makefile
Quite a regular
Quite a regular


See User information
@xenic

unfortunately the script doesn't work.

@broadblues
thank you for the tips.

what this string return for you?
amigacurdir=`cd "\`dirname "$0"\`";pwd`

Retired
Go to top
Re: Get disk or volume name from a makefile
Home away from home
Home away from home


See User information
@AmigaBlitter

Quote:

what this string return for you?
amigacurdir=`cd "\`dirname "$0"\`";pwd`


In what context? sh script? amigaos scriptmake file element?

I should imagine when I knowe the context it will exactly the same as it does for you.

Can you be a bit more explicit about what you are trying to do? ie the end result not an intermediate step?

Go to top
Re: Get disk or volume name from a makefile
Home away from home
Home away from home


See User information
@xenic

Unfortunatly $shell(cd) actually returns an unix style path, I suspect CD is executed under 'SH' when run that way, so that is messing up your following cut...

Also using PATH is a bad idea as PATH is likely set to the unix search path, for GCC and abc-shell benefit if nothing else.


CURDIR := $shell(cd)
VOLNAME := $(shell C:cut $(CURDIRWORD=2 S="/")
VOLUME := $(VOLNAME):

all
    echo $(
CURDIR)
    echo $(
VOLNAME)
    echo $(
VOLUME)


This variation works for me, (but only when run as make not as gmake)

11.NGFSBoot:> make -f RAM:Makefile
echo /NGFSBoot
/NGFSBoot
echo NGFSBoot
NGFSBoot
echo NGFSBoot:
NGFSBoot:

with gmake

11.NGFSBoot:> gmake -f RAM:Makefile
echo /NGFSBoot
/NGFSBoot
echo T:gmake.sh.863.MEINBH[1]: C:cut: not found sh failed returncode 127
T:gmake.sh.863.MEINBH[1]: C:cut: not found sh failed returncode 127
echo T:gmake.sh.863.MEINBH[1]: C:cut: not found sh failed returncode 127:
T:gmake.sh.863.MEINBH[1]: C:cut: not found sh failed returncode 127:





Edited by broadblues on 2016/12/23 0:49:59
Go to top
Re: Get disk or volume name from a makefile
Home away from home
Home away from home


See User information
@broadblues


/FACEPALM

CURDIR contains the current directory so my script $shell(cd) is doing nothing!

VOLNAME := $(shell C:cut $(CURDIRWORD=2 S="/")
VOLUME := $(VOLNAME):

all
    echo $(
CURDIR)
    echo $(
VOLNAME)
    echo $(
VOLUME)


does the trick all by itself.

11.NGFSBoot:Classes> make -f RAM:Makefile
echo /NGFSBoot/Classes
/NGFSBoot/Classes
echo NGFSBoot
NGFSBoot
echo NGFSBoot:
NGFSBoot:


Go to top
Re: Get disk or volume name from a makefile
Just can't stay away
Just can't stay away


See User information
@AmigaBlitter
In your original post you said you wanted to get the volume name; which is what my example makefile does. The makefile is just an example of what you can do with the $(shell xxx) command in a makefile.

I included the caveat:
"If you want it to work when make is called from a *nix shell (sh), you'll need to use *nix commands (like ones in SDK:local/C) instead of Amiga commands."

I suppose I should have mentioned that using gmake can affect your results too.

Amiga X1000 with 2GB memory & OS 4.1FE + Radeon HD 5450

Go to top
Re: Get disk or volume name from a makefile
Quite a regular
Quite a regular


See User information
@xenic

I know, thank you.
I'ts not your fault.
Maybe i've done something in the wrong way.
However your script is interesting. I saved it for later use

@broadblues

I'm using a makefile that needs to get some paths.
I needs path in the Amiga style AmigaOS:Software/Development
but if i try with pwd i get the following /AmigaOS/Software/Development.

I tried with cd, but cd is not interpred (doesn't return anything).

Finally i ended up using pwd and modifying the result with sed

Original path: /AmigaOS/Software/Development
Converted path: AmigaOS:Software/Development


I was interested to know if there was been a direct command or already defined "var" returning directly the path in Amiga style.

Retired
Go to top
Re: Get disk or volume name from a makefile
Just can't stay away
Just can't stay away


See User information
@broadblues

I got the impression from AmigaBlitter's original post that he wanted to get the Amiga format volume name so the example makefile is intended to demonstrate using $(shell xxx) can be used to get the current volume name when it's run in an Amiga environment (Amiga shell with make).

I thought my caveat:
"If you want it to work when make is called from a *nix shell (sh), you'll need to use *nix commands (like ones in SDK:local/C) instead of Amiga commands."
would make it clear that the example would not work if run in a *nix environment ("sh" shell and or gmake). Apparently I was wrong.

Yes, using PATH (and a lot of other variables) can lead to problems if using sh or gmake. Something like MYPATH would be more appropriate.

Since "CD" is an internal sh command and Amiga "CD" is a resident command (not in C:), using "CD" to get an AmigaOS style volume name directly doesn't appear to be possible from the *nix shell ( sh ). However, your use of the CURDIR variable seems to work. With a slight modification it seems to work in an "sh" shell and Amiga shell with make and gmake:

SHELL := sh
VOLNAME 
:= $(shell /C/Cut $(CURDIRWORD=2 S="/")
VOLUME := $(VOLNAME):

all:
    echo 
"$(CURDIR)"
    
echo "$(VOLNAME)"
    
echo "$(VOLUME)"


NOTE: Copying code from this forum seems to introduce non-printable characters that cause the example makefiles to fail. I had to manually copy them in an editor & then save them.


Amiga X1000 with 2GB memory & OS 4.1FE + Radeon HD 5450

Go to top
Re: Get disk or volume name from a makefile
Home away from home
Home away from home


See User information
@xenic

Quote:

NOTE: Copying code from this forum seems to introduce non-printable characters that cause the example makefiles to fail. I had to manually copy them in an editor & then save them.


I edited most of those away but seems I missed at least one NBSP in the first line, causing it not to execute, making it look like PATH wasn't overidable (which caused me to raise an eyebrow as I thought I knew it was, and I was in fact correct )or that $(shell cd) did not work even in make (as opposed to gmake).

Really could do with a editor font that displayed those pesky things as small dots so it's obvious when they have crept in. Few languages seem to recognise them as whitespace...

Typing everythin again from scratch then makes it work and even CURDIR can be overidden but left to it's own devices it still seems the simplest way of getting the current directory


My initial choice of CURDIR as an alternative to PATH was just plain confusing as I didn't realise it did the obvious.

@AmigaBlitter

Quote:

Finally i ended up using pwd and modifying the result with sed


That's a perfectly acceptable solution.


Go to top
Re: Get disk or volume name from a makefile
Quite a regular
Quite a regular


See User information
@broadblues

What about -lunix flag?

I remember that someone told me to use this flag.
How an amiga path would be threated in this case?

I tried to add the -lunix flag, btw, and i get -lunix: not found

Retired
Go to top

  Register To Post

 




Currently Active Users Viewing This Thread: 1 ( 0 members and 1 Anonymous Users )




Powered by XOOPS 2.0 © 2001-2023 The XOOPS Project