Skip to content

Commit d2f50cc

Browse files
orbeasjaeckel
authored andcommitted
makefile.shared: Don't use libtool
Gentoo Bug: https://bugs.gentoo.org/777084
1 parent 60566eb commit d2f50cc

File tree

5 files changed

+96
-54
lines changed

5 files changed

+96
-54
lines changed

.gitignore

Lines changed: 4 additions & 2 deletions
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

Lines changed: 19 additions & 0 deletions
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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ sub patch_file {
273273
sub version_from_tomcrypt_h {
274274
my $h = read_file(shift);
275275
if ($h =~ /\n#define\s*SCRYPT\s*"([0-9]+)\.([0-9]+)\.([0-9]+)(\S*)"/s) {
276-
return "VERSION_PC=$1.$2.$3", "VERSION_LT=1:1", "VERSION=$1.$2.$3$4", "PROJECT_NUMBER=$1.$2.$3$4";
276+
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";
277277
}
278278
else {
279279
die "#define SCRYPT not found in tomcrypt.h";

makefile.shared

Lines changed: 52 additions & 34 deletions
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,34 +24,34 @@ 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
27+
INSTALL_CMD := install
28+
UNINSTALL_CMD := rm -f
29+
30+
NAME := libtomcrypt
31+
PIC := -fPIC
32+
SHARED := $(PIC)
33+
34+
ifeq ($(UNAME), Darwin)
35+
NO_UNDEFINED := -Wl,-undefined,error
36+
SHARED += -dynamiclib
2937
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
38+
NO_UNDEFIED := -Wl,--no-undefined
39+
SHARED += -shared
3940
endif
4041

41-
ifneq ($(findstring $(PLATFORM),CYGWIN MINGW32 MINGW64 MSYS),)
42-
NO_UNDEFINED:=-no-undefined
42+
ifeq ($(PLATFORM), Darwin)
43+
TARGET := $(NAME).dylib
44+
else ifeq ($(OS), Windows_NT)
45+
TARGET := $(NAME).dll
46+
else
47+
TARGET := $(NAME).so
4348
endif
4449

45-
LTCOMPILE = $(TGTLIBTOOL) --mode=compile --tag=CC $(CC)
46-
INSTALL_CMD = $(TGTLIBTOOL) --mode=install install
47-
UNINSTALL_CMD = $(TGTLIBTOOL) --mode=uninstall rm
48-
4950
#Output filenames for various targets.
5051
ifndef LIBNAME
51-
LIBNAME=libtomcrypt.la
52+
LIBNAME = $(TARGET).$(VERSION_LT)
5253
endif
5354

54-
5555
include makefile_include.mk
5656

5757
ifneq ($(findstring -DLTM_DESC,$(LTC_CFLAGS)),)
@@ -74,40 +74,58 @@ endif
7474
LTC_PKG_CONFIG_CFLAGS += $(PKG_CONFIG_CFLAGS)
7575
LTC_PKG_CONFIG_LIBS += $(PKG_CONFIG_LIBS)
7676

77+
.PHONY: check install install_bins uninstall
78+
79+
.bin/.tag: bin.in
80+
mkdir -p .bin
81+
touch $@
82+
7783
#ciphers come in two flavours... enc+dec and enc
7884
src/ciphers/aes/aes_enc.o: src/ciphers/aes/aes.c src/ciphers/aes/aes_tab.c
79-
$(LTCOMPILE) $(LTC_CFLAGS) $(CPPFLAGS) $(LTC_LDFLAGS) -DENCRYPT_ONLY -c src/ciphers/aes/aes.c -o src/ciphers/aes/aes_enc.o
85+
$(CC) $(LTC_CFLAGS) $(PIC) $(CPPFLAGS) -DENCRYPT_ONLY -c src/ciphers/aes/aes.c -o src/ciphers/aes/aes_enc.o
8086
src/ciphers/aes/aes_enc_desc.o: src/ciphers/aes/aes_desc.c
81-
$(LTCOMPILE) $(LTC_CFLAGS) $(CPPFLAGS) $(LTC_LDFLAGS) -DENCRYPT_ONLY -c src/ciphers/aes/aes_desc.c -o src/ciphers/aes/aes_enc_desc.o
87+
$(CC) $(LTC_CFLAGS) $(PIC) $(CPPFLAGS) -DENCRYPT_ONLY -c src/ciphers/aes/aes_desc.c -o src/ciphers/aes/aes_enc_desc.o
8288

8389
.c.o:
84-
$(LTCOMPILE) $(LTC_CFLAGS) $(CPPFLAGS) $(LTC_LDFLAGS) -o $@ -c $<
85-
86-
LOBJECTS = $(OBJECTS:.o=.lo)
90+
$(CC) $(LTC_CFLAGS) $(PIC) $(CPPFLAGS) -o $@ -c $<
8791

8892
$(LIBNAME): $(OBJECTS)
89-
$(TGTLIBTOOL) --mode=link --tag=CC $(CC) $(LTC_LDFLAGS) $(LOBJECTS) $(EXTRALIBS) -o $@ -rpath $(LIBPATH) -version-info $(VERSION_LT) $(NO_UNDEFINED)
93+
$(CC) $(LTC_LDFLAGS) $(OBJECTS) $(EXTRALIBS) $(SHARED) -Wl,-soname,$(TARGET).$(VERSION_MAJOR) $(NO_UNDEFINED) -o $@
94+
95+
$(TARGET).$(VERSION_MAJOR) $(TARGET): $(LIBNAME)
96+
ln -sf $< $@
9097

91-
test: $(call print-help,test,Builds the library and the 'test' application to run all self-tests) $(LIBNAME) $(TOBJECTS)
92-
$(TGTLIBTOOL) --mode=link --tag=CC $(CC) $(LTC_LDFLAGS) -o $(TEST) $(TOBJECTS) $(LIBNAME) $(EXTRALIBS)
98+
.bin/$(TEST): $(TARGET).$(VERSION_MAJOR) $(TARGET) $(TOBJECTS) .bin/.tag
99+
$(CC) $(LTC_LDFLAGS) $(TOBJECTS) -L. -ltomcrypt $(EXTRALIBS) $(NO_UNDEFINED) -o $@
100+
101+
test: $(call print-help,test,Builds the library and the 'test' application to run all self-tests) .bin/$(TEST)
102+
$(INSTALL_CMD) -m 755 bin.in $@
93103

94104
# build the demos from a template
95105
define DEMO_template
96-
$(1): $(call print-help,$(1),Builds the library and the '$(1)' demo) demos/$(1).o $$(LIBNAME)
97-
$$(TGTLIBTOOL) --mode=link --tag=CC $$(CC) $$(LTC_LDFLAGS) $$^ $$(EXTRALIBS) -o $$@
106+
.bin/$(1): demos/$(1).o $$(TARGET).$$(VERSION_MAJOR) $$(TARGET) .bin/.tag
107+
$$(CC) $$(LTC_LDFLAGS) $$< -L. -ltomcrypt $$(EXTRALIBS) $(NO_UNDEFINED) -o $$@
108+
109+
$(1): $(call print-help,$(1),Builds the library and the '$(1)' demo) .bin/$(1)
110+
$$(INSTALL_CMD) -m 755 bin.in $(1)
98111
endef
99112

100113
$(foreach demo, $(strip $(DEMOS)), $(eval $(call DEMO_template,$(demo))))
101114

102115
install: $(call print-help,install,Installs the library + headers + pkg-config file) .common_install
116+
ln -sf $(LIBNAME) $(DESTDIR)/$(LIBPATH)/$(TARGET).$(VERSION_MAJOR)
117+
ln -sf $(LIBNAME) $(DESTDIR)/$(LIBPATH)/$(TARGET)
103118
sed -e 's,^prefix=.*,prefix=$(PREFIX),' -e 's,^Version:.*,Version: $(VERSION_PC),' -e 's,^libdir=.*,libdir=$(LIBPATH),' \
104119
-e 's,^includedir=.*,includedir=$(INCPATH),' \
105120
-e 's,@PKG_CONFIG_LIBS@,$(LTC_PKG_CONFIG_LIBS),' \
106121
-e 's,@PKG_CONFIG_CFLAGS@,$(LTC_PKG_CONFIG_CFLAGS),' libtomcrypt.pc.in > libtomcrypt.pc
107-
install -p -d $(DESTDIR)$(LIBPATH)/pkgconfig
108-
install -p -m 644 libtomcrypt.pc $(DESTDIR)$(LIBPATH)/pkgconfig/
122+
$(INSTALL_CMD) -p -d $(DESTDIR)$(LIBPATH)/pkgconfig
123+
$(INSTALL_CMD) -p -m 644 libtomcrypt.pc $(DESTDIR)$(LIBPATH)/pkgconfig/
109124

110-
install_bins: $(call print-help,install_bins,Installs the useful demos ($(USEFUL_DEMOS))) .common_install_bins
125+
install_bins: $(call print-help,install_bins,Installs the useful demos ($(USEFUL_DEMOS))) $(USEFUL_DEMOS) $(DESTDIR)$(BINPATH)
126+
$(INSTALL_CMD) -p -m 775 $(foreach demo, $(strip $(USEFUL_DEMOS)),.bin/$(demo)) $(DESTDIR)$(BINPATH)
111127

112128
uninstall: $(call print-help,uninstall,Uninstalls the library + headers + pkg-config file) .common_uninstall
113-
rm $(DESTDIR)$(LIBPATH)/pkgconfig/libtomcrypt.pc
129+
$(UNINSTALL_CMD) $(DESTDIR)/$(LIBPATH)/$(TARGET).$(VERSION_MAJOR)
130+
$(UNINSTALL_CMD) $(DESTDIR)/$(LIBPATH)/$(TARGET)
131+
$(UNINSTALL_CMD) $(DESTDIR)$(LIBPATH)/pkgconfig/libtomcrypt.pc

makefile_include.mk

Lines changed: 20 additions & 17 deletions
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
@@ -507,30 +510,30 @@ install_hooks: $(call print-help,install_hooks,Installs the git hooks)
507510
HEADER_FILES=$(notdir $(HEADERS_PUB))
508511
.common_uninstall:
509512
$(UNINSTALL_CMD) $(DESTDIR)$(LIBPATH)/$(LIBNAME)
510-
rm $(HEADER_FILES:%=$(DESTDIR)$(INCPATH)/%)
513+
$(UNINSTALL_CMD) $(HEADER_FILES:%=$(DESTDIR)$(INCPATH)/%)
511514

512515
#This rule cleans the source tree of all compiled code, not including the pdf
513516
#documentation.
514517
clean: $(call print-help,clean,Clean everything besides the pdf documentation)
515518
find . -type f -name "*.o" \
516-
-o -name "*.lo" \
517-
-o -name "*.a" \
518-
-o -name "*.la" \
519-
-o -name "*.obj" \
520-
-o -name "*.lib" \
521-
-o -name "*.exe" \
522-
-o -name "*.dll" \
523-
-o -name "*.so" \
524-
-o -name "*.gcov"\
525-
-o -name "*.gcda"\
526-
-o -name "*.gcno"\
527-
-o -name "*.il" \
528-
-o -name "*.dyn" \
519+
-o -name "*.a" \
520+
-o -name "*.obj" \
521+
-o -name "*.lib" \
522+
-o -name "*.exe" \
523+
-o -name "*.dll*" \
524+
-o -name "*.dylib*"\
525+
-o -name "*.so*" \
526+
-o -name "*.out" \
527+
-o -name "*.gcov" \
528+
-o -name "*.gcda" \
529+
-o -name "*.gcno" \
530+
-o -name "*.il" \
531+
-o -name "*.dyn" \
529532
-o -name "*.dpi" | xargs rm -f
530533
rm -f $(TIMING) $(TEST) $(DEMOS)
531534
rm -f *_tv.txt
532535
rm -f *.pc
533-
rm -rf `find . -type d -name "*.libs" | xargs`
536+
rm -rf `find . -type d -name "*.bin" | xargs`
534537
$(MAKE) -C doc/ clean
535538

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

0 commit comments

Comments
 (0)