2022-12-04 18:54:57 +01:00
# This is part of WHY2
# Copyright (C) 2022 Václav Šmejkal
# 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 <https://www.gnu.org/licenses/>.
2022-05-20 19:06:26 +02:00
# Compiler Settings
CC = cc
2023-01-27 14:26:37 +01:00
CFLAGS = -Wall -Wextra -Werror -Wcomment -Wformat -Wformat-security -Wmain -Wnonnull -Wunused -std= gnu11 -O2 -g # Remove the '-g' flag if you want the smallest possible lib size
2022-05-20 19:06:26 +02:00
2023-01-06 15:20:39 +01:00
# Output Files
PROJECT_NAME = why2
OUTPUT = out
LOGS = logs
OUTPUT_TEST_CORE = $( OUTPUT) /$( PROJECT_NAME) -core-test
2023-02-08 14:38:20 +01:00
OUTPUT_APP_CORE = $( OUTPUT) /$( PROJECT_NAME) -core-app
2023-01-06 15:20:39 +01:00
OUTPUT_TEST_LOGGER = $( OUTPUT) /$( PROJECT_NAME) -logger-test
2023-02-08 14:38:50 +01:00
OUTPUT_APP_LOGGER = $( OUTPUT) /$( PROJECT_NAME) -logger-app
2023-01-06 15:20:39 +01:00
2023-02-09 09:13:57 +01:00
OUTPUT_CHAT_CLIENT = $( OUTPUT) /$( PROJECT_NAME) -chat-client
2023-02-09 09:15:57 +01:00
OUTPUT_CHAT_SERVER = $( OUTPUT) /$( PROJECT_NAME) -chat-server
2023-02-09 09:13:57 +01:00
2022-05-20 19:06:26 +02:00
# Source Code
2023-01-29 19:46:16 +01:00
SRC_CORE = ./src/core/lib/*.c ./src/core/lib/utils/*.c
2022-11-18 16:10:20 +01:00
SRC_CORE_APP = ./src/core/app/*.c
2022-11-18 16:30:55 +01:00
SRC_LOGGER = ./src/logger/lib/*.c
2023-02-08 14:38:50 +01:00
SRC_LOGGER_APP = ./src/logger/app/*.c
2023-02-09 09:13:57 +01:00
SRC_CHAT_CLIENT = ./src/chat/client/*.c
2023-02-09 09:15:57 +01:00
SRC_CHAT_SERVER = ./src/chat/server/*.c
2022-11-18 16:20:01 +01:00
2022-11-17 14:04:03 +01:00
INCLUDE_DIR = ./include
2022-11-18 16:16:11 +01:00
INCLUDE_CORE = $( INCLUDE_DIR) /*.h
2022-11-18 16:20:01 +01:00
INCLUDE_LOGGER = $( INCLUDE_DIR) /logger/*.h
2022-11-18 16:28:57 +01:00
TEST_CORE = ./src/core/lib/test/main.c
2022-11-18 16:26:56 +01:00
LIBS_CORE = -ljson-c -lcurl -lgit2
2023-02-08 14:41:48 +01:00
LIB_CORE = -l$( PROJECT_NAME)
2022-05-20 19:06:26 +02:00
2022-11-18 17:43:53 +01:00
TEST_LOGGER = ./src/logger/lib/test/main.c
2023-02-08 09:45:39 +01:00
LIBS_LOGGER = $( LIB_CORE)
2023-02-08 14:41:48 +01:00
LIB_LOGGER = -l$( PROJECT_NAME) -logger
2022-11-18 17:41:20 +01:00
2023-02-09 17:18:15 +01:00
LIBS_CHAT = $( LIB_CORE) -lpthread
2022-05-20 19:06:26 +02:00
# Install Files
INSTALL_INCLUDE = /usr/include
INSTALL_LIBRARY = /usr/lib
INSTALL_BIN = /usr/bin
# Misc
DOLLAR = $
##########
2022-06-28 17:45:39 +02:00
noTarget : # Do not use this, please <3
@echo Hey you... You have to enter your target, too. Use \' install\' target for installing $( PROJECT_NAME) -core.
2022-11-18 16:19:21 +01:00
installHeaderCore :
2022-11-18 16:16:11 +01:00
for file in $( INCLUDE_CORE) ; do install -m 755 -D $( DOLLAR) file -t $( INSTALL_INCLUDE) /$( PROJECT_NAME) ; done
2022-11-18 13:03:50 +01:00
ln -sf $( INSTALL_INCLUDE) /$( PROJECT_NAME) /$( PROJECT_NAME) .h $( INSTALL_INCLUDE) /$( PROJECT_NAME) .h
2022-06-11 16:30:19 +02:00
2022-11-18 16:23:23 +01:00
installHeaderLogger :
for file in $( INCLUDE_LOGGER) ; do install -m 755 -D $( DOLLAR) file -t $( INSTALL_INCLUDE) /$( PROJECT_NAME) /logger; done
2022-11-18 16:24:47 +01:00
buildLibCore :
2022-11-18 17:24:30 +01:00
$( MAKE) clean
2022-11-18 16:10:20 +01:00
$( CC) $( CFLAGS) -fPIC -c $( SRC_CORE)
2022-11-18 16:26:56 +01:00
$( CC) $( CFLAGS) -shared -o lib$( PROJECT_NAME) .so *.o $( LIBS_CORE)
2022-11-18 16:01:41 +01:00
2022-11-18 16:33:07 +01:00
buildLibLogger :
2022-11-18 17:24:30 +01:00
$( MAKE) clean
2022-11-18 16:33:07 +01:00
$( CC) $( CFLAGS) -fPIC -c $( SRC_LOGGER)
$( CC) $( CFLAGS) -shared -o lib$( PROJECT_NAME) -logger.so *.o $( LIBS_LOGGER)
2023-02-09 09:13:57 +01:00
buildChatClient :
2023-02-09 17:18:15 +01:00
$( CC) $( CFLAGS) $( SRC_CHAT_CLIENT) -o $( OUTPUT_CHAT_CLIENT) $( LIBS_CHAT)
2023-02-09 09:13:57 +01:00
2023-02-09 09:15:57 +01:00
buildChatServer :
2023-02-09 17:18:15 +01:00
$( CC) $( CFLAGS) $( SRC_CHAT_SERVER) -o $( OUTPUT_CHAT_SERVER) $( LIBS_CHAT)
2023-02-09 09:15:57 +01:00
2022-11-18 16:25:17 +01:00
installLibCore : buildLibCore
2022-11-17 14:04:03 +01:00
install -m 755 ./lib$( PROJECT_NAME) .so $( INSTALL_LIBRARY) /lib$( PROJECT_NAME) .so
2022-06-01 17:40:52 +02:00
2023-02-08 14:22:01 +01:00
installAppCore : appCore
2023-02-08 14:24:07 +01:00
install -m 755 $( OUTPUT_APP_CORE) $( INSTALL_BIN) /$( PROJECT_NAME)
2022-05-20 19:06:26 +02:00
2022-11-18 16:34:10 +01:00
installLibLogger : buildLibLogger
install -m 755 ./lib$( PROJECT_NAME) -logger.so $( INSTALL_LIBRARY) /lib$( PROJECT_NAME) -logger.so
2023-02-08 18:45:06 +01:00
installAppLogger : appLogger
install -m 755 $( OUTPUT_APP_LOGGER) $( INSTALL_BIN) /$( PROJECT_NAME) -logger
2022-11-18 16:40:25 +01:00
testCore :
2023-01-27 14:26:37 +01:00
$( CC) $( CFLAGS) $( TEST_CORE) -o $( OUTPUT_TEST_CORE) $( LIB_CORE)
2022-05-20 19:06:26 +02:00
2022-11-18 17:43:26 +01:00
testLogger :
2023-02-08 18:51:10 +01:00
$( CC) $( CFLAGS) $( TEST_LOGGER) -o $( OUTPUT_TEST_LOGGER) $( LIBS_LOGGER) $( LIB_LOGGER)
2022-11-18 17:43:26 +01:00
2023-02-08 14:22:01 +01:00
appCore :
2023-02-08 14:24:07 +01:00
$( CC) $( CFLAGS) $( SRC_CORE_APP) -o $( OUTPUT_APP_CORE) $( LIB_CORE)
2022-05-20 19:06:26 +02:00
2023-02-08 14:38:50 +01:00
appLogger :
2023-02-08 18:51:10 +01:00
$( CC) $( CFLAGS) $( SRC_LOGGER_APP) -o $( OUTPUT_APP_LOGGER) $( LIBS_LOGGER) $( LIB_LOGGER)
2023-02-08 14:38:50 +01:00
2022-05-20 19:06:26 +02:00
clean :
2023-01-06 15:25:57 +01:00
rm -rf $( OUTPUT) /* $( LOGS) /* *.o *.so vgcore.*
2022-06-01 17:32:27 +02:00
2022-11-18 16:23:46 +01:00
installHeader : installHeaderCore installHeaderLogger
2023-02-08 18:43:16 +01:00
installLibs : installLibCore installLibLogger
2023-02-08 18:45:06 +01:00
installApps : installAppCore installAppLogger
2023-02-08 18:43:16 +01:00
install : installHeader installLibs installApps clean
2022-11-18 17:45:18 +01:00
installTest : install testCore testLogger
2022-07-29 17:33:37 +02:00
all : install