Skip to content

Commit

Permalink
T-8 : Initial Makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
zaya-mc committed Apr 22, 2020
1 parent b7fe069 commit b88f835
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,6 @@ modules.order
Module.symvers
Mkfile.old
dkms.conf

# Project specific
out/
5 changes: 5 additions & 0 deletions Include/test.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/**
* @brief A test header
*/

void testFunction(void);
23 changes: 23 additions & 0 deletions Source/test.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@

/**
* @brief a test source file
*/

#include "test.h"

#include <stdio.h>

#ifndef TEST_CONFIG
#error "TEST_CONFIG is not defined"
#endif /* TEST_DEFINE */

void testFunction(void)
{
printf("\r\nHello World!");
printf("\r\nTest Config Value : %d\r\n", TEST_CONFIG);
}

int main(void)
{
testFunction();
}
67 changes: 67 additions & 0 deletions makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#
# The root makefile
#

OUTPUT_PATH=out
OUTPUT_NAME=test

# The cross compile if exists, otherwise uses the gcc
CROSS_COMPILE?=

#
# Source (.c) Files
#
SOURCE_FILES= \
Source/test.c

#
# Header (.h) File Directories
#
# Bear in mind, include directories must have -I prefix
#
INCLUDE_DIRECTORIES= \
-IInclude/

#
# Project Definitions
#
# Bear in mind, definitions must have -D prefix
#
DEFINES= \
-DTEST_CONFIG=255

#
# All Flags
#
CFLAGS=${INCLUDE_DIRECTORIES} ${DEFINES}


#############################################
# Rules
#############################################


#
# The main rule
#
all: out test

# Rebuild
rebuild: clean all

# The test rule
test:
${CROSS_COMPILE}gcc -g ${SOURCE_FILES} ${CFLAGS} -o ${OUTPUT_PATH}/${OUTPUT_NAME}

# The clean rule
clean:
rm -f test

# The rule to create out path
out:
mkdir -p ${OUTPUT_PATH}

# The rule to run the output executable
run:
./${OUTPUT_PATH}/${OUTPUT_NAME}

0 comments on commit b88f835

Please sign in to comment.