Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cpp_introduction
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Kiril Klein
cpp_introduction
Commits
cc781f40
Commit
cc781f40
authored
5 years ago
by
Kevin Höllring
Browse files
Options
Downloads
Patches
Plain Diff
Add Makefile to build binaries
parent
ce185270
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
Makefile
+89
-0
89 additions, 0 deletions
Makefile
with
89 additions
and
0 deletions
Makefile
0 → 100644
+
89
−
0
View file @
cc781f40
# Relevant directories
BUILD_DIR
=
./build
TARGET_DIR
=
./bin
SOURCE_DIR
=
./src
INCLUDE_DIR
=
./include
TMP_DIR
=
./tmp
INP_DIR
=
./inputs
OUT_DIR
=
./outputs
# Build parameters
LDFLAGS
=
CFLAGS
=
-Wall
-Werror
-I
$(
INCLUDE_DIR
)
-I
/usr/local/include
-fsanitize
=
address
SAMPLE_CFLAGS
=
-Wall
-I
$(
INCLUDE_DIR
)
-I
/usr/local/include
-fsanitize
=
address
CPPFLAGS
=
-std
=
c++14
CC
=
g++
CPP_SRC_SAMPLES
=
$(
wildcard
$(
SOURCE_DIR
)
/sample_
*
.cpp
)
CPP_OBJ_SAMPLES
=
$(
patsubst
$(
SOURCE_DIR
)
/%.cpp,
$(
BUILD_DIR
)
/%.o,
$(
CPP_SRC_SAMPLES
))
BINARIES_SAMPLES
=
$(
patsubst
$(
SOURCE_DIR
)
/%.cpp,
$(
TARGET_DIR
)
/%,
$(
CPP_SRC_SAMPLES
))
CPP_SRC
=
$(
wildcard
$(
SOURCE_DIR
)
/task_
*
.cpp
)
CPP_OBJ
=
$(
patsubst
$(
SOURCE_DIR
)
/%.cpp,
$(
BUILD_DIR
)
/%.o,
$(
CPP_SRC
))
BINARIES
=
$(
patsubst
$(
SOURCE_DIR
)
/%.cpp,
$(
TARGET_DIR
)
/%,
$(
CPP_SRC
))
.PHONY
:
all
all
:
init build_samples build
@
echo
"done"
# Generating object files from source
$(CPP_OBJ_SAMPLES)
:
$(BUILD_DIR)/%.o : $(SOURCE_DIR)/%.cpp
$(
CC
)
-O3
-g
-c
$<
-o
$@
$(
SAMPLE_CFLAGS
)
$(
CPPFLAGS
)
# Generating object files from source
$(CPP_OBJ)
:
$(BUILD_DIR)/%.o : $(SOURCE_DIR)/%.cpp
$(
CC
)
-O3
-g
-c
$<
-o
$@
$(
CFLAGS
)
$(
CPPFLAGS
)
# Dependency creation
$(CPP_DEP)
:
$(BUILD_DIR)/%.d : $(SOURCE_DIR)/%.cpp
$(
CC
)
-MM
$<
>
$@
$(
CFLAGS
)
$(
CPPFLAGS
)
.PHONY
:
init
init
:
mkdir
-p
$(
BUILD_DIR
)
mkdir
-p
$(
TARGET_DIR
)
.PHONY
:
init_test
init_test
:
init
mkdir
-p
$(
TMP_DIR
)
.PHONY
:
clean
clean
:
rm
-rf
$(
BUILD_DIR
)
/
*
$(
TARGET_DIR
)
/
*
.PHONY
:
test
test
:
init_test test_task1 test_task2 test_task3 test_task4 test_task5
build
:
init $(BINARIES)
build_samples
:
init $(BINARIES_SAMPLES)
$(TARGET_DIR)/%
:
$(BUILD_DIR)/%.o
$(
CC
)
$(
CFLAGS
)
$(
CPPFLAGS
)
-o
$@
$^
$(
LDFLAGS
)
TASK1_EXE
=
$(
TARGET_DIR
)
/task_1
test_task1
:
build
$(
TASK1_EXE
)
<
$(
INP_DIR
)
/task_1_sample.in
>
$(
TMP_DIR
)
/task_1_sample.out
diff
-us
$(
TMP_DIR
)
/task_1_sample.out
$(
OUT_DIR
)
/task_1_sample.out
TASK2_EXE
=
$(
TARGET_DIR
)
/task_2
test_task2
:
build
$(
TASK2_EXE
)
<
$(
INP_DIR
)
/task_2_sample.in
>
$(
TMP_DIR
)
/task_2_sample.out
diff
-us
$(
TMP_DIR
)
/task_2_sample.out
$(
OUT_DIR
)
/task_2_sample.out
TASK3_EXE
=
$(
TARGET_DIR
)
/task_3
test_task3
:
build
$(
TASK3_EXE
)
<
$(
INP_DIR
)
/task_3_sample.in
>
$(
TMP_DIR
)
/task_3_sample.out
diff
-us
$(
TMP_DIR
)
/task_3_sample.out
$(
OUT_DIR
)
/task_3_sample.out
TASK4_EXE
=
$(
TARGET_DIR
)
/task_4
test_task4
:
build
$(
TASK4_EXE
)
<
$(
INP_DIR
)
/task_4_sample.in
>
$(
TMP_DIR
)
/task_4_sample.out
diff
-us
$(
TMP_DIR
)
/task_4_sample.out
$(
OUT_DIR
)
/task_4_sample.out
TASK5_EXE
=
$(
TARGET_DIR
)
/task_5
test_task5
:
build
$(
TASK5_EXE
)
<
$(
INP_DIR
)
/task_5_sample.in
>
$(
TMP_DIR
)
/task_5_sample.out
diff
-us
$(
TMP_DIR
)
/task_5_sample.out
$(
OUT_DIR
)
/task_5_sample.out
.DEFAULT_GOAL
:=
all
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment