1# MAKEFILE for linux GCC
2#
3# This makefile produces a shared object and requires libtool to be installed.
4#
5# Thanks to Zed Shaw for helping debug this on BSD/OSX.
6# Tom St Denis
7#
8#  (GNU $(MAKE) only)
9
10### USAGE:
11#
12# CFLAGS="-DUSE_LTM -DLTM_DESC -I/path/to/libtommath" $(MAKE) -f makefile.shared all EXTRALIBS=/path/to/libtommath/libtommath.a
13# ./test
14# $(MAKE) -f makefile.shared PREFIX=/opt/libtom install
15#
16
17PLATFORM := $(shell uname | sed -e 's/_.*//')
18
19ifndef LIBTOOL
20  ifeq ($(PLATFORM), Darwin)
21    LIBTOOL:=glibtool
22  else
23    LIBTOOL:=libtool
24  endif
25endif
26ifeq ($(PLATFORM), CYGWIN)
27  NO_UNDEFINED:=-no-undefined
28endif
29LTCOMPILE = $(LIBTOOL) --mode=compile --tag=CC $(CC)
30INSTALL_CMD = $(LIBTOOL) --mode=install install
31UNINSTALL_CMD = $(LIBTOOL) --mode=uninstall rm
32
33#Output filenames for various targets.
34ifndef LIBNAME
35   LIBNAME=libtomcrypt.la
36endif
37
38
39include makefile_include.mk
40
41
42#ciphers come in two flavours... enc+dec and enc
43src/ciphers/aes/aes_enc.o: src/ciphers/aes/aes.c src/ciphers/aes/aes_tab.c
44	$(LTCOMPILE) $(LTC_CFLAGS) $(CPPFLAGS) $(LTC_LDFLAGS) -DENCRYPT_ONLY -c src/ciphers/aes/aes.c -o src/ciphers/aes/aes_enc.o
45
46.c.o:
47	$(LTCOMPILE) $(LTC_CFLAGS) $(CPPFLAGS) $(LTC_LDFLAGS) -o $@ -c $<
48
49LOBJECTS = $(OBJECTS:.o=.lo)
50
51$(LIBNAME): $(OBJECTS)
52	$(LIBTOOL) --mode=link --tag=CC $(CC) $(LTC_LDFLAGS) $(LOBJECTS) $(EXTRALIBS) -o $@ -rpath $(LIBPATH) -version-info $(VERSION_LT) $(NO_UNDEFINED)
53
54test: $(call print-help,test,Builds the library and the 'test' application to run all self-tests) $(LIBNAME) $(TOBJECTS)
55	$(LIBTOOL) --mode=link --tag=CC $(CC) $(LTC_LDFLAGS) -o $(TEST) $(TOBJECTS) $(LIBNAME) $(EXTRALIBS)
56
57# build the demos from a template
58define DEMO_template
59$(1): $(call print-help,$(1),Builds the library and the '$(1)' demo) demos/$(1).o $$(LIBNAME)
60	$$(LIBTOOL) --mode=link --tag=CC $$(CC) $$(LTC_LDFLAGS) $$^ $$(EXTRALIBS) -o $(1)
61endef
62
63$(foreach demo, $(strip $(DEMOS)), $(eval $(call DEMO_template,$(demo))))
64
65install: $(call print-help,install,Installs the library + headers + pkg-config file) .common_install
66	sed -e 's,^prefix=.*,prefix=$(PREFIX),' -e 's,^Version:.*,Version: $(VERSION_PC),' libtomcrypt.pc.in > libtomcrypt.pc
67	install -p -d $(DESTDIR)$(LIBPATH)/pkgconfig
68	install -p -m 644 libtomcrypt.pc $(DESTDIR)$(LIBPATH)/pkgconfig/
69
70install_bins: $(call print-help,install_bins,Installs the useful demos ($(USEFUL_DEMOS))) .common_install_bins
71
72uninstall: $(call print-help,uninstall,Uninstalls the library + headers + pkg-config file) .common_uninstall
73	rm $(DESTDIR)$(LIBPATH)/pkgconfig/libtomcrypt.pc
74
75# ref:         HEAD -> master, tag: v1.18.2
76# git commit:  7e7eb695d581782f04b24dc444cbfde86af59853
77# commit time: 2018-07-01 22:49:01 +0200
78