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,34 @@ 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
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
29
37
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
39
40
endif
40
41
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
43
48
endif
44
49
45
- LTCOMPILE = $(TGTLIBTOOL) --mode=compile --tag=CC $(CC)
46
- INSTALL_CMD = $(TGTLIBTOOL) --mode=install install
47
- UNINSTALL_CMD = $(TGTLIBTOOL) --mode=uninstall rm
48
-
49
50
#Output filenames for various targets.
50
51
ifndef LIBNAME
51
- LIBNAME=libtomcrypt.la
52
+ LIBNAME = $(TARGET).$(VERSION_LT)
52
53
endif
53
54
54
-
55
55
include makefile_include.mk
56
56
57
57
ifneq ($(findstring -DLTM_DESC,$(LTC_CFLAGS)),)
@@ -67,43 +67,61 @@ LTC_MPI_PROVIDERS_CFLAGS += -DGMP_DESC
67
67
LTC_MPI_PROVIDERS_LIBS += -lgmp
68
68
endif
69
69
70
+ .PHONY: check install install_bins uninstall
71
+
72
+ .bin/.tag: bin.in
73
+ mkdir -p .bin
74
+ touch $@
75
+
70
76
#ciphers come in two flavours... enc+dec and enc
71
77
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
78
+ $(CC ) $(LTC_CFLAGS) $(PIC ) $(CPPFLAGS ) -DENCRYPT_ONLY -c src/ciphers/aes/aes.c -o src/ciphers/aes/aes_enc.o
73
79
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
80
+ $(CC ) $(LTC_CFLAGS) $(PIC ) $(CPPFLAGS ) -DENCRYPT_ONLY -c src/ciphers/aes/aes_desc.c -o src/ciphers/aes/aes_enc_desc.o
75
81
76
82
.c.o:
77
- $(LTCOMPILE) $(LTC_CFLAGS) $(CPPFLAGS) $(LTC_LDFLAGS) -o $@ -c $<
78
-
79
- LOBJECTS = $(OBJECTS:.o=.lo)
83
+ $(CC) $(LTC_CFLAGS) $(PIC) $(CPPFLAGS) -o $@ -c $<
80
84
81
85
$(LIBNAME): $(OBJECTS)
82
- $(TGTLIBTOOL) --mode=link --tag=CC $(CC) $(LTC_LDFLAGS) $(LOBJECTS) $(EXTRALIBS) -o $@ -rpath $(LIBPATH) -version-info $(VERSION_LT) $(NO_UNDEFINED)
86
+ $(CC) $(LTC_LDFLAGS) $(OBJECTS) $(EXTRALIBS) $(SHARED) -Wl,-soname,$(TARGET).$(VERSION_MAJOR) $(NO_UNDEFINED) -o $@
87
+
88
+ $(TARGET).$(VERSION_MAJOR) $(TARGET): $(LIBNAME)
89
+ ln -sf $< $@
83
90
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)
91
+ .bin/$(TEST): $(TARGET).$(VERSION_MAJOR) $(TARGET) $(TOBJECTS) .bin/.tag
92
+ $(CC) $(LTC_LDFLAGS) $(TOBJECTS) -L. -ltomcrypt $(EXTRALIBS) $(NO_UNDEFINED) -o $@
93
+
94
+ test: $(call print-help,test,Builds the library and the 'test' application to run all self-tests) .bin/$(TEST)
95
+ $(INSTALL_CMD) -m 755 bin.in $@
86
96
87
97
# build the demos from a template
88
98
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)
99
+ .bin/$(1): demos/$(1).o $$(TARGET).$$(VERSION_MAJOR) $$(TARGET) .bin/.tag
100
+ $$(CC) $$(LTC_LDFLAGS) $$< -L. -ltomcrypt $$(EXTRALIBS) $(NO_UNDEFINED) -o $$@
101
+
102
+ $(1): $(call print-help,$(1),Builds the library and the '$(1)' demo) .bin/$(1)
103
+ $$(INSTALL_CMD) -m 755 bin.in $(1)
91
104
endef
92
105
93
106
$(foreach demo, $(strip $(DEMOS)), $(eval $(call DEMO_template,$(demo))))
94
107
95
108
install: $(call print-help,install,Installs the library + headers + pkg-config file) .common_install
109
+ ln -sf $(LIBNAME) $(DESTDIR)/$(LIBPATH)/$(TARGET).$(VERSION_MAJOR)
110
+ ln -sf $(LIBNAME) $(DESTDIR)/$(LIBPATH)/$(TARGET)
96
111
sed -e 's,^prefix=.*,prefix=$(PREFIX),' -e 's,^Version:.*,Version: $(VERSION_PC),' -e 's,^libdir=.*,libdir=$(LIBPATH),' \
97
112
-e 's,^includedir=.*,includedir=$(INCPATH),' \
98
113
-e 's,@MPI_PROVIDERS_LIBS@,$(LTC_MPI_PROVIDERS_LIBS),' \
99
114
-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/
115
+ $(INSTALL_CMD) -p -d $(DESTDIR)$(LIBPATH)/pkgconfig
116
+ $(INSTALL_CMD) -p -m 644 libtomcrypt.pc $(DESTDIR)$(LIBPATH)/pkgconfig/
102
117
103
- install_bins: $(call print-help,install_bins,Installs the useful demos ($(USEFUL_DEMOS))) .common_install_bins
118
+ install_bins: $(call print-help,install_bins,Installs the useful demos ($(USEFUL_DEMOS))) $(USEFUL_DEMOS) $(DESTDIR)$(BINPATH)
119
+ $(INSTALL_CMD) -p -m 775 $(foreach demo, $(strip $(USEFUL_DEMOS)),.bin/$(demo)) $(DESTDIR)$(BINPATH)
104
120
105
121
uninstall: $(call print-help,uninstall,Uninstalls the library + headers + pkg-config file) .common_uninstall
106
- rm $(DESTDIR)$(LIBPATH)/pkgconfig/libtomcrypt.pc
122
+ $(UNINSTALL_CMD) $(DESTDIR)/$(LIBPATH)/$(TARGET).$(VERSION_MAJOR)
123
+ $(UNINSTALL_CMD) $(DESTDIR)/$(LIBPATH)/$(TARGET)
124
+ $(UNINSTALL_CMD) $(DESTDIR)$(LIBPATH)/pkgconfig/libtomcrypt.pc
107
125
108
126
# ref: $Format:%D$
109
127
# git commit: $Format:%H$
0 commit comments