Skip to content

Commit

Permalink
Split Makefile into several makefiles
Browse files Browse the repository at this point in the history
Since before the merge d6d2908 (huge
GUI refactorization), the old API of Julia interfaces offered to call
the GUI. Since, this merge is was not possible since Petri net and GUI
have been separated. It's now a better idea to have 3 libraries: - core
for managing Petri nets without GUI; -- GUI for editor using Petri nets;
-- Julia interface.
  • Loading branch information
Lecrapouille committed Apr 30, 2024
1 parent 566cb8e commit da41e40
Show file tree
Hide file tree
Showing 7 changed files with 259 additions and 75 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ petri.json
build/
doc/coverage/
external/*/
src/*/VERSION.txt

# LaTeX
*.aux
Expand Down
2 changes: 1 addition & 1 deletion .makefile
125 changes: 51 additions & 74 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,53 +1,27 @@
###################################################
# Project definition
#
PROJECT = TimedPetriNetEditor
TARGET = $(PROJECT)
DESCRIPTION = Timed Petri Net Editor
STANDARD = --std=c++14
BUILD_TYPE = debug

###################################################
# Location of the project directory and Makefiles
#
P := .
M := $(P)/.makefile
include $(M)/Makefile.header

###################################################
# The application is using Dear ImGui for the human
# interface.
#
include $(P)/src/Editor/DearImGui/Makefile.imgui

###################################################
# Check if objects have been set for the GUI.
#
ifeq ($(GUI_OBJS),)
$(error "No .o files have been defined for the graphical interface")
endif

###################################################
# Set MQTT Library.
# Project definition
#
ifneq ($(ARCHI),Emscripten)
INCLUDES += -I$(THIRDPART) -I$(THIRDPART)/MQTT/include
VPATH += $(THIRDPART)/MQTT/src
DEFINES += -DMQTT_BROKER_ADDR=\"localhost\"
DEFINES += -DMQTT_BROKER_PORT=1883
PKG_LIBS += libmosquitto
endif
include $(P)/Makefile.common
TARGET = $(PROJECT)
DESCRIPTION = Timed Petri Net Editor

###################################################
# Set json ibrary.
# Other targets
#
INCLUDES += -I$(THIRDPART)/json/include
LIB_TPNE_CORE = $(abspath $(P)/src/Net/$(BUILD)/libtimedpetrinetcore.a)
LIB_TPNE_GUI = $(abspath $(P)/src/Editor/$(BUILD)/libtimedpetrinetgui.a)
LIB_TPNE_JULIA = $(abspath $(P)/src/julia/$(BUILD)/libtimedpetrinetjulia.a)

###################################################
# Set xml Library.
# Sharable informations between all Makefiles
#
VPATH += $(THIRDPART)/tinyxml2
LIB_OBJS += tinyxml2.o
include $(M)/Makefile.header

###################################################
# OpenGL: glfw and glew libraries
Expand Down Expand Up @@ -86,58 +60,50 @@ LINKER_FLAGS += -framework CoreFoundation
endif

###################################################
# Inform Makefile where to find *.cpp files
# Stand-alone application.
#
include $(P)/src/Editor/DearImGui/Makefile.imgui
THIRDPART_LIBS += $(LIB_TPNE_GUI) $(LIB_TPNE_CORE)
THIRDPART_LIBS += $(LIB_TPNE_JULIA)
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

###################################################
# Inform Makefile where to find header files
#
INCLUDES += -I$(P)/include -I$(P)/src -I$(P)/external
OBJS += main.o

###################################################
# Project defines
#
DEFINES += -DDATADIR=\"$(DATADIR):$(abspath $(P))/data/:data/\"

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

###################################################
# Linkage
#
LINKER_FLAGS += -ldl -lpthread
# Compile the stand-alone application
.PHONY: all
all: | $(LIB_TPNE_GUI) $(LIB_TPNE_CORE) $(LIB_TPNE_JULIA)
all: $(TARGET) $(LIB_TPNE_GUI) $(LIB_TPNE_CORE) $(LIB_TPNE_JULIA) copy-emscripten-assets

