Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22307

Makefile - Unable to find sub-directory item pattern with "%.c"

$
0
0
PROJNAME=testTARGET=$(PROJNAME).soCC=gccLD=ldSRC=$(shell find $(SRCDIR) -name "*.c")OBJ=$(patsubst $(SRCDIR)/%.c, %.o, $(SRC))COMMONFLAGS=-Wall -WerrorCFLAGS=$(COMMONFLAGS) -fPIC $(addprefix -I,$(INCDIR))LDFLAGS=$(COMMONFLAGS) -shared $(addprefix -L,$(LIBDIR)) $(addprefix -l,$(LIB))DBG_CFLAGS=-D_DEBUG -gREL_CFLAGS=-march=native -OfastDBG_LDFLAGS=REL_LDFLAGS=-fltoSRCDIR=srcSRCSUBDIR=$(shell find $(SRCDIR) -type d)mkdir_subdir:    mkdir -p $(patsubst $(SRCDIR)%, $(OUTDIR)%, $(SRCSUBDIR))all: buildbuild: debugdebug: OUTDIR=debugdebug: CFLAGS+= $(DBG_CFLAGS)debug: LDFLAGS+= $(DBG_LDFLAGS)debug: build_targetrelease: OUTDIR=releaserelease: CFLAGS+= $(REL_CFLAGS)release: LDFLAGS+= $(REL_LDFLAGS)release: build_targetbuild_target: mkdir_subdir $(TARGET)$(TARGET): $(OBJ)    $(LD) $^ -o $(OUTDIR)/$@ $(LDFLAGS)%.o: $(SRCDIR)/%.c    $(CC) $< -o $(OUTDIR)/$@ -c $(CFLAGS)

The problematic code is the below part:

%.o: $(SRCDIR)/%.c    $(CC) $< -o $(OUTDIR)/$@ -c $(CFLAGS)

% cannot find the item within subdirectories of SRCDIR(which is src/).

Specifying directory for %.o (ex. src/test/%.o: ...) makes it possible to find only those files within that subdirectory.


Viewing all articles
Browse latest Browse all 22307

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>