2018-03-14 18:02:54 +00:00
|
|
|
# Copyright (C) 2018 Ortega Froysa, Nicolás <nortega@themusicinnoise.net>
|
|
|
|
# Author: Ortega Froysa, Nicolás <nortega@themusicinnoise.net>
|
|
|
|
#
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
cmake_minimum_required(VERSION 2.8)
|
2018-03-14 20:44:41 +00:00
|
|
|
project(colonel C ASM)
|
2018-03-14 18:02:54 +00:00
|
|
|
|
|
|
|
set(TARGET_NAME "colonel.bin")
|
|
|
|
|
|
|
|
if(NOT CMAKE_BUILD_TYPE)
|
|
|
|
set(CMAKE_BUILD_TYPE "release")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
string(TOLOWER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE)
|
|
|
|
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
|
|
|
|
|
|
|
|
# flags
|
2018-03-14 20:44:41 +00:00
|
|
|
set(CMAKE_C_FLAGS "-std=c99 -ffreestanding -fno-builtin -Wall -Wextra")
|
2018-03-14 18:02:54 +00:00
|
|
|
set(CMAKE_C_FLAGS_DEBUG "-g -O0")
|
|
|
|
set(CMAKE_C_FLAGS_RELEASE "-O3")
|
2018-03-14 20:44:41 +00:00
|
|
|
set(CMAKE_ASM_FLAGS "")
|
2018-03-14 21:18:19 +00:00
|
|
|
set(CMAKE_ASM_FLAGS_DEBUG "")
|
2018-03-14 20:44:41 +00:00
|
|
|
set(CMAKE_ASM_FLAGS_RELEASE "")
|
2018-03-14 18:02:54 +00:00
|
|
|
|
|
|
|
include_directories(
|
|
|
|
"src/")
|
|
|
|
|
|
|
|
# source files
|
|
|
|
set(SRCS
|
|
|
|
src/kernel/kernel.c)
|
|
|
|
|
|
|
|
# architecture specific code
|
|
|
|
if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "i.86")
|
|
|
|
set(SRCS
|
|
|
|
src/kernel/arch/x86/boot.s
|
|
|
|
${SRCS}
|
|
|
|
src/kernel/arch/x86/tty.c)
|
2018-03-14 20:44:41 +00:00
|
|
|
set(CMAKE_EXE_LINKER_FLAGS
|
|
|
|
"-T ${CMAKE_CURRENT_SOURCE_DIR}/src/kernel/arch/x86/linker.ld -ffreestanding -nostdlib")
|
|
|
|
include_directories(
|
|
|
|
"src/kernel/arch/x86/")
|
2018-03-14 18:02:54 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
add_executable(${TARGET_NAME} ${SRCS})
|
2018-03-14 21:39:49 +00:00
|
|
|
|
|
|
|
add_custom_target(build-iso
|
|
|
|
COMMAND mkdir -p isodir/boot/grub/
|
|
|
|
COMMAND cp ${CMAKE_CURRENT_SOURCE_DIR}/configs/grub.cfg isodir/boot/grub/
|
|
|
|
COMMAND cp ${TARGET_NAME} isodir/boot/
|
|
|
|
COMMAND grub-mkrescue -o colonel.iso isodir
|
|
|
|
DEPENDS ${TARGET_NAME}
|
|
|
|
COMMENT "Building ISO iamge..."
|
|
|
|
SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/configs/grub.cfg)
|