Skip to content

Commit

Permalink
Use MyMakefile v2-rc
Browse files Browse the repository at this point in the history
  • Loading branch information
Lecrapouille committed May 28, 2024
1 parent e4af943 commit e39f461
Show file tree
Hide file tree
Showing 21 changed files with 330 additions and 390 deletions.
2 changes: 1 addition & 1 deletion .makefile
163 changes: 53 additions & 110 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
##=====================================================================
## TimedPetriNetEditor: A timed Petri net editor.
## Copyright 2021 -- 2023 Quentin Quadrat <lecrapouille@gmail.com>
##
## This file is part of PetriEditor.
##
## PetriEditor 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 GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
##=====================================================================

###################################################
# Location of the project directory and Makefiles
#
Expand All @@ -8,93 +28,63 @@ M := $(P)/.makefile
# Project definition
#
include $(P)/Makefile.common
TARGET = $(PROJECT)
DESCRIPTION = Timed Petri Net Editor
TARGET_NAME := $(PROJECT_NAME)
TARGET_DESCRIPTION := Timed Petri Net Editor
include $(M)/project/Makefile

###################################################
# Sharable informations between all Makefiles
# Standalone application
#
include $(M)/Makefile.header
SRC_FILES := src/main.cpp
INCLUDES := $(P)/include
VPATH := $(P)/src
LINKER_FLAGS += -ldl -lpthread
# Internal libs to compile
LIB_TPNE_NET := TimedPetriNet
LIB_TPNE_EDITOR := TimedPetriEditor
LIB_TPNE_JULIA := TimedPetriJulia
INTERNAL_LIBS := $(LIB_TPNE_EDITOR) $(LIB_TPNE_NET) $(LIB_TPNE_JULIA)
DIRS_WITH_MAKEFILE := $(P)/src/Net $(P)/src/Editor $(P)/src/julia

###################################################
# OpenGL: glfw and glew libraries
# GUI
#
ifeq ($(ARCHI),Darwin)
INCLUDES += -I/usr/local/include -I/opt/local/include
LINKER_FLAGS += -framework OpenGL -framework Cocoa
LINKER_FLAGS += -framework IOKit -framework CoreVideo
LINKER_FLAGS += -L/usr/local/lib -L/opt/local/lib
LINKER_FLAGS += -lGLEW -lglfw
else ifeq ($(ARCHI),Linux)
LINKER_FLAGS += -lGL
PKG_LIBS += --static glfw3
else ifeq ($(ARCHI),Emscripten)
ifneq ($(EXAEQUOS),)
LINKER_FLAGS += -sMIN_WEBGL_VERSION=2 -sMAX_WEBGL_VERSION=2 -sFULL_ES3
PKG_LIBS += exa-wayland --static glfw
endif
else
$(error Unknown architecture $(ARCHI) for OpenGL)
endif
include $(abspath $(P)/src/Editor/DearImGui/Backends/Makefile)
INCLUDES += $(P)/src/Editor/DearImGui
INCLUDES += $(P)/src

###################################################
# Embed assets for web version. Assets shall be
# present inside $(BUILD) folder.
#
ifeq ($(ARCHI),Emscripten)
ifeq ($(EXAEQUOS),)
LINKER_FLAGS += --preload-file examples
LINKER_FLAGS += --preload-file data
LINKER_FLAGS += -s FORCE_FILESYSTEM=1
endif
endif

###################################################
# Create a MacOS X bundle application.
#
ifeq ($(ARCHI),Darwin)
BUILD_MACOS_APP_BUNDLE = 1
APPLE_IDENTIFIER = lecrapouille
MACOS_BUNDLE_ICON = data/TimedPetriNetEditor.icns
LINKER_FLAGS += -framework CoreFoundation
ifeq ($(OS),Emscripten)
ifndef EXAEQUOS
LINKER_FLAGS += --preload-file $(PROJECT_DATA_DIR)
LINKER_FLAGS += -s FORCE_FILESYSTEM=1
endif
endif

