“makefile” Réponses codées

makefile

.PHONY: all, install, clean  
   
 TARGET=sum  
   
 HDRS+= sum.h  
 CSRCS+= main.c sum.c  
 CPPSRCS+=  
   
 OBJSDIR=./build  
 OBJS:= $(patsubst %.cpp, $(OBJSDIR)/%.o, $(CPPSRCS))  
 OBJS+= $(patsubst %.c, $(OBJSDIR)/%.o, $(CSRCS))  
   
 CFLAGS += -I./include -DDEBUG -Wall -g  
 LDFLAGS += -L./lib -lm  
   
 CC:= gcc  
 CXX:= g++  
   
 all: ${TARGET}  
 ${TARGET} : $(OBJS)  
      @echo " [LINK] $@"  
      @mkdir -p $(shell dirname $@)  
      @$(CXX) $(OBJS) -o $@ $(LDFLAGS)  
        
 $(OBJSDIR)/%.o: %.c $(HDRS)  
      @echo " [CC]  $@"  
      @mkdir -p $(shell dirname $@)  
      @$(CC) -c $< -o $@ $(CFLAGS)  
   
 $(OBJSDIR)/%.o: %.cpp $(HDRS)  
      @echo " [CXX] $@"  
      @mkdir -p $(shell dirname $@)  
      @$(CXX) -c $< -o $@ $(CFLAGS)  

 install:
      cp -rf ${TARGET} /usr/local/bin   
    
 clean:  
      rm -rf ${OBJSDIR}/*.o  
      rm -rf ${TARGET}
Sparkling Squirrel

makefile

blah: blah.o
	cc blah.o -o blah # Runs third

blah.o: blah.c
	cc -c blah.c -o blah.o # Runs second

blah.c:
	echo "int main() { return 0; }" > blah.c # Runs first
Hungry Hippopotamus

Réponses similaires à “makefile”

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code