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,85 @@ 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
56
+ .PHONY: check install install_bins uninstall
57
+
58
+ .bin/.tag: bin.in
59
+ mkdir -p .bin
60
+ touch $@
57
61
58
62
#ciphers come in two flavours... enc+dec and enc
59
63
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
61
65
62
66
.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 $<
66
68
67
69
$(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 $< $@
69
74
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 $@
72
80
73
81
# build the demos from a template
74
82
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)
77
88
endef
78
89
79
90
$(foreach demo, $(strip $(DEMOS)), $(eval $(call DEMO_template,$(demo))))
80
91
81
92
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)
82
95
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/
85
98
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)
87
101
88
102
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
90
106
91
107
# ref: $Format:%D$
92
108
# git commit: $Format:%H$
0 commit comments