Last active
June 21, 2024 05:16
-
-
Save basharam/9511906 to your computer and use it in GitHub Desktop.
Makefile template for Static library.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Makefile template for Static library. | |
# 1. Compile every *.cpp in the folder | |
# 2. All obj files under obj folder | |
# 3. static library .a at lib folder | |
# 4. run 'make dirmake' before calling 'make' | |
CC = g++ | |
OUT_FILE_NAME = libNAME.a | |
CFLAGS= -fPIC -O0 -g -Wall -c -fpermissive | |
INC = -I../Import | |
OBJ_DIR=./obj | |
OUT_DIR=./lib | |
# Enumerating of every *.cpp as *.o and using that as dependency. | |
# filter list of .c files in a directory. | |
# FILES =dump_l.c \ | |
# kter.c \ | |
# | |
# $(OUT_FILE_NAME): $(patsubst %.c,$(OBJ_DIR)/%.o,$(wildcard $(FILES))) | |
# Enumerating of every *.cpp as *.o and using that as dependency | |
$(OUT_FILE_NAME): $(patsubst %.cpp,$(OBJ_DIR)/%.o,$(wildcard *.cpp)) | |
ar -r -o $(OUT_DIR)/$@ $^ | |
#Compiling every *.cpp to *.o | |
$(OBJ_DIR)/%.o: %.cpp dirmake | |
$(CC) -c $(INC) $(CFLAGS) -o $@ $< | |
dirmake: | |
@mkdir -p $(OUT_DIR) | |
@mkdir -p $(OBJ_DIR) | |
clean: | |
rm -f $(OBJ_DIR)/*.o $(OUT_DIR)/$(OUT_FILE_NAME) Makefile.bak | |
rebuild: clean build | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment