Makefile update

This commit is contained in:
2024-11-16 11:57:48 +05:30
parent 92742e091b
commit 4e298d6f2b
2 changed files with 18 additions and 2 deletions

View File

@@ -1,3 +1,5 @@
#make "rule" -f "makefile name"
#############GUIDE LIST########################################## #############GUIDE LIST##########################################
# G1. CC: # # G1. CC: #
# Flag to mention the C compiler to used. # # Flag to mention the C compiler to used. #
@@ -48,7 +50,8 @@
#Flags #Flags
# C program # C program
CC = gcc CC = gcc
CFLAGS = -g INCDIRS = -I./include
CFLAGS = -g $(INCDIRS)
OUTPUT_OPTION = -MMD -MP -o $@ OUTPUT_OPTION = -MMD -MP -o $@
SHARED_LIBRARY_EXTENSION = so SHARED_LIBRARY_EXTENSION = so
SHARED_LIBRARY_FLAG = -shared SHARED_LIBRARY_FLAG = -shared
@@ -88,6 +91,18 @@ ${EXE_NAME}: ${OBJS}
${CC} ${OJBS} -o ${EXE_NAME} ${CC} ${OJBS} -o ${EXE_NAME}
#regular expression where % is a wildcard
%.o: %.c
$(CC) $(CFLAGS) -c $^ -o $@
#OR
%.o: %.c
$(CC) $(CFLAGS) -c -o $@ $^
##G12. ##G12.
#####SOURCE FILE DEPENDENT ON HEADER FILE################ #####SOURCE FILE DEPENDENT ON HEADER FILE################
# "src or obj file": "header file" # # "src or obj file": "header file" #
@@ -131,8 +146,9 @@ ${LIB}.${SHARED_LIBRARY_EXTENSION}: ${OBJS}
##G14. ##G14.
###MEANING OF $@ AND $^ SYMBOLS ON ABOVE RULE#################### ###MEANING OF $@ AND $^ SYMBOLS ON ABOVE RULE####################
# $@ -> Replacing itself with rule under which # # $@ -> Replacing itself with rule under which #
# its written. # # its written. (Left side of rule) #
# $^ -> Replacing itself with dependencies of rule. # # $^ -> Replacing itself with dependencies of rule. #
# (Right side of rule) #
################################################################# #################################################################

View File