Skip to content

Commit

Permalink
Merge pull request TheNetAdmin#8 from sirh3e/master
Browse files Browse the repository at this point in the history
Fixed naming
  • Loading branch information
TheNetAdmin authored Oct 28, 2020
2 parents 2749961 + 741e9a2 commit 6c94979
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 41 deletions.
10 changes: 5 additions & 5 deletions MediumProject/Example/Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# target marcros
# target marcos
TARGET := medium.exe
MAIN_SRC := main.cpp

# compile marcros
# compile marcos
DIRS := src1 src2 src3
OBJS :=

# intermedia compile marcros
# intermedia compile marcos
ALL_OBJS :=
CLEAN_FILES := $(TARGET) $(OBJS)
DIST_CLEAN_FILES := $(OBJS)
Expand All @@ -19,8 +19,8 @@ default: show-info all

# non-phony targets
$(TARGET): build-subdirs $(OBJS) find-all-objs
@echo -e "\t" CC $(CCFLAG) $(ALL_OBJS) $(MAIN_SRC) -o $@
@$(CC) $(CCFLAG) $(ALL_OBJS) $(MAIN_SRC) -o $@
@echo -e "\t" CC $(CCFLAGS) $(ALL_OBJS) $(MAIN_SRC) -o $@
@$(CC) $(CCFLAGS) $(ALL_OBJS) $(MAIN_SRC) -o $@

# phony targets
.PHONY: all
Expand Down
14 changes: 7 additions & 7 deletions MediumProject/Example/config/make.global
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,30 @@
export MAKE := "C:/PROGRA~1/IMAGIN~1/INTERN~1/msys/bin/make.exe"

# make flag
MAKEFLAG := -s --no-print-directory
MAKEFLAGS := -s --no-print-directory

# compile macro
CC := g++

# compile flags
CCFLAG :=
OBJCCFLAG := $(CCFLAG) -c
CCFLAGS :=
OBJCCFLAGS := $(CCFLAGS) -c

# recursive make and clean
.PHONY: build-subdirs
build-subdirs: $(DIRS)

.PHONY: $(DIRS)
$(DIRS):
@$(MAKE) $(MAKEFLAG) -C $@ all
@$(MAKE) $(MAKEFLAGS) -C $@ all

.PHONY: clean-subdirs
clean-subdirs:
@for dir in $(DIRS); do \
$(MAKE) $(MAKEFLAG) -C $$dir clean; \
$(MAKE) $(MAKEFLAGS) -C $$dir clean; \
done

# dependencies
%.o: %.c*
@echo -e "\t" CC $(OBJCCFLAG) $< -o $@
@$(CC) $(OBJCCFLAG) $< -o $@
@echo -e "\t" CC $(OBJCCFLAGS) $< -o $@
@$(CC) $(OBJCCFLAGS) $< -o $@
6 changes: 3 additions & 3 deletions MediumProject/Template/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ MAIN_SRC := # FILL: src file which contains `main()`
DIRS := src # FILL: only the dirs which contain the src files, in this case, `src` should be added
OBJS := # FILL: only the objects in current dir, and do not include the one contains `main()`

# intermedia compile marcros
# intermedia compile marcos
# NOTE: ALL_OBJS are intentionally left blank, no need to fill it
ALL_OBJS :=
CLEAN_FILES := $(TARGET) $(OBJS)
Expand All @@ -20,8 +20,8 @@ default: show-info all

# non-phony targets
$(TARGET): build-subdirs $(OBJS) find-all-objs
@echo -e "\t" CC $(CCFLAG) $(ALL_OBJS) $(MAIN_SRC) -o $@
@$(CC) $(CCFLAG) $(ALL_OBJS) $(MAIN_SRC) -o $@
@echo -e "\t" CC $(CCFLAGS) $(ALL_OBJS) $(MAIN_SRC) -o $@
@$(CC) $(CCFLAGS) $(ALL_OBJS) $(MAIN_SRC) -o $@

# phony targets
.PHONY: all
Expand Down
16 changes: 8 additions & 8 deletions MediumProject/Template/config/make.global
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,30 @@
export MAKE := # FILL: make path, may needed under Windows

# make flag
MAKEFLAG := -s --no-print-directory
MAKEFLAGS := -s --no-print-directory

# compile marcro
# compile marco
CC := # FILL: compiler

# compile flags
CCFLAG :=
OBJCCFLAG := $(CCFLAG) -c
CCFLAGS :=
OBJCCFLAGS := $(CCFLAGS) -c

# recursive make and clean
.PHONY: build-subdirs
build-subdirs: $(DIRS)

.PHONY: $(DIRS)
$(DIRS):
@$(MAKE) $(MAKEFLAG) -C $@ all
@$(MAKE) $(MAKEFLAGS) -C $@ all

.PHONY: clean-subdirs
clean-subdirs:
@for dir in $(DIRS); do \
$(MAKE) $(MAKEFLAG) -C $$dir clean; \
$(MAKE) $(MAKEFLAGS) -C $$dir clean; \
done

# dependencies
%.o: %.c*
@echo -e "\t" CC $(OBJCCFLAG) $< -o $@
@$(CC) $(OBJCCFLAG) $< -o $@
@echo -e "\t" CC $(OBJCCFLAGS) $< -o $@
@$(CC) $(OBJCCFLAGS) $< -o $@
20 changes: 10 additions & 10 deletions SmallProject/Example/Makefile
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# tool marcros
# tool marcos
CC := g++
CCFLAG :=
DBGFLAG := -g
CCOBJFLAG := $(CCFLAG) -c
CCFLAGS :=
DBGFLAGS := -g
CCOBJFLAGS := $(CCFLAGS) -c

# path marcros
# path marcos
BIN_PATH := bin
OBJ_PATH := obj
SRC_PATH := src
DBG_PATH := debug

# compile marcros
# compile marcos
TARGET_NAME := main
ifeq ($(OS),Windows_NT)
TARGET_NAME := $(addsuffix .exe,$(TARGET_NAME))
Expand All @@ -35,16 +35,16 @@ default: makedir all

# non-phony targets
$(TARGET): $(OBJ)
$(CC) $(CCFLAG) -o $@ $(OBJ)
$(CC) $(CCFLAGS) -o $@ $(OBJ)

$(OBJ_PATH)/%.o: $(SRC_PATH)/%.c*
$(CC) $(CCOBJFLAG) -o $@ $<
$(CC) $(CCOBJFLAGS) -o $@ $<

$(DBG_PATH)/%.o: $(SRC_PATH)/%.c*
$(CC) $(CCOBJFLAG) $(DBGFLAG) -o $@ $<
$(CC) $(CCOBJFLAGS) $(DBGFLAGS) -o $@ $<

$(TARGET_DEBUG): $(OBJ_DEBUG)
$(CC) $(CCFLAG) $(DBGFLAG) $(OBJ_DEBUG) -o $@
$(CC) $(CCFLAGS) $(DBGFLAGS) $(OBJ_DEBUG) -o $@

# phony rules
.PHONY: makedir
Expand Down
2 changes: 1 addition & 1 deletion SmallProject/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ If any of the `OBJ`'s object is out-dated, it will be re-generated and futher, t

1. Shall I put src files in sub-dirs of `SRC_PATH`?
1. Basically, YES. You could put some srcs in such sub-dirs, and add some new rules to the Makefile.
1. BUT, I do NOT recomment you to do this. Consider we have two srcs, *src/sub1/src1.c*, *src/sub2/src1.c*. They would not conflict when we write the code. But remember ALL the objects will be output tot `OBJ_PATH`, when compiling, they will conflict, and the linker will be confused.
1. BUT, I do NOT recommend you to do this. Consider we have two srcs, *src/sub1/src1.c*, *src/sub2/src1.c*. They would not conflict when we write the code. But remember ALL the objects will be output tot `OBJ_PATH`, when compiling, they will conflict, and the linker will be confused.
1. So, what if I really need to do so? Consider using the Template **MediumProject** we provided.
1. Why putting all objects into one dir?
1. Since the project is a SMALL project, doing so will reduce the complexity of folder structure, and make it easier to clean these files.
Expand Down
14 changes: 7 additions & 7 deletions SmallProject/Template/Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# tool macros
CC := # FILL: the compiler
CCFLAG := # FILL: compile flags
DBGFLAG := -g
CCOBJFLAG := $(CCFLAG) -c
CCFLAGS := # FILL: compile flags
DBGFLAGS := -g
CCOBJFLAGS := $(CCFLAGS) -c

# path macros
BIN_PATH := bin
Expand Down Expand Up @@ -35,16 +35,16 @@ default: makedir all

# non-phony targets
$(TARGET): $(OBJ)
$(CC) $(CCFLAG) -o $@ $(OBJ)
$(CC) $(CCFLAGS) -o $@ $(OBJ)

$(OBJ_PATH)/%.o: $(SRC_PATH)/%.c*
$(CC) $(CCOBJFLAG) -o $@ $<
$(CC) $(CCOBJFLAGS) -o $@ $<

$(DBG_PATH)/%.o: $(SRC_PATH)/%.c*
$(CC) $(CCOBJFLAG) $(DBGFLAG) -o $@ $<
$(CC) $(CCOBJFLAGS) $(DBGFLAGS) -o $@ $<

$(TARGET_DEBUG): $(OBJ_DEBUG)
$(CC) $(CCFLAG) $(DBGFLAG) $(OBJ_DEBUG) -o $@
$(CC) $(CCFLAGS) $(DBGFLAGS) $(OBJ_DEBUG) -o $@

# phony rules
.PHONY: makedir
Expand Down

0 comments on commit 6c94979

Please sign in to comment.