###################################################
# Stand-alone application.
# Generic Makefile rules
#
include $(P)/src/Editor/DearImGui/Makefile.imgui
LINKER_FLAGS += -ldl -lpthread
VPATH += $(P)/include $(P)/src $(P)/src/Utils $(P)/src/Net
VPATH += $(P)/src/Net/Imports VPATH += $(P)/src/Net/Exports
INCLUDES += -I$(P)/include -I$(P)/src -I$(P)/external
OBJS += main.o
include $(M)/rules/Makefile

###################################################
# Compile the stand-alone application
.PHONY: all
all: $(TARGET) copy-emscripten-assets

###################################################
# Internal libraries
# Compile internal librairies in the correct order
#
LIB_TPNE_CORE = $(abspath $(P)/$(BUILD)/libtimedpetrinetcore.a)
LIB_TPNE_GUI = $(abspath $(P)/$(BUILD)/libtimedpetrinetgui.a)
LIB_TPNE_JULIA = $(abspath $(P)/$(BUILD)/libtimedpetrinetjulia.a)
THIRDPART_LIBS += $(LIB_TPNE_CORE) $(LIB_TPNE_GUI) $(LIB_TPNE_JULIA)
DIRS_WITH_MAKEFILE := src/Editor src/Net src/julia
$(LIB_TPNE_NET): $(P)/src/Net

$(LIB_TPNE_GUI): src/Editor
$(LIB_TPNE_EDITOR): $(P)/src/Editor

$(LIB_TPNE_CORE): src/Net
$(LIB_TPNE_JULIA): $(P)/src/julia

$(LIB_TPNE_JULIA): src/julia
$(P)/src/julia: $(P)/src/Editor

src/julia: src/Editor

src/Editor: src/Net
$(P)/src/Editor: $(P)/src/Net

###################################################
# Copy data inside BUILD to allow emscripten to embedded them
#
.PHONY: copy-assets
copy-emscripten-assets: | $(BUILD)
ifeq ($(ARCHI),Emscripten)
Expand All @@ -104,51 +94,4 @@ ifeq ($(ARCHI),Emscripten)
@cp $(P)/data/examples/*.json $(BUILD)/examples
@cp $(P)/data/font.ttf $(BUILD)/data
@cp $(P)/data/imgui.ini $(BUILD)/data
endif

###################################################
# Compile and launch unit tests and generate the code coverage html report.
.PHONY: unit-tests
unit-tests:
@$(call print-simple,"Compiling unit tests")
@$(MAKE) -C tests coverage

###################################################
# Compile and launch unit tests and generate the code coverage html report.
.PHONY: check
check: unit-tests

###################################################
# Install project. You need to be root.
.PHONY: install
install: $(TARGET)
@$(call INSTALL_BINARY)
ifeq ($(EXAEQUOS),)
@$(MAKE) --no-print-directory -C src/Net install
@$(MAKE) --no-print-directory -C src/Editor install
@$(MAKE) --no-print-directory -C src/julia install
@$(call INSTALL_DOCUMENTATION)
@$(call INSTALL_PROJECT_HEADERS)
endif

###################################################
# Clean the whole project.
.PHONY: veryclean
veryclean: clean
@rm -fr cov-int $(PROJECT).tgz *.log foo 2> /dev/null
@(cd tests && $(MAKE) -s clean)
@$(call print-simple,"Cleaning","$(PWD)/doc/html")
@rm -fr $(THIRDPART)/*/ doc/html 2> /dev/null

###################################################
# Sharable informations between all Makefiles
#
include $(M)/Makefile.footer

###################################################
# Override clean the project
.PHONY: clean
clean::
@$(MAKE) --no-print-directory -C src/Net clean
@$(MAKE) --no-print-directory -C src/Editor clean
@$(MAKE) --no-print-directory -C src/julia clean
endif
21 changes: 5 additions & 16 deletions Makefile.common
Original file line number Diff line number Diff line change
@@ -1,23 +1,12 @@
###################################################
# Project definition
#
PROJECT = TimedPetriNetEditor
STANDARD = --std=c++14
BUILD_TYPE = release
PROJECT_NAME := TimedPetriNetEditor
PROJECT_VERSION := 0.4.0
COMPILATION_MODE := debug
CXX_STANDARD := --std=c++14