###################################################
# Make the list of compiled files for the library
#
IMPORT_FORMATS += ImportJSON.o ImportPNML.o ImportTimedEventGraph.o ExportTimedEventGraph.o
EXPORT_FORMATS += ExportJSON.o ExportPNML.o ExportSymfony.o ExportPnEditor.o
EXPORT_FORMATS += ExportPetriLaTeX.o ExportJulia.o ExportGraphviz.o ExportDrawIO.o
EXPORT_FORMATS += ExportGrafcetCpp.o
LIB_OBJS += Path.o Howard.o Utils.o TimedTokens.o Receptivities.o
LIB_OBJS += PetriNet.o Algorithms.o Simulation.o History.o
LIB_OBJS += $(IMPORT_FORMATS) Imports.o $(EXPORT_FORMATS) Exports.o
# Compile The Petri net core lib
$(LIB_TPNE_CORE): src/Net/Makefile Makefile
@$(call print-from,"Compiling Petri net core lib",$(PROJECT),core)
@$(MAKE) -C src/Net all
@cp $(LIB_TPNE_CORE) $(BUILD)

###################################################
# Make the list of compiled files for the application
#
OBJS += $(LIB_OBJS) $(GUI_OBJS) Drawable.o Application.o Editor.o main.o
# Compile The Petri net gui lib
$(LIB_TPNE_GUI): | $(LIB_TPNE_CORE)
$(LIB_TPNE_GUI): src/Editor/Makefile Makefile
@$(call print-from,"Compiling Petri net GUI lib",$(PROJECT),gui)
@$(MAKE) -C src/Editor all
@cp $(LIB_TPNE_GUI) $(BUILD)

###################################################
# Compile the project, the static and shared libraries
.PHONY: all
all: copy-assets $(STATIC_LIB_TARGET) $(SHARED_LIB_TARGET) $(PKG_FILE) $(TARGET)
# Compile interface for Julia
$(LIB_TPNE_JULIA): | $(LIB_TPNE_GUI)
$(LIB_TPNE_JULIA): $(LIB_TPNE_GUI) $(LIB_TPNE_CORE) src/julia/Makefile Makefile
@$(call print-from,"Compiling Interface for Julia-lang",$(PROJECT),Julia-lang)
@$(MAKE) -C src/julia all
@cp $(LIB_TPNE_JULIA) $(BUILD)

###################################################
# Copy data inside BUILD to allow emscripten to embedded them
.PHONY: copy-assets
copy-assets: | $(BUILD)
copy-emscripten-assets: | $(BUILD)
ifeq ($(ARCHI),Emscripten)
@$(call print-to,"Copying assets","$(TARGET)","$(BUILD)","")
@mkdir -p $(BUILD)/data
Expand All @@ -163,10 +129,12 @@ ifeq ($(ARCHI),Linux)
###################################################
# Install project. You need to be root.
.PHONY: install
install: $(TARGET) $(STATIC_LIB_TARGET) $(SHARED_LIB_TARGET) $(PKG_FILE)
install: $(TARGET)
@$(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_BINARY)
@$(call INSTALL_DOCUMENTATION)
@$(call INSTALL_PROJECT_LIBRARIES)
@$(call INSTALL_PROJECT_HEADERS)
endif

Expand All @@ -181,4 +149,13 @@ veryclean: clean

###################################################
# 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
18 changes: 18 additions & 0 deletions Makefile.common
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
###################################################
# Project definition
#
PROJECT = TimedPetriNetEditor
STANDARD = --std=c++14
BUILD_TYPE = release

###################################################
# 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/\"
47 changes: 47 additions & 0 deletions src/Editor/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
###################################################
# Location of the project directory and Makefiles
#
P := ../..
M := $(P)/.makefile

###################################################
# Project definition
#
include $(P)/Makefile.common
TARGET = TimedPetriNetGui
DESCRIPTION = Library for the GUI of the Timed Petri Net Editor

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

