add global Makefile

src/Makefile uses now 'find' for looking for *.cpp files
and we don't need Makefile.o.dep anymore
This commit is contained in:
2022-06-26 06:15:19 +02:00
parent fc50c8ca5e
commit c89d4f76bc
7 changed files with 426 additions and 141 deletions

View File

@@ -1,36 +1,45 @@
include Makefile.o.dep
sourcefiles:=$(shell find . -name "*.cpp")
objfiles:=$(patsubst %.cpp,%.o,$(sourcefiles))
libname=morm.a
ifndef GLOBAL_WORKING_DIR
GLOBAL_WORKING_DIR := $(shell pwd)/../..
ifndef CXX
CXX = g++
endif
current_path := $(shell pwd)
global_relative_working_dir := $(shell relative_path $(current_path) $(GLOBAL_WORKING_DIR))
ifndef CXXFLAGS
CXXFLAGS = -Wall -pedantic -O2 -std=c++20 -I../../pikotools/src -I/usr/local/include
endif
ifndef AR
AR = ar
endif
libname = morm.a
all: $(libname)
$(libname): $(o)
$(AR) rcs $(libname) $(o)
$(libname): $(objfiles)
$(AR) rcs $(libname) $(objfiles)
%.o: %.cpp
$(CXX) -c $(CXXFLAGS) -I$(GLOBAL_WORKING_DIR)/pikotools $<
depend:
makedepend -Y. -I$(global_relative_working_dir)/pikotools -f- *.cpp > Makefile.dep
echo -n "o = " > Makefile.o.dep
ls -1 *.cpp | xargs -I foo echo -n foo " " | sed -E "s/([^\.]*)\.cpp[ ]/\1\.o/g" >> Makefile.o.dep
$(CXX) -c $(CXXFLAGS) -o $@ $<
clean:
rm -f *.o
rm -f $(objfiles)
rm -f $(libname)
include Makefile.dep
depend:
makedepend -Y. -I../../pikotools/src -f- $(sourcefiles) > Makefile.dep
-include Makefile.dep