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,69 +24,91 @@ 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
44
36
45
- LTCOMPILE = $(TGTLIBTOOL) --mode=compile --tag=CC $(CC)
46
- INSTALL_CMD = $(TGTLIBTOOL) --mode=install install
47
- UNINSTALL_CMD = $(TGTLIBTOOL) --mode=uninstall rm
37
+ ifeq ($(PLATFORM), Darwin)
38
+ SHARED += -dynamiclib
39
+ TARGET := $(NAME).dylib
40
+ else ifeq ($(OS), Windows_NT)
41
+ SHARED += -shared
42
+ TARGET := $(NAME).dll
43
+ else
44
+ SHARED += -shared
45
+ TARGET := $(NAME).so
46
+ endif
48
47
49
48
#Output filenames for various targets.
50
49
ifndef LIBNAME
51
- LIBNAME=libtomcrypt.la
50
+ LIBNAME = $(TARGET).$(VERSION_LT)
52
51
endif
53
52
54
-
55
53
include makefile_include.mk
56
54
55
+ .PHONY: check install install_bins uninstall
56
+
57
+ .bin/.tag:
58
+ mkdir -p .bin
59
+ touch $@
57
60
58
61
#ciphers come in two flavours... enc+dec and enc
59
62
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
63
+ $(CC ) $(LTC_CFLAGS) $(PIC ) $(CPPFLAGS ) -DENCRYPT_ONLY -c src/ciphers/aes/aes.c -o src/ciphers/aes/aes_enc.o
61
64
62
65
.c.o:
63
- $(LTCOMPILE) $(LTC_CFLAGS) $(CPPFLAGS) $(LTC_LDFLAGS) -o $@ -c $<
64
-
65
- LOBJECTS = $(OBJECTS:.o=.lo)
66
+ $(CC) $(LTC_CFLAGS) $(PIC) $(CPPFLAGS) -o $@ -c $<
66
67
67
68
$(LIBNAME): $(OBJECTS)
68
- $(TGTLIBTOOL) --mode=link --tag=CC $(CC) $(LTC_LDFLAGS) $(LOBJECTS) $(EXTRALIBS) -o $@ -rpath $(LIBPATH) -version-info $(VERSION_LT) $(NO_UNDEFINED)
69
+ $(CC) $(LTC_LDFLAGS) $(OBJECTS) $(EXTRALIBS) $(SHARED) -Wl,-soname,$(TARGET).$(VERSION_MAJOR) $(NO_UNDEFINED) -o $@
70
+
71
+ $(TARGET).$(VERSION_MAJOR): $(LIBNAME)
72
+ ln -sf $< $@
69
73
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)
74
+ $(TARGET): $(LIBNAME)
75
+ ln -sf $< $@
76
+
77
+ .bin/$(TEST): $(TARGET).$(VERSION_MAJOR) $(TARGET) $(TOBJECTS) .bin/.tag
78
+ $(CC) $(LTC_LDFLAGS) $(TOBJECTS) -L. -ltomcrypt $(EXTRALIBS) $(NO_UNDEFINED) -o $@
79
+
80
+ test: $(call print-help,test,Builds the library and the 'test' application to run all self-tests) .bin/$(TEST) bin.in
81
+ sed -e 's|@EXE@|$@|' bin.in >
[email protected]
82
+ $(INSTALL_CMD) -m 755
[email protected] $@
83
+
72
84
73
85
# build the demos from a template
74
86
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)
87
+ .bin/$(1): demos/$(1).o $$(TARGET).$$(VERSION_MAJOR) $$(TARGET) .bin/.tag
88
+ $$(CC) $$(LTC_LDFLAGS) $$< -L. -ltomcrypt $$(EXTRALIBS) $(NO_UNDEFINED) -o $$@
89
+
90
+ $(1): $(call print-help,$(1),Builds the library and the '$(1)' demo) .bin/$(1) bin.in
91
+ sed -e 's|@EXE@|$(1)|' bin.in > $(1).out
92
+ $$(INSTALL_CMD) -m 755 $(1).out $(1)
93
+ @rm -f $(1).out
77
94
endef
78
95
79
96
$(foreach demo, $(strip $(DEMOS)), $(eval $(call DEMO_template,$(demo))))
80
97
81
98
install: $(call print-help,install,Installs the library + headers + pkg-config file) .common_install
99
+ ln -sf $(LIBNAME) $(DESTDIR)/$(LIBPATH)/$(TARGET).$(VERSION_MAJOR)
100
+ ln -sf $(LIBNAME) $(DESTDIR)/$(LIBPATH)/$(TARGET)
82
101
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/
102
+ $(INSTALL_CMD) -p -d $(DESTDIR)$(LIBPATH)/pkgconfig
103
+ $(INSTALL_CMD) -p -m 644 libtomcrypt.pc $(DESTDIR)$(LIBPATH)/pkgconfig/
85
104
86
- install_bins: $(call print-help,install_bins,Installs the useful demos ($(USEFUL_DEMOS))) .common_install_bins
105
+ install_bins: $(call print-help,install_bins,Installs the useful demos ($(USEFUL_DEMOS))) $(USEFUL_DEMOS) $(DESTDIR)$(BINPATH)
106
+ $(INSTALL_CMD) -p -m 775 $(foreach demo, $(strip $(USEFUL_DEMOS)),.bin/$(demo)) $(DESTDIR)$(BINPATH)
87
107
88
108
uninstall: $(call print-help,uninstall,Uninstalls the library + headers + pkg-config file) .common_uninstall
89
- rm $(DESTDIR)$(LIBPATH)/pkgconfig/libtomcrypt.pc
109
+ $(UNINSTALL_CMD) $(DESTDIR)/$(LIBPATH)/$(TARGET).$(VERSION_MAJOR)
110
+ $(UNINSTALL_CMD) $(DESTDIR)/$(LIBPATH)/$(TARGET)
111
+ $(UNINSTALL_CMD) $(DESTDIR)$(LIBPATH)/pkgconfig/libtomcrypt.pc
90
112
91
113
# ref: $Format:%D$
92
114
# git commit: $Format:%H$
0 commit comments