1
1
# MAKEFILE for linux GCC
2
2
#
3
- # This makefile produces a shared object and requires libtool to be installed .
3
+ # This makefile produces a shared object.
4
4
#
5
5
# Thanks to Zed Shaw for helping debug this on BSD/OSX.
6
6
# Tom St Denis
@@ -24,34 +24,33 @@ PLATFORM := $(shell uname | sed -e 's/_.*//')
24
24
# Linux (on all Linux distros)
25
25
# Darwin (on macOS, OS X)
26
26
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
39
29
endif
40
30
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)
44
37
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
48
48
49
49
#Output filenames for various targets.
50
50
ifndef LIBNAME
51
- LIBNAME=libtomcrypt.la
51
+ LIBNAME = $(TARGET).$(VERSION_LT)
52
52
endif
53
53
54
-
55
54
include makefile_include.mk
56
55
57
56
ifneq ($(findstring -DLTM_DESC,$(LTC_CFLAGS)),)
@@ -67,43 +66,61 @@ LTC_MPI_PROVIDERS_CFLAGS += -DGMP_DESC
67
66
LTC_MPI_PROVIDERS_LIBS += -lgmp
68
67
endif
69
68
69
+ .PHONY: check install install_bins uninstall
70
+
71
+ .bin/.tag: bin.in
72
+ mkdir -p .bin
73
+ touch $@
74
+
70
75
#ciphers come in two flavours... enc+dec and enc
71
76
src/ciphers/aes/aes_enc.o: src/ciphers/aes/aes.c src/ciphers/aes/aes_tab.c
72
- $(LTCOMPILE ) $(LTC_CFLAGS) $(CPPFLAGS ) $(LTC_LDFLAGS ) -DENCRYPT_ONLY -c src/ciphers/aes/aes.c -o src/ciphers/aes/aes_enc.o
77
+ $(CC ) $(LTC_CFLAGS) $(PIC ) $(CPPFLAGS ) -DENCRYPT_ONLY -c src/ciphers/aes/aes.c -o src/ciphers/aes/aes_enc.o
73
78
src/ciphers/aes/aes_enc_desc.o: src/ciphers/aes/aes_desc.c
74
- $(LTCOMPILE ) $(LTC_CFLAGS) $(CPPFLAGS ) $(LTC_LDFLAGS ) -DENCRYPT_ONLY -c src/ciphers/aes/aes_desc.c -o src/ciphers/aes/aes_enc_desc.o
79
+ $(CC ) $(LTC_CFLAGS) $(PIC ) $(CPPFLAGS ) -DENCRYPT_ONLY -c src/ciphers/aes/aes_desc.c -o src/ciphers/aes/aes_enc_desc.o
75
80
76
81
.c.o:
77
- $(LTCOMPILE) $(LTC_CFLAGS) $(CPPFLAGS) $(LTC_LDFLAGS) -o $@ -c $<
78
-
79
- LOBJECTS = $(OBJECTS:.o=.lo)
82
+ $(CC) $(LTC_CFLAGS) $(PIC) $(CPPFLAGS) -o $@ -c $<
80
83
81
84
$(LIBNAME): $(OBJECTS)
82
- $(TGTLIBTOOL) --mode=link --tag=CC $(CC ) $(LTC_LDFLAGS) $(LOBJECTS ) $(EXTRALIBS) -o $@ -rpath $(LIBPATH ) -version-info $(VERSION_LT) $(NO_UNDEFINED)
85
+ $(CC ) $(LTC_LDFLAGS) $(OBJECTS ) $(EXTRALIBS) $(SHARED ) -Wl,-soname,$(TARGET).$(VERSION_MAJOR) $(NO_UNDEFINED) -o $@
83
86
84
- test: $(call print-help,test,Builds the library and the 'test' application to run all self-tests) $(LIBNAME) $(TOBJECTS)
85
- $(TGTLIBTOOL) --mode=link --tag=CC $(CC) $(LTC_LDFLAGS) -o $(TEST) $(TOBJECTS) $(LIBNAME) $(EXTRALIBS)
87
+ $(TARGET).$(VERSION_MAJOR) $(TARGET): $(LIBNAME)
88
+ ln -sf $< $@
89
+
90
+ .bin/$(TEST): $(TARGET).$(VERSION_MAJOR) $(TARGET) $(TOBJECTS) .bin/.tag
91
+ $(CC) $(LTC_LDFLAGS) $(TOBJECTS) -L. -ltomcrypt $(EXTRALIBS) $(NO_UNDEFINED) -o $@
92
+
93
+ test: $(call print-help,test,Builds the library and the 'test' application to run all self-tests) .bin/$(TEST)
94
+ $(INSTALL_CMD) -m 755 bin.in $@
86
95
87
96
# build the demos from a template
88
97
define DEMO_template
89
- $(1): $(call print-help,$(1),Builds the library and the '$(1)' demo) demos/$(1).o $$(LIBNAME)
90
- $$(TGTLIBTOOL) --mode=link --tag=CC $$(CC) $$(LTC_LDFLAGS) $$^ $$(EXTRALIBS) -o $(1)
98
+ .bin/$(1): demos/$(1).o $$(TARGET).$$(VERSION_MAJOR) $$(TARGET) .bin/.tag
99
+ $$(CC) $$(LTC_LDFLAGS) $$< -L. -ltomcrypt $$(EXTRALIBS) $(NO_UNDEFINED) -o $$@
100
+
101
+ $(1): $(call print-help,$(1),Builds the library and the '$(1)' demo) .bin/$(1)
102
+ $$(INSTALL_CMD) -m 755 bin.in $(1)
91
103
endef
92
104
93
105
$(foreach demo, $(strip $(DEMOS)), $(eval $(call DEMO_template,$(demo))))
94
106
95
107
install: $(call print-help,install,Installs the library + headers + pkg-config file) .common_install
108
+ ln -sf $(LIBNAME) $(DESTDIR)/$(LIBPATH)/$(TARGET).$(VERSION_MAJOR)
109
+ ln -sf $(LIBNAME) $(DESTDIR)/$(LIBPATH)/$(TARGET)
96
110
sed -e 's,^prefix=.*,prefix=$(PREFIX),' -e 's,^Version:.*,Version: $(VERSION_PC),' -e 's,@CMAKE_INSTALL_LIBDIR@,lib,' \
97
111
-e 's,@CMAKE_INSTALL_INCLUDEDIR@/@PROJECT_NAME@,include/tomcrypt,' \
98
112
-e 's,@MPI_PROVIDERS_LIBS@,$(LTC_MPI_PROVIDERS_LIBS),' \
99
113
-e 's,@MPI_PROVIDERS_CFLAGS@,$(LTC_MPI_PROVIDERS_CFLAGS),' libtomcrypt.pc.in > libtomcrypt.pc
100
- install -p -d $(DESTDIR)$(LIBPATH)/pkgconfig
101
- install -p -m 644 libtomcrypt.pc $(DESTDIR)$(LIBPATH)/pkgconfig/
114
+ $(INSTALL_CMD) -p -d $(DESTDIR)$(LIBPATH)/pkgconfig
115
+ $(INSTALL_CMD) -p -m 644 libtomcrypt.pc $(DESTDIR)$(LIBPATH)/pkgconfig/
102
116
103
- install_bins: $(call print-help,install_bins,Installs the useful demos ($(USEFUL_DEMOS))) .common_install_bins
117
+ install_bins: $(call print-help,install_bins,Installs the useful demos ($(USEFUL_DEMOS))) $(USEFUL_DEMOS) $(DESTDIR)$(BINPATH)
118
+ $(INSTALL_CMD) -p -m 775 $(foreach demo, $(strip $(USEFUL_DEMOS)),.bin/$(demo)) $(DESTDIR)$(BINPATH)
104
119
105
120
uninstall: $(call print-help,uninstall,Uninstalls the library + headers + pkg-config file) .common_uninstall
106
- rm $(DESTDIR)$(LIBPATH)/pkgconfig/libtomcrypt.pc
121
+ $(UNINSTALL_CMD) $(DESTDIR)/$(LIBPATH)/$(TARGET).$(VERSION_MAJOR)
122
+ $(UNINSTALL_CMD) $(DESTDIR)/$(LIBPATH)/$(TARGET)
123
+ $(UNINSTALL_CMD) $(DESTDIR)$(LIBPATH)/pkgconfig/libtomcrypt.pc
107
124
108
125
# ref: $Format:%D$
109
126
# git commit: $Format:%H$
0 commit comments