[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Re: [PROGRAMMERING] Makefile problem - subst af flere forskellige filformater samtidigt




On Sep 11, 2007, at 10:43 AM, Kim Schulz wrote:



hejsa,

Jeg har en variabel i en makefile ala:

API_SRC +=   somecode.c \
             morecode.cxx \
             foobar.c \
             barbaz.cxx

Jeg har normalt kun haft .c filer men nu er der kommet en flok cxx filer
ind som
der nu ikke bliver laver .o filer ud af.
"problembarnet" er følgende linje:
API_OBJ := $(addprefix $(OBJ_PATH)/,$($(API_SRC:.cxx=.o):.c=.o))


Denne retter kun .c til .o så mine .cxx filer i API_SRC bliver bare sendt
direkte igennem til API_OBJ.


Nogen der har en ide til hvordan jeg kan lave ovenstående så den kan
supportere
både c og cxx filer?


2 Måder:

Du kan dele API_SRC i to variable API_C_SRC og API_CXX_SRC og så bruge
API_OBJ:=$(API_C_SRC:.c=.o) $(API_CXX_SRC:.cxx=.o)

eller du kan bruge den generelle substitueringsfunction i GNU make patsubst:

API_OBJ:=$(patsubst %.c,%.o,$(patsubst %.cxx,%.o,$(API_SRC)))

Man siden til GNU make kan du finde på:

http://www.gnu.org/software/make/manual/make.html

Specielt kapitel 8 er interessant i denne forbindelse.

Mvh

Lars




--
Kim Schulz





 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2007-10-01, 02:01 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *