Proper makefile
This commit is contained in:
		
							parent
							
								
									4052f9712d
								
							
						
					
					
						commit
						12d5c26124
					
				
					 1 changed files with 41 additions and 0 deletions
				
			
		
							
								
								
									
										41
									
								
								Makefile
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										41
									
								
								Makefile
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,41 @@ | |||
| # Compiler
 | ||||
| CC := gcc | ||||
| 
 | ||||
| # Compiler flags
 | ||||
| CFLAGS := -Wall -Wextra -Wpedantic | ||||
| 
 | ||||
| # Directories
 | ||||
| SRC_DIR := src | ||||
| BUILD_DIR := build | ||||
| 
 | ||||
| # Source files
 | ||||
| SRCS := $(wildcard $(SRC_DIR)/*.c) | ||||
| 
 | ||||
| # Object files
 | ||||
| OBJS := $(patsubst $(SRC_DIR)/%.c,$(BUILD_DIR)/%.o,$(SRCS)) | ||||
| 
 | ||||
| # Target executable
 | ||||
| TARGET := CTree | ||||
| 
 | ||||
| # Default target
 | ||||
| all: $(TARGET) | ||||
| 
 | ||||
| # Rule to build the target executable
 | ||||
| $(TARGET): $(OBJS) | ||||
| 	$(CC) $(CFLAGS) $^ -o $@ | ||||
| 
 | ||||
| # Rule to build object files
 | ||||
| $(BUILD_DIR)/%.o: $(SRC_DIR)/%.c | ||||
| 	@mkdir -p $(BUILD_DIR) | ||||
| 	$(CC) $(CFLAGS) -c $< -o $@ | ||||
| 
 | ||||
| # Run rule
 | ||||
| run: $(TARGET) | ||||
| 	./$(TARGET) | ||||
| 
 | ||||
| # Clean rule
 | ||||
| clean: | ||||
| 	rm -rf $(BUILD_DIR) $(TARGET) | ||||
| 
 | ||||
| # Mark rules as phony
 | ||||
| .PHONY: all run clean | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Imbus
						Imbus