global winixd/Makefile uses now 'find' for looking for *.cpp files

and we don't need Makefiles in subdirectories anymore (except plugins)
This commit is contained in:
2022-06-26 06:22:27 +02:00
parent 56d87c4410
commit 26226de865
53 changed files with 16781 additions and 22045 deletions

View File

@@ -1,83 +1,79 @@
# Makefile for GNU make
# GNU Makefile
include Makefile.dep
# sourcefiles: all *.cpp files except ./plugins subdirectory
# objfiles: corresponding *.o files
sourcefiles:=$(shell find . -name "*.cpp" -not \( -path ./plugins/\* \))
objfiles:=$(patsubst %.cpp,%.o,$(sourcefiles))
# sourcefiles_no_main: all *.cpp files except ./plugins and ./main subdirectories
sourcefiles_no_main:=$(shell find . -name "*.cpp" -not \( -path ./plugins/\* \) -not \( -path ./main/\* \))
objfiles_no_main:=$(patsubst %.cpp,%.o,$(sourcefiles_no_main))
# https://www.gnu.org/software/make/manual/html_node/Flavors.html#Flavors
GLOBAL_WORKING_DIR := $(shell pwd)/../..
current_path := $(shell pwd)
global_relative_working_dir := $(shell relative_path $(current_path) $(GLOBAL_WORKING_DIR))
# sourcefiles_main: all *.cpp files from ./main subdirectory
sourcefiles_main:=$(shell find main -name "*.cpp")
objfiles_main:=$(patsubst %.cpp,%.o,$(sourcefiles_main))
ifeq ($(CXX), g++)
CXX = g++6
endif
WINIX_PLUGINS_MAKEDEPEND_INCLUDES = -I../../../../winix/winixd \
-I../../../../pikotools/src \
-I../../../../morm/src \
-I../../../../ezc/src \
-I../../../../tito/src
WINIX_NEEDED_MACROS = -DPT_HAS_MORM_LIBRARY \
-DEZC_HAS_MORM_LIBRARY \
-DMORM_HAS_EZC_LIBRARY
ifndef CXX
ifeq ($(OSTYPE), FreeBSD)
CXX = clang++
else
CXX = g++6
CXX = g++
endif
endif
# CXX = g++-4.8
ifndef CXXFLAGS
CXXFLAGS = -Wall -O0 -g -fPIC -pthread -std=c++20 -I/usr/local/include -I/usr/include/postgresql -I$(GLOBAL_WORKING_DIR)/pikotools/src -I$(GLOBAL_WORKING_DIR)/ezc/src -I$(GLOBAL_WORKING_DIR)/morm/src -DPT_HAS_MORM_LIBRARY -DEZC_HAS_MORM_LIBRARY -DMORM_HAS_EZC_LIBRARY
CXXFLAGS = -Wall -pedantic -O2 -std=c++20 -fPIC -pthread \
-I/usr/local/include \
-I/usr/include/postgresql \
-I../../winix/winixd \
-I../../pikotools/src \
-I../../morm/src \
-I../../ezc/src \
-I../../tito/src \
$(WINIX_PLUGINS_MAKEDEPEND_INCLUDES) \
$(WINIX_NEEDED_MACROS)
endif
ifndef AR
AR = ar
endif
winix_include_paths = -I$(global_relative_working_dir)/winix/winixd -I$(global_relative_working_dir)/ezc/src -I$(global_relative_working_dir)/tito/src -I$(global_relative_working_dir)/morm/src -I$(global_relative_working_dir)/pikotools/src
ifndef LDFLAGS
LDFLAGS = -L/usr/local/lib
LDFLAGS = -L/usr/local/lib -s
endif
# for make install
winix_install_dir = /usr/local/winix
WINIX_INSTALL_DIR = /usr/local/winix
export CXX
export CXXFLAGS
export LDFLAGS
export GLOBAL_WORKING_DIR
export WINIX_PLUGINS_MAKEDEPEND_INCLUDES
export WINIX_NEEDED_MACROS
all: winix winix.so plugins
all: winix.so plugins winix
winix: $(objfiles_main) winix.so
$(CXX) -o winix $(CXXFLAGS) $(LDFLAGS) $(objfiles_main) winix.so -lfcgi
winix.so: $(winix.src.files)
@cd core ; $(MAKE) -e
@cd models ; $(MAKE) -e
@cd db ; $(MAKE) -e
@cd functions ; $(MAKE) -e
@cd templates ; $(MAKE) -e
@cd notify ; $(MAKE) -e
@cd utils ; $(MAKE) -e
@cd $(GLOBAL_WORKING_DIR)/ezc/src ; $(MAKE) -e
@cd $(GLOBAL_WORKING_DIR)/tito/src ; $(MAKE) -e
@cd $(GLOBAL_WORKING_DIR)/pikotools ; $(MAKE) -e
@cd $(GLOBAL_WORKING_DIR)/morm/src ; $(MAKE) -e
$(CXX) -shared -rdynamic -Wl,-whole-archive -o winix.so $(CXXFLAGS) $(winix_include_paths) core/*.o db/*.o models/*.o functions/*.o templates/*.o notify/*.o utils/*.o $(GLOBAL_WORKING_DIR)/ezc/src/ezc.a $(GLOBAL_WORKING_DIR)/tito/src/tito.a $(GLOBAL_WORKING_DIR)/pikotools/src/pikotools.a $(GLOBAL_WORKING_DIR)/morm/src/morm.a $(LDFLAGS) -lfcgi -lpq -lz -lpthread -lcurl -lmagic -Wl,-no-whole-archive
winix: winix.so $(winix.src.files)
@cd main ; $(MAKE) -e
$(CXX) -o winix $(CXXFLAGS) $(LDFLAGS) main/*.o winix.so -lfcgi
winix.so: $(objfiles_no_main)
@cd ../../pikotools ; $(MAKE) -e
@cd ../../morm ; $(MAKE) -e
@cd ../../ezc ; $(MAKE) -e
@cd ../../tito ; $(MAKE) -e
$(CXX) -shared -rdynamic -Wl,-whole-archive -o winix.so $(CXXFLAGS) $(objfiles_no_main) ../../pikotools/src/pikotools.a ../../morm/src/morm.a ../../ezc/src/ezc.a ../../tito/src/tito.a $(LDFLAGS) -lfcgi -lpq -lz -lpthread -lcurl -lmagic -Wl,-no-whole-archive
plugins: FORCE
@@ -92,17 +88,17 @@ plugins: FORCE
@cd plugins/seo ; $(MAKE) -e
%.o: %.cpp
$(CXX) -c $(CXXFLAGS) -o $@ $<
FORCE:
clean:
@cd core ; $(MAKE) -e clean
@cd db ; $(MAKE) -e clean
@cd models ; $(MAKE) -e clean
@cd functions ; $(MAKE) -e clean
@cd templates ; $(MAKE) -e clean
@cd notify ; $(MAKE) -e clean
@cd utils ; $(MAKE) -e clean
rm -f $(objfiles)
rm -f winix.so
rm -f winix
@cd plugins/stats ; $(MAKE) -e clean
@cd plugins/thread ; $(MAKE) -e clean
@cd plugins/ticket ; $(MAKE) -e clean
@@ -112,77 +108,63 @@ clean:
@cd plugins/export ; $(MAKE) -e clean
@cd plugins/mailregister ; $(MAKE) -e clean
@cd plugins/seo ; $(MAKE) -e clean
@cd $(GLOBAL_WORKING_DIR)/ezc/src ; $(MAKE) -e clean
@cd $(GLOBAL_WORKING_DIR)/tito/src ; $(MAKE) -e clean
@cd $(GLOBAL_WORKING_DIR)/pikotools ; $(MAKE) -e clean
@cd $(GLOBAL_WORKING_DIR)/morm/src ; $(MAKE) -e clean
@cd main ; $(MAKE) -e clean
rm -f winix.so
rm -f winix
@cd ../../pikotools ; $(MAKE) -e clean
@cd ../../morm ; $(MAKE) -e clean
@cd ../../ezc ; $(MAKE) -e clean
@cd ../../tito ; $(MAKE) -e clean
depend:
@cd core ; $(MAKE) -e depend
@cd db ; $(MAKE) -e depend
@cd models ; $(MAKE) -e depend
@cd functions ; $(MAKE) -e depend
@cd templates ; $(MAKE) -e depend
@cd notify ; $(MAKE) -e depend
@cd utils ; $(MAKE) -e depend
@cd plugins/stats ; $(MAKE) -e depend
@cd plugins/thread ; $(MAKE) -e depend
@cd plugins/ticket ; $(MAKE) -e depend
@cd plugins/gallery ; $(MAKE) -e depend
@cd plugins/group ; $(MAKE) -e depend
@cd plugins/menu ; $(MAKE) -e depend
@cd plugins/export ; $(MAKE) -e depend
@cd plugins/mailregister ; $(MAKE) -e depend
@cd plugins/seo ; $(MAKE) -e depend
@cd $(GLOBAL_WORKING_DIR)/ezc/src ; $(MAKE) -e depend
@cd $(GLOBAL_WORKING_DIR)/tito/src ; $(MAKE) -e depend
@cd $(GLOBAL_WORKING_DIR)/pikotools ; $(MAKE) -e depend
@cd main ; $(MAKE) -e depend
echo -n "winix.src.files = " > Makefile.dep
find -E . -type f -regex ".*\.h|.*\.cpp" | xargs -I foo echo -n foo " " >> Makefile.dep
# use $(global_relative_working_dir) here to put relative paths to Makefile.dep
find -E $(global_relative_working_dir)/ezc/src -type f -regex ".*\.h|.*\.cpp" | xargs -I foo echo -n foo " " >> Makefile.dep
find -E $(global_relative_working_dir)/tito/src -type f -regex ".*\.h|.*\.cpp" | xargs -I foo echo -n foo " " >> Makefile.dep
find -E $(global_relative_working_dir)/pikotools/src -type f -regex ".*\.h|.*\.cpp" | xargs -I foo echo -n foo " " >> Makefile.dep
find -E $(global_relative_working_dir)/morm/src -type f -regex ".*\.h|.*\.cpp" | xargs -I foo echo -n foo " " >> Makefile.dep
makedepend -Y. -I../../pikotools/src -I../../morm/src -I../../ezc/src -I../../tito/src $(WINIX_NEEDED_MACROS) -f- $(sourcefiles) > Makefile.dep
@cd plugins/stats ; $(MAKE) -e depend
@cd plugins/thread ; $(MAKE) -e depend
@cd plugins/ticket ; $(MAKE) -e depend
@cd plugins/gallery ; $(MAKE) -e depend
@cd plugins/group ; $(MAKE) -e depend
@cd plugins/menu ; $(MAKE) -e depend
@cd plugins/export ; $(MAKE) -e depend
@cd plugins/mailregister ; $(MAKE) -e depend
@cd plugins/seo ; $(MAKE) -e depend
@cd ../../pikotools ; $(MAKE) -e depend
@cd ../../morm ; $(MAKE) -e depend
@cd ../../ezc ; $(MAKE) -e depend
@cd ../../tito ; $(MAKE) -e depend
install: all
# installing binaries
rm -Rf $(winix_install_dir)/bin
mkdir -p $(winix_install_dir)/bin
cp winix $(winix_install_dir)/bin
cp winix.so $(winix_install_dir)/bin
rm -Rf $(WINIX_INSTALL_DIR)/bin
mkdir -p $(WINIX_INSTALL_DIR)/bin
cp winix $(WINIX_INSTALL_DIR)/bin
cp winix.so $(WINIX_INSTALL_DIR)/bin
# etc configs
rm -Rf $(winix_install_dir)/etc
mkdir -p $(winix_install_dir)/etc
cp -rf etc/* $(winix_install_dir)/etc/
rm -Rf $(WINIX_INSTALL_DIR)/etc
mkdir -p $(WINIX_INSTALL_DIR)/etc
cp -rf etc/* $(WINIX_INSTALL_DIR)/etc/
# html templates
rm -Rf $(winix_install_dir)/html
mkdir -p $(winix_install_dir)/html
cp -rf html/* $(winix_install_dir)/html/
rm -Rf $(WINIX_INSTALL_DIR)/html
mkdir -p $(WINIX_INSTALL_DIR)/html
cp -rf html/* $(WINIX_INSTALL_DIR)/html/
# txt templates
rm -Rf $(winix_install_dir)/txt
mkdir -p $(winix_install_dir)/txt
cp -rf txt/* $(winix_install_dir)/txt/
rm -Rf $(WINIX_INSTALL_DIR)/txt
mkdir -p $(WINIX_INSTALL_DIR)/txt
cp -rf txt/* $(WINIX_INSTALL_DIR)/txt/
# locales
rm -Rf $(winix_install_dir)/locale
mkdir -p $(winix_install_dir)/locale
cp -rf locale/* $(winix_install_dir)/locale/
rm -Rf $(WINIX_INSTALL_DIR)/locale
mkdir -p $(WINIX_INSTALL_DIR)/locale
cp -rf locale/* $(WINIX_INSTALL_DIR)/locale/
# plugins
rm -Rf $(winix_install_dir)/plugins
mkdir -p $(winix_install_dir)/plugins
find plugins/ -name "*.so" | xargs -I foo cp foo $(winix_install_dir)/plugins/
# deleting subversion directories
find $(winix_install_dir) -type d -name ".svn" | xargs -I foo rm -fr foo
rm -Rf $(WINIX_INSTALL_DIR)/plugins
mkdir -p $(WINIX_INSTALL_DIR)/plugins
find plugins/ -name "*.so" | xargs -I foo cp foo $(WINIX_INSTALL_DIR)/plugins/
# removing privileges for others
find $(winix_install_dir) -exec chmod o-r,o-x,o-w "{}" "+"
find $(WINIX_INSTALL_DIR) -exec chmod o-r,o-x,o-w "{}" "+"
-include Makefile.dep