I have a several Makefiles in app specific directories like this:
/project1/apps/app_typeA/Makefile
/project1/apps/app_typeB/Makefile
/project1/apps/app_typeC/Makefile
Each Makefile includes a .inc file in this path one level up:
/project1/apps/app_rules.inc
Inside app_rules.inc I'm setting the destination of where I want the binaries to be placed when built. I want all binaries to be in their respective app_type
path:
/project1/bin/app_typeA/
I tried using $(CURDIR)
, like this:
OUTPUT_PATH = /project1/bin/$(CURDIR)
but instead I got the binaries buried in the entire path name like this: (notice the redundancy)
/project1/bin/projects/users/bob/project1/apps/app_typeA
What can I do to get the "current directory" of execution so that I can know just the app_typeX
in order to put the binaries in their respective types folder?
update 2018/03/05 finnaly I use this:
It can be executed correct in relative path or absolute path. Executed correct invoked by crontab. Executed correct in other shell.
show example, a.sh print self path.
old: I use this:
It can show correct if executed in other shell and other directory.
If the make variable contain the Relative path is ROOT_DIR
Them to get the absolute path just use below method.
Its work fine in GNUMake...
As taken from here;
Shows up as;
Hope this helps
I tried many of these answers, but on my AIX system with gnu make 3.80 I needed to do some things old school.
Turns out that
lastword
,abspath
andrealpath
were not added until 3.81. :(As others have said, not the most elegant as it invokes a shell twice, and it still has the spaces issues.
But as I don't have any spaces in my paths, it works for me regardless of how I started
make
:All give me
wherever
forcurrent_dir
and the absolute path towherever
formkfile_dir
.