###################################################
# Select the Dear ImGui backend: RayLib or GLFW3.
#
DEAR_IMGUI_BACKEND ?= RayLib

###################################################
# Reduce warnings
#
CCFLAGS += -Wno-sign-conversion -Wno-float-equal
CXXFLAGS += -Wno-undef -Wno-switch-enum -Wno-enum-compare
CXXFLAGS += -Wshadow

###################################################
# Project defines
#
DEFINES += -DDATADIR=\"$(DATADIR):$(abspath $(P))/data/:data/\"
DEAR_IMGUI_BACKEND ?= GLFW3
1 change: 0 additions & 1 deletion VERSION.txt

This file was deleted.

10 changes: 5 additions & 5 deletions external/compile-external-libs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
### $CXX: C++ compiler
###############################################################################

source ../.makefile/compile-external-libs.sh
source $1

### Library raylib
print-compile raylib
Expand All @@ -39,11 +39,11 @@ print-compile raylib
# Note: Concerning .backup see https://www.themoderncoder.com/fix-sed-i-error-macos/
sed -i.backup 's/ExportImage(image, path)/ExportImage(image, fileName)/g' rcore.c

mkdir -p $ARCHI
mkdir -p $OS
call-make clean
if [ "$ARCHI" != "Emscripten" ]; then
call-make PLATFORM=PLATFORM_DESKTOP RAYLIB_RELEASE_PATH=$ARCHI RAYLIB_BUILD_MODE=DEBUG
if [ "$OS" != "Emscripten" ]; then
call-make PLATFORM=PLATFORM_DESKTOP RAYLIB_RELEASE_PATH=$OS RAYLIB_BUILD_MODE=DEBUG
else
call-make PLATFORM=PLATFORM_WEB RAYLIB_RELEASE_PATH=$ARCHI
call-make PLATFORM=PLATFORM_WEB RAYLIB_RELEASE_PATH=$OS
fi
)
2 changes: 1 addition & 1 deletion external/download-external-libs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
### It replaces git submodules that I dislike.
###############################################################################

source ../.makefile/download-external-libs.sh
source $1

### Dear ImGui: Bloat-free Graphical User interface for C++ with minimal dependencies
### License: MIT
Expand Down
6 changes: 3 additions & 3 deletions src/Editor/DearImGui/Backends/GLFW3/Application.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@
#ifndef APPLICATION_HPP
# define APPLICATION_HPP

#include "imgui.h"
#include "imgui/imgui.h"
#include "imgui_impl_glfw.h"
#include "imgui_impl_opengl3.h"
#include "imgui/misc/cpp/imgui_stdlib.h"
#include "implot.h"
#include "ImGuiFileDialog.h"
#include "implot/implot.h"
#include "ImGuiFileDialog/ImGuiFileDialog.h"
#include <GLFW/glfw3.h>

//------------------------------------------------------------------------------
Expand Down
105 changes: 105 additions & 0 deletions src/Editor/DearImGui/Backends/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
###################################################
# If compiling for HTML5 (Emscripten) then force
# using Raylib backend since GLFW3 is not compilable.
#
ifeq ($(OS),Emscripten)
ifndef EXAEQUOS
ifneq ($(DEAR_IMGUI_BACKEND),GLFW3)
$(warning Force GLFW3 backend for compiling with ExaequOS)
DEAR_IMGUI_BACKEND = GLFW3
endif
else
ifneq ($(DEAR_IMGUI_BACKEND),RayLib)
$(warning Force RayLib backend for compiling with Emscripten)
DEAR_IMGUI_BACKEND = RayLib
endif
endif
endif

