1 SRC_LIST
=.
/UdpLibrary.
cpp
2 LIB_DEBUG_DIR
=output
/debug
3 LIB_RELEASE_DIR
=output
/release
4 DEBUG_OBJ_LIST
=$(addprefix $(LIB_DEBUG_DIR
)/, $(notdir $(SRC_LIST
:.
cpp=.o
)))
5 RELEASE_OBJ_LIST
=$(addprefix $(LIB_RELEASE_DIR
)/, $(notdir $(SRC_LIST
:.
cpp=.o
)))
6 DEBUG_OBJ_LIST_C
=$(addprefix $(LIB_DEBUG_DIR
)/, $(notdir $(SRC_LIST_SHARED_C
:.c
=.o
)))
7 RELEASE_OBJ_LIST_C
=$(addprefix $(LIB_RELEASE_DIR
)/, $(notdir $(SRC_LIST_SHARED_C
:.c
=.o
)))
8 LIB_OUTPUT
=libudplibrary.a
10 INCLUDE_FLAGS
=$(addprefix -I
,$(INCLUDE_DIRS
))
13 CFLAGS
= $(INCLUDE_FLAGS
) -DREENTRANT
14 CFLAGS_DEBUG
= $(CFLAGS
) -g
-D_DEBUG
=1 -Wall
-Werror
-Wno-unknown-pragmas
-DREENTRANT
15 CFLAGS_RELEASE
= $(CFLAGS
) -g
-O2
18 DEPENDENCY_LIST
= $(SRC_LIST
:.
cpp=.d
)
24 debug
: $(LIB_DEBUG_DIR
) $(LIB_DEBUG_DIR
)/$(LIB_OUTPUT
)
25 @echo Successfully built
$(LIB_DEBUG_DIR
)/$(LIB_OUTPUT
)
27 release
: $(LIB_RELEASE_DIR
) $(LIB_RELEASE_DIR
)/$(LIB_OUTPUT
)
28 @echo Successfully built
$(LIB_RELEASE_DIR
)/$(LIB_OUTPUT
)
33 $(DEBUG_OBJ_LIST
): $(SRC_LIST
)
34 @echo compiling
$(filter %/$(notdir $(basename $@
)).
cpp,$(SRC_LIST
))
35 @
$(CPP
) $(CFLAGS_DEBUG
) -o
$@
-c
$(filter %/$(notdir $(basename $@
)).
cpp,$(SRC_LIST
))
37 $(DEBUG_OBJ_LIST_C
): $(SRC_LIST_SHARED_C
)
38 @echo compiling
$(filter %/$(notdir $(basename $@
)).c
,$(SRC_LIST_SHARED_C
))
39 $(CC
) $(CFLAGS_DEBUG
) -o
$@
-c
$(filter %/$(notdir $(basename $@
)).c
,$(SRC_LIST_SHARED_C
))
44 $(LIB_DEBUG_DIR
)/$(LIB_OUTPUT
): $(DEBUG_OBJ_LIST
) $(DEBUG_OBJ_LIST_C
) $(LIB_DEBUG_DIR
)
45 @echo linking
$(LIB_DEBUG_DIR
)/$(LIB_OUTPUT
)
46 $(LINK
) $(LINK_FLAGS
) -o
$@
$(DEBUG_OBJ_LIST
) $(DEBUG_OBJ_LIST_C
)
49 $(RELEASE_OBJ_LIST
): $(SRC_LIST
)
50 @echo compiling
$(filter %/$(notdir $(basename $@
)).
cpp,$(SRC_LIST
))
51 @
$(CPP
) $(CFLAGS_RELEASE
) -o
$@
-c
$(filter %/$(notdir $(basename $@
)).
cpp,$(SRC_LIST
))
53 $(RELEASE_OBJ_LIST_C
): $(SRC_LIST_SHARED_C
)
54 @echo compiling
$(filter %/$(notdir $(basename $@
)).c
,$(SRC_LIST_SHARED_C
))
55 @
$(CC
) $(CFLAGS_RELEASE
) -o
$@
-c
$(filter %/$(notdir $(basename $@
)).c
,$(SRC_LIST_SHARED_C
))
60 $(LIB_RELEASE_DIR
)/$(LIB_OUTPUT
): $(RELEASE_OBJ_LIST
) $(RELEASE_OBJ_LIST_C
) $(LIB_RELEASE_DIR
)
61 @echo linking
$(LIB_RELEASE_DIR
)/$(LIB_OUTPUT
)
62 @
$(LINK
) $(LINK_FLAGS
) -o
$@
$(RELEASE_OBJ_LIST
) $(RELEASE_OBJ_LIST_C
)
66 .PHONY
: $(DEPENDENCY_LIST
)
68 depend
: .depend
$(DEPENDENCY_LIST
)
75 @echo Generating dependencies for
$(notdir $(@
:.d
=.
cpp))
76 @echo
-n
$(LIB_DEBUG_DIR
)/ >> .depend
77 @
$(CPP
) -MM
$(addprefix -I
,$(INCLUDE_DIRS
)) $(@
:.d
=.
cpp)>> .depend
78 @echo
-n
$(LIB_RELEASE_DIR
)/ >> .depend
79 @
$(CPP
) -MM
$(addprefix -I
,$(INCLUDE_DIRS
)) $(@
:.d
=.
cpp) >> .depend
82 rm -f
$(LIB_DEBUG_DIR
)/*
83 rm -f
$(LIB_RELEASE_DIR
)/*