Sed in makefile, use

I am involved in the process of creating a makefile.

The current goal is to scan files $(SOURCEDIR)for .cand create (in accordance with these files paths .cin format /path/file.c) a good one $(VPATH), so I do not need to use recursive make files (otherwise a pain in a ..).

Atm i'm stuck with this where $(SOURCETREE)will be empty on$(ECHO)

SOURCES := $(shell find $(SOURCEDIR) -name '*.c')
SOURCETREE := $(dir $(SOURCES))
SOURCETREE := $(shell $(ECHO) $(SOURCETREE) | $(SED) -e "s/[[:space:]]/\n/g" | uniq | $(SED) -e "s/\n/[[:space:]]/g");

Maybe I just don’t understand (later late: /)

Thanks for any help.

Note. In the bash shell, it works fine on my Linux desktop (I replaced the variables accordingly) Note: I'm not a professional, so please explain if you are doing voodoo with sed, thanks

+3
source share
1

:

  • . ; $(shell) .

  • echo/sed/uniq/sed ls/uniq. ls , .

  • , $(dir), $(SOURCES) $(SOURCES), $(SOURCETREE).

:

SOURCES := $(shell find $(SOURCEDIR) -name '*.c')
SOURCETREE := $(dir $(SOURCES))
SOURCETREE := $(shell ls $(SOURCETREE) | uniq);

. $(sort) . make: ", , , ".

SOURCES := $(shell find $(SOURCEDIR) -name '*.c')
SOURCETREE := $(sort $(dir $(SOURCES)))
+5

Source: https://habr.com/ru/post/1766674/


All Articles