diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..a91da51 --- /dev/null +++ b/Makefile @@ -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: + diff --git a/src/Makefile b/src/Makefile index 3efc00a..5f97ddc 100644 --- a/src/Makefile +++ b/src/Makefile @@ -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 + diff --git a/src/Makefile.dep b/src/Makefile.dep index f7d8322..9a4b611 100644 --- a/src/Makefile.dep +++ b/src/Makefile.dep @@ -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 diff --git a/src/Makefile.o.dep b/src/Makefile.o.dep deleted file mode 100644 index e98a22a..0000000 --- a/src/Makefile.o.dep +++ /dev/null @@ -1 +0,0 @@ -o = aes.o base32.o base64.o crypto.o misc.o \ No newline at end of file