makefile patches from MacPorts

Ryan Schmidt <[email protected]> Thu, 2 Apr 2015 22:41:03 -0500
Newsgroups gmane.comp.encryption.cryptlib
Message-ID <[email protected]>
In MacPorts, we use a couple patches to cryptlib, which might appropriate for including in the upstream sources.

In this one, we patch the makefile:

https://trac.macports.org/browser/trunk/dports/devel/cryptlib/files/patch-makefile.diff?rev=114713

That's for cryptlib 3.4.2; I'll attach one updated for 3.4.3 beta.

We append to CFLAGS, rather than overwriting them, and remove the line that clears LDFLAGS. It is customary for users to want to be able to specify CFLAGS and LDFLAGS (and CXXFLAGS and CPPFLAGS) at the command line, and we do want to do that in MacPorts.

When creating the dylib, we remove the "@" at the beginning of the line, because the "@" suppresses the display of the actual command that's run, but seeing the actual command that's run is essential to figuring out why something isn't working. We had to add $(LDFLAGS) to this linker invocation, since the LDFLAGS we provide at the command line are needed. We also added the -install_name argument, specifying the absolute path to the library's final install location; this is required for OS X libraries; without this, programs linking with the library will not be able to find it. We introduce a new variable PREFIX to support this, and another later change. A default value for PREFIX should probably be set earlier in the makefile, such as PREFIX=/usr/local or PREFIX=/opt/cryptlib.

We remove LDFLAGS="-object -s" from the Darwin section because this is archaic and does not work on recent versions of OS X.

We add an install target to install the software. Here again we use the PREFIX variable, and another new variable DESTDIR, which defaults to empty but which MacPorts uses to stage installations.

_______________________________________________
Cryptlib mailing list
[email protected] via Mail: [email protected]
Archive: ftp://ftp.franken.de/pub/crypt/cryptlib/archives/
http://news.gmane.org/gmane.comp.encryption.cryptlib
Posts from non-subscribed addresses are blocked to prevent spam, please
subscribe in order to post messages.
patch-makefile.diff (application/octet-stream, 1.8 KB)
--- makefile.orig	2014-10-01 01:38:46.000000000 -0500
+++ makefile	2014-12-13 17:48:33.000000000 -0600
@@ -90,7 +90,7 @@
 # Further cc flags are gathered dynamically at runtime via the ccopts.sh
 # script.
 
-CFLAGS		= -c -D__UNIX__ -DNDEBUG -I.
+CFLAGS		+= -c -D__UNIX__ -DNDEBUG -I.
 CFLAGS_DEBUG = -c -D__UNIX__ -I. -ggdb3 -fno-omit-frame-pointer -O0
 CFLAGS_ANALYSE = -c -D__UNIX__ -I.
 CFLAGS_COVERAGE = -c -D__UNIX__ -I. -ggdb3 -fno-omit-frame-pointer -O1 --coverage -fprofile-arcs -ftest-coverage
@@ -110,7 +110,6 @@
 SHARED_OBJ_DIR = ./shared-obj
 CPP			= $(CC) -E
 LD			= $(CC)
-LDFLAGS		=
 LDFLAGS_COVERAGE = -lgcov
 AR			= ar
 STRIP		= strip
@@ -1510,7 +1509,8 @@
 					$(STRIP) $(OBJS) $(EXTRAOBJS)
 
 $(DYLIBNAME):	$(OBJS) $(EXTRAOBJS) $(TESTOBJS)
-				@$(LD) -dynamiclib -compatibility_version $(MAJ).$(MIN) \
+				$(LD) $(LDFLAGS) -dynamiclib -install_name $(PREFIX)/lib/$(DYLIBNAME) \
+					-compatibility_version $(MAJ).$(MIN) \
 					-current_version $(MAJ).$(MIN).$(PLV) \
 					-o $(DYLIBNAME) $(OBJS) $(EXTRAOBJS)
 
@@ -1904,7 +1904,7 @@
 #			decide to try it.
 
 Darwin:
-	@make $(DEFINES) CFLAGS="$(CFLAGS) -fomit-frame-pointer" LDFLAGS="-object -s"
+	@make $(DEFINES) CFLAGS="$(CFLAGS) -fomit-frame-pointer"
 
 # MinGW: cc is gcc.  Note that we have to use the cross-compile flags
 # XCFLAGS rather than CFLAGS because the latter implies a native Unix
@@ -2905,3 +2905,12 @@
 	fi
 	@if [ `uname -s` = 'CYGWIN_NT-5.0' ] ; then rm -f *.exe; fi
 	@if [ `uname -s` = 'HP-UX' ] ; then rm -f lib$(PROJ).sl; fi
+
+
+install:
+	install -d $(DESTDIR)$(PREFIX)/lib
+	install -m 644 $(LIBNAME) $(DESTDIR)$(PREFIX)/lib
+	install -m 644 $(DYLIBNAME) $(DESTDIR)$(PREFIX)/lib
+	ln -s $(DYLIBNAME) $(DESTDIR)$(PREFIX)/lib/lib$(PROJ).dylib
+	install -d $(DESTDIR)$(PREFIX)/include
+	install -m 644 cryptlib.h $(DESTDIR)$(PREFIX)/include