###################################################
# Dear ImGui backends: GLFW3
#
ifeq ($(DEAR_IMGUI_BACKEND),GLFW3)
INCLUDES += $(P)/src/Editor/DearImGui/Backends/GLFW3
GUI_FILES += $(P)/src/Editor/DearImGui/Backends/GLFW3/Application.cpp
INCLUDES += $(THIRDPART_DIR)/imgui/backends/
GUI_FILES += $(THIRDPART_DIR)/imgui/backends/imgui_impl_glfw.cpp
GUI_FILES += $(THIRDPART_DIR)/imgui/backends/imgui_impl_opengl3.cpp
ifeq ($(OS),Linux)
# OpenGL, GLEW, GLFW3
LINKER_FLAGS += -lGL
PKG_LIBS += --static glfw3
else ifeq ($(OS),Darwin)
# OpenGL, GLEW, GLFW3
INCLUDES += -I/usr/local/include -I/opt/local/include
LINKER_FLAGS += -framework OpenGL -framework Cocoa
LINKER_FLAGS += -framework IOKit -framework CoreVideo
LINKER_FLAGS += -L/usr/local/lib -L/opt/local/lib
LINKER_FLAGS += -lGLEW -lglfw
else ifeq ($(OS),Emscripten)
ifdef EXAEQUOS
# Wayland, OpenGL, GLEW, GLFW3 for ExaequOS
LINKER_FLAGS += -sMIN_WEBGL_VERSION=2 -sMAX_WEBGL_VERSION=2 -sFULL_ES3
PKG_LIBS += exa-wayland --static glfw
else
# We tell the linker that the game/library uses GLFW3
# library internally, it must be linked automatically
# (emscripten provides the implementation)
LINKER_FLAGS += -s USE_GLFW=3
endif
else
$(error Unknown architecture $(OS) for OpenGL)
endif
USER_CXX_FLAGS += -Wno-old-style-cast -Wno-sign-conversion -Wno-float-equal
USER_CXX_FLAGS += -Wno-conversion
endif

###################################################
# Dear ImGui backends: Raylib
#
ifeq ($(DEAR_IMGUI_BACKEND),RayLib)
VPATH += $(P)/src/Editor/DearImGui
VPATH += $(P)/src/Editor/DearImGui/Backends/RayLib
INCLUDES += $(P)/src/Editor/DearImGui/Backends/RayLib
GUI_FILES += $(P)/src/Editor/DearImGui/Backends/RayLib/Application.cpp
VPATH += $(THIRDPART_DIR)/rlImGui
INCLUDES += $(THIRDPART_DIR)/rlImGui
GUI_FILES += $(THIRDPART_DIR)/rlImGui/rlImGui.cpp
INCLUDES += $(THIRDPART_DIR)/raylib/src
ifeq ($(OS),Emscripten)
ifdef EXAEQUOS
LINKER_FLAGS += -sMIN_WEBGL_VERSION=2 -sMAX_WEBGL_VERSION=2 -sFULL_ES3
PKG_LIBS += exa-wayland --static raylib
else
# We tell the linker that the game/library uses GLFW3
# library internally, it must be linked automatically
# (emscripten provides the implementation)
LINKER_FLAGS += -s USE_GLFW=3
endif
else
THIRDPART_LIBS += $(THIRDPART_DIR)/raylib/src/$(OS)/libraylib.a
endif

USER_CXX_FLAGS += -Wno-conversion -Wno-sign-conversion -Wno-float-equal -Wno-old-style-cast
USER_CXX_FLAGS += -Wno-cast-qual -Wno-undef
endif

# Dear ImGui
INCLUDES += $(THIRDPART_DIR)
INCLUDES += $(THIRDPART_DIR)/imgui
GUI_FILES += $(THIRDPART_DIR)/imgui/imgui_widgets.cpp
GUI_FILES += $(THIRDPART_DIR)/imgui/imgui_draw.cpp
GUI_FILES += $(THIRDPART_DIR)/imgui/imgui_tables.cpp
GUI_FILES += $(THIRDPART_DIR)/imgui/imgui.cpp
GUI_FILES += $(THIRDPART_DIR)/imgui/misc/cpp/imgui_stdlib.cpp

# Dear ImGui plot
GUI_FILES += $(THIRDPART_DIR)/implot/implot_items.cpp
GUI_FILES += $(THIRDPART_DIR)/implot/implot.cpp

# Dear ImGui file dialog
GUI_FILES += $(THIRDPART_DIR)/ImGuiFileDialog/ImGuiFileDialog.cpp
USER_CXX_FLAGS += -Wno-unknown-pragmas

# Petri Editor
GUI_FILES += $(call wildcard,$(P)/src/Editor/DearImGui/*.cpp)
Loading

0 comments on commit e39f461

Please sign in to comment.