Skip to content

Commit 859f545

Browse files
committed
makefile.shared: Don't use libtool
Gentoo Bug: https://bugs.gentoo.org/777084
1 parent 06a81ae commit 859f545

File tree

5 files changed

+94
-54
lines changed

5 files changed

+94
-54
lines changed

.gitignore

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
# suppress compiler/linker output
22
*.[oa]
33
*.obj
4-
*.l[oa]
4+
*.dylib*
5+
*.dll*
6+
*.so*
57
[Dd]ebug/
68
[Rr]elease/
79
/MSVC_*
8-
.libs/
10+
.bin/
911

1012
# release files
1113
/libtomcrypt-*

bin.in

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/sh
2+
# Shell wrapper script for the executables when built with the shared
3+
# libtomcrypt library.
4+
5+
set -euf
6+
7+
rootdir="$(cd -- "${0%/*}/" && pwd -P)"
8+
binpath="$rootdir/.bin/${0##*/}"
9+
10+
[ -z "${LD_LIBRARY_PATH:=$rootdir}" ] ||
11+
LD_LIBRARY_PATH="$rootdir:$LD_LIBRARY_PATH"
12+
13+
export LD_LIBRARY_PATH
14+
15+
if [ -n "${1+x}" ]; then
16+
exec "$binpath" "${@:-}"
17+
else
18+
exec "$binpath"
19+
fi

helper.pl

+1-1
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ sub patch_file {
272272
sub version_from_tomcrypt_h {
273273
my $h = read_file(shift);
274274
if ($h =~ /\n#define\s*SCRYPT\s*"([0-9]+)\.([0-9]+)\.([0-9]+)(\S*)"/s) {
275-
return "VERSION_PC=$1.$2.$3", "VERSION_LT=1:1", "VERSION=$1.$2.$3$4", "PROJECT_NUMBER=$1.$2.$3$4";
275+
return "VERSION_PC=$1.$2.$3", "VERSION_MAJOR=1", "VERSION_MINOR=0", "VERSION_PATCH=1", "VERSION=$1.$2.$3$4", "PROJECT_NUMBER=$1.$2.$3$4";
276276
}
277277
else {
278278
die "#define SCRYPT not found in tomcrypt.h";

makefile.shared

+50-34
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# MAKEFILE for linux GCC
22
#
3-
# This makefile produces a shared object and requires libtool to be installed.
3+
# This makefile produces a shared object.
44
#
55
# Thanks to Zed Shaw for helping debug this on BSD/OSX.
66
# Tom St Denis
@@ -24,69 +24,85 @@ PLATFORM := $(shell uname | sed -e 's/_.*//')
2424
# Linux (on all Linux distros)
2525
# Darwin (on macOS, OS X)
2626

27-
ifeq ($(LIBTOOL),rlibtool)
28-
TGTLIBTOOL:=slibtool-shared
29-
else
30-
ifndef LIBTOOL
31-
ifeq ($(PLATFORM), Darwin)
32-
TGTLIBTOOL:=glibtool
33-
else
34-
TGTLIBTOOL:=libtool
35-
endif
36-
else
37-
TGTLIBTOOL=$(LIBTOOL)
38-
endif
27+
ifneq ($(findstring $(PLATFORM),Linux CYGWIN MINGW32 MINGW64 MSYS),)
28+
NO_UNDEFINED := -Wl,--no-undefined
3929
endif
4030

41-
ifneq ($(findstring $(PLATFORM),CYGWIN MINGW32 MINGW64 MSYS),)
42-
NO_UNDEFINED:=-no-undefined
43-
endif
31+
INSTALL_CMD := install
32+
UNINSTALL_CMD := rm -f
33+
34+
NAME := libtomcrypt
35+
PIC := -fPIC
36+
SHARED := $(PIC)
4437

45-
LTCOMPILE = $(TGTLIBTOOL) --mode=compile --tag=CC $(CC)
46-
INSTALL_CMD = $(TGTLIBTOOL) --mode=install install
47-
UNINSTALL_CMD = $(TGTLIBTOOL) --mode=uninstall rm
38+
ifeq ($(PLATFORM), Darwin)
39+
SHARED += -dynamiclib
40+
TARGET := $(NAME).dylib
41+
else ifeq ($(OS), Windows_NT)
42+
SHARED += -shared
43+
TARGET := $(NAME).dll
44+
else
45+
SHARED += -shared
46+
TARGET := $(NAME).so
47+
endif
4848

4949
#Output filenames for various targets.
5050
ifndef LIBNAME
51-
LIBNAME=libtomcrypt.la
51+
LIBNAME = $(TARGET).$(VERSION_LT)
5252
endif
5353

54-
5554
include makefile_include.mk
5655

56+
.PHONY: check install install_bins uninstall
57+
58+
.bin/.tag: bin.in
59+
mkdir -p .bin
60+
touch $@
5761

5862
#ciphers come in two flavours... enc+dec and enc
5963
src/ciphers/aes/aes_enc.o: src/ciphers/aes/aes.c src/ciphers/aes/aes_tab.c
60-
$(LTCOMPILE) $(LTC_CFLAGS) $(CPPFLAGS) $(LTC_LDFLAGS) -DENCRYPT_ONLY -c src/ciphers/aes/aes.c -o src/ciphers/aes/aes_enc.o
64+
$(CC) $(LTC_CFLAGS) $(PIC) $(CPPFLAGS) -DENCRYPT_ONLY -c src/ciphers/aes/aes.c -o src/ciphers/aes/aes_enc.o
6165

6266
.c.o:
63-
$(LTCOMPILE) $(LTC_CFLAGS) $(CPPFLAGS) $(LTC_LDFLAGS) -o $@ -c $<
64-
65-
LOBJECTS = $(OBJECTS:.o=.lo)
67+
$(CC) $(LTC_CFLAGS) $(PIC) $(CPPFLAGS) -o $@ -c $<
6668

6769
$(LIBNAME): $(OBJECTS)
68-
$(TGTLIBTOOL) --mode=link --tag=CC $(CC) $(LTC_LDFLAGS) $(LOBJECTS) $(EXTRALIBS) -o $@ -rpath $(LIBPATH) -version-info $(VERSION_LT) $(NO_UNDEFINED)
70+
$(CC) $(LTC_LDFLAGS) $(OBJECTS) $(EXTRALIBS) $(SHARED) -Wl,-soname,$(TARGET).$(VERSION_MAJOR) $(NO_UNDEFINED) -o $@
71+
72+
$(TARGET).$(VERSION_MAJOR) $(TARGET): $(LIBNAME)
73+
ln -sf $< $@
6974

70-
test: $(call print-help,test,Builds the library and the 'test' application to run all self-tests) $(LIBNAME) $(TOBJECTS)
71-
$(TGTLIBTOOL) --mode=link --tag=CC $(CC) $(LTC_LDFLAGS) -o $(TEST) $(TOBJECTS) $(LIBNAME) $(EXTRALIBS)
75+
.bin/$(TEST): $(TARGET).$(VERSION_MAJOR) $(TARGET) $(TOBJECTS) .bin/.tag
76+
$(CC) $(LTC_LDFLAGS) $(TOBJECTS) -L. -ltomcrypt $(EXTRALIBS) $(NO_UNDEFINED) -o $@
77+
78+
test: $(call print-help,test,Builds the library and the 'test' application to run all self-tests) .bin/$(TEST)
79+
$(INSTALL_CMD) -m 755 bin.in $@
7280

7381
# build the demos from a template
7482
define DEMO_template
75-
$(1): $(call print-help,$(1),Builds the library and the '$(1)' demo) demos/$(1).o $$(LIBNAME)
76-
$$(TGTLIBTOOL) --mode=link --tag=CC $$(CC) $$(LTC_LDFLAGS) $$^ $$(EXTRALIBS) -o $(1)
83+
.bin/$(1): demos/$(1).o $$(TARGET).$$(VERSION_MAJOR) $$(TARGET) .bin/.tag
84+
$$(CC) $$(LTC_LDFLAGS) $$< -L. -ltomcrypt $$(EXTRALIBS) $(NO_UNDEFINED) -o $$@
85+
86+
$(1): $(call print-help,$(1),Builds the library and the '$(1)' demo) .bin/$(1)
87+
$$(INSTALL_CMD) -m 755 bin.in $(1)
7788
endef
7889

7990
$(foreach demo, $(strip $(DEMOS)), $(eval $(call DEMO_template,$(demo))))
8091

8192
install: $(call print-help,install,Installs the library + headers + pkg-config file) .common_install
93+
ln -sf $(LIBNAME) $(DESTDIR)/$(LIBPATH)/$(TARGET).$(VERSION_MAJOR)
94+
ln -sf $(LIBNAME) $(DESTDIR)/$(LIBPATH)/$(TARGET)
8295
sed -e 's,^prefix=.*,prefix=$(PREFIX),' -e 's,^Version:.*,Version: $(VERSION_PC),' libtomcrypt.pc.in > libtomcrypt.pc
83-
install -p -d $(DESTDIR)$(LIBPATH)/pkgconfig
84-
install -p -m 644 libtomcrypt.pc $(DESTDIR)$(LIBPATH)/pkgconfig/
96+
$(INSTALL_CMD) -p -d $(DESTDIR)$(LIBPATH)/pkgconfig
97+
$(INSTALL_CMD) -p -m 644 libtomcrypt.pc $(DESTDIR)$(LIBPATH)/pkgconfig/
8598

86-
install_bins: $(call print-help,install_bins,Installs the useful demos ($(USEFUL_DEMOS))) .common_install_bins
99+
install_bins: $(call print-help,install_bins,Installs the useful demos ($(USEFUL_DEMOS))) $(USEFUL_DEMOS) $(DESTDIR)$(BINPATH)
100+
$(INSTALL_CMD) -p -m 775 $(foreach demo, $(strip $(USEFUL_DEMOS)),.bin/$(demo)) $(DESTDIR)$(BINPATH)
87101

88102
uninstall: $(call print-help,uninstall,Uninstalls the library + headers + pkg-config file) .common_uninstall
89-
rm $(DESTDIR)$(LIBPATH)/pkgconfig/libtomcrypt.pc
103+
$(UNINSTALL_CMD) $(DESTDIR)/$(LIBPATH)/$(TARGET).$(VERSION_MAJOR)
104+
$(UNINSTALL_CMD) $(DESTDIR)/$(LIBPATH)/$(TARGET)
105+
$(UNINSTALL_CMD) $(DESTDIR)$(LIBPATH)/pkgconfig/libtomcrypt.pc
90106

91107
# ref: $Format:%D$
92108
# git commit: $Format:%H$

makefile_include.mk

+20-17
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@
55
# The version - BEWARE: VERSION, VERSION_PC and VERSION_LT are updated via ./updatemakes.sh
66
VERSION=1.18.2-develop
77
VERSION_PC=1.18.2
8-
# http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
9-
VERSION_LT=1:1
8+
# https://semver.org/
9+
VERSION_MAJOR=1
10+
VERSION_MINOR=0
11+
VERSION_PATCH=1
12+
VERSION_LT=$(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_PATCH)
1013

1114
# Compiler and Linker Names
1215
ifndef CROSS_COMPILE
@@ -478,30 +481,30 @@ install_hooks: $(call print-help,install_hooks,Installs the git hooks)
478481
HEADER_FILES=$(notdir $(HEADERS_PUB))
479482
.common_uninstall:
480483
$(UNINSTALL_CMD) $(DESTDIR)$(LIBPATH)/$(LIBNAME)
481-
rm $(HEADER_FILES:%=$(DESTDIR)$(INCPATH)/%)
484+
$(UNINSTALL_CMD) $(HEADER_FILES:%=$(DESTDIR)$(INCPATH)/%)
482485

483486
#This rule cleans the source tree of all compiled code, not including the pdf
484487
#documentation.
485488
clean: $(call print-help,clean,Clean everything besides the pdf documentation)
486489
find . -type f -name "*.o" \
487-
-o -name "*.lo" \
488-
-o -name "*.a" \
489-
-o -name "*.la" \
490-
-o -name "*.obj" \
491-
-o -name "*.lib" \
492-
-o -name "*.exe" \
493-
-o -name "*.dll" \
494-
-o -name "*.so" \
495-
-o -name "*.gcov"\
496-
-o -name "*.gcda"\
497-
-o -name "*.gcno"\
498-
-o -name "*.il" \
499-
-o -name "*.dyn" \
490+
-o -name "*.a" \
491+
-o -name "*.obj" \
492+
-o -name "*.lib" \
493+
-o -name "*.exe" \
494+
-o -name "*.dll*" \
495+
-o -name "*.dylib*"\
496+
-o -name "*.so*" \
497+
-o -name "*.out" \
498+
-o -name "*.gcov" \
499+
-o -name "*.gcda" \
500+
-o -name "*.gcno" \
501+
-o -name "*.il" \
502+
-o -name "*.dyn" \
500503
-o -name "*.dpi" | xargs rm -f
501504
rm -f $(TIMING) $(TEST) $(DEMOS)
502505
rm -f *_tv.txt
503506
rm -f *.pc
504-
rm -rf `find . -type d -name "*.libs" | xargs`
507+
rm -rf `find . -type d -name "*.bin" | xargs`
505508
$(MAKE) -C doc/ clean
506509

507510
zipup: $(call print-help,zipup,Prepare the archives for a release) doc/crypt.pdf

0 commit comments

Comments
 (0)