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:
Tomasz Sowa 2022-06-26 06:17:20 +02:00
parent e02fe7a235
commit a212a69517
4 changed files with 60 additions and 26 deletions

26
Makefile Normal file
View File

@ -0,0 +1,26 @@
export CXX
export CXXFLAGS
export AR
all: src
src: FORCE
$(MAKE) -C src
clean: FORCE
$(MAKE) -C src clean
depend: FORCE
$(MAKE) -C src depend
FORCE:

View File

@ -1,36 +1,45 @@
include Makefile.o.dep
sourcefiles:=$(shell find . -name "*.cpp")
objfiles:=$(patsubst %.cpp,%.o,$(sourcefiles))
libname=tito.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 = tito.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/src $<
depend:
makedepend -Y. -I$(global_relative_working_dir)/pikotools/src -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

View File

@ -1,10 +1,10 @@
# DO NOT DELETE
aes.o: aes.h
base32.o: base32.h
base64.o: base64.h
crypto.o: crypto.h aes.h base64.h ../../pikotools/src/utf8/utf8.h
crypto.o: ../../pikotools/src/textstream/stream.h
crypto.o: ../../pikotools/src/utf8/utf8_templates.h
crypto.o: ../../pikotools/src/utf8/utf8_private.h misc.h
misc.o: misc.h
./aes.o: aes.h
./base32.o: base32.h
./base64.o: base64.h
./crypto.o: crypto.h aes.h base64.h ../../pikotools/src/utf8/utf8.h
./crypto.o: ../../pikotools/src/textstream/stream.h
./crypto.o: ../../pikotools/src/utf8/utf8_templates.h
./crypto.o: ../../pikotools/src/utf8/utf8_private.h misc.h
./misc.o: misc.h

View File

@ -1 +0,0 @@
o = aes.o base32.o base64.o crypto.o misc.o