###################################################
# For the moment we only use Dear ImGui
#
include ./DearImGui/Makefile.imgui

###################################################
# Make the list of compiled files for the library
#
VPATH += $(P)/include $(P)/src $(P)/src/Utils $(P)/src/Net
VPATH += $(P)/src/Net/Imports $(P)/src/Net/Exports
INCLUDES += -I$(P)/include -I$(P)/src -I$(P)/external
LIB_OBJS += $(GUI_OBJS) Drawable.o Application.o Editor.o

###################################################
# Compile the project, the static and shared libraries
#
.PHONY: all
all: $(STATIC_LIB_TARGET) $(SHARED_LIB_TARGET) $(PKG_FILE) $(P)/Makefile $(P)/Makefile.common

###################################################
# Install project. You need to be root.
.PHONY: install
install: $(STATIC_LIB_TARGET) $(SHARED_LIB_TARGET) $(PKG_FILE)
@$(call INSTALL_PROJECT_LIBRARIES)

###################################################
# Sharable informations between all Makefiles
#
include $(M)/Makefile.footer
82 changes: 82 additions & 0 deletions src/Net/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
###################################################
# Location of the project directory and Makefiles
#
P := ../..
M := $(P)/.makefile

###################################################
# Project definition
#
include $(P)/Makefile.common
TARGET = TimedPetriNetCore
DESCRIPTION = Library for the Core of the Timed Petri Net Editor

###################################################
# Location of the project directory and Makefiles
#
include $(M)/Makefile.header

###################################################
# Set MQTT Library.
#
ifneq ($(ARCHI),Emscripten)
INCLUDES += -I$(THIRDPART) -I$(THIRDPART)/MQTT/include
VPATH += $(THIRDPART)/MQTT/src
DEFINES += -DMQTT_BROKER_ADDR=\"localhost\"
DEFINES += -DMQTT_BROKER_PORT=1883
PKG_LIBS += libmosquitto
endif

###################################################
# Set json ibrary.
#
INCLUDES += -I$(THIRDPART)/json/include

###################################################
# Set xml Library.
#
VPATH += $(THIRDPART)/tinyxml2
LIB_OBJS += tinyxml2.o

###################################################
# Inform Makefile where to find *.cpp files
#
VPATH += $(P)/include $(P)/src $(P)/src/Utils $(P)/src/Net
VPATH += $(P)/src/Net/Imports $(P)/src/Net/Exports

###################################################
# Inform Makefile where to find header files
#
INCLUDES += -I$(P)/include -I$(P)/src -I$(P)/external

###################################################
# Linkage
#
LINKER_FLAGS += -ldl -lpthread

###################################################
# Make the list of compiled files for the library
#
IMPORT_FORMATS += ImportJSON.o ImportPNML.o ImportTimedEventGraph.o ExportTimedEventGraph.o
EXPORT_FORMATS += ExportJSON.o ExportPNML.o ExportSymfony.o ExportPnEditor.o
EXPORT_FORMATS += ExportPetriLaTeX.o ExportJulia.o ExportGraphviz.o ExportDrawIO.o
EXPORT_FORMATS += ExportGrafcetCpp.o
LIB_OBJS += Path.o Howard.o Utils.o TimedTokens.o Receptivities.o
LIB_OBJS += PetriNet.o Algorithms.o Simulation.o History.o
LIB_OBJS += $(IMPORT_FORMATS) Imports.o $(EXPORT_FORMATS) Exports.o

###################################################
# Compile the project, the static and shared libraries
.PHONY: all
all: $(STATIC_LIB_TARGET) $(SHARED_LIB_TARGET) $(PKG_FILE) $(P)/Makefile $(P)/Makefile.common

###################################################
# Install project. You need to be root.
.PHONY: install
install: $(STATIC_LIB_TARGET) $(SHARED_LIB_TARGET) $(PKG_FILE)
@$(call INSTALL_PROJECT_LIBRARIES)

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

0 comments on commit da41e40

Please sign in to comment.