Fix for makefiles and samples cleanup SAMPLES_BRANCH
authorElio Maldonado <emaldona@redhat.com>
Sun, 04 Jan 2015 09:15:26 -0800
branchSAMPLES_BRANCH
changeset 11327 98ad09b8346fbafb12e4530ca736262fd2f68d56
parent 11326 9c25253f6d3ce33ac1d8a951dd8f1cf3c7b33ade
child 11328 bfbf07547f7a466fa46fc2abcd81165d4a203810
push id533
push useremaldona@redhat.com
push dateSun, 04 Jan 2015 18:22:47 +0000
Fix for makefiles and samples cleanup - Fix comments on howto deal with case where pkg-config can't be used - Cleanup withespace for samples 2 and 6
Makefile
samples/sample1/Makefile
samples/sample2/Makefile
samples/sample2/sample2.c
samples/sample2/util.c
samples/sample3/Makefile
samples/sample4/Makefile
samples/sample4/sample4.c
samples/sample5/Makefile
samples/sample6/Makefile
samples/sample6/sample6.c
samples/utils/Makefile
--- a/Makefile
+++ b/Makefile
@@ -39,19 +39,19 @@ include $(CORE_DEPTH)/coreconf/rules.mk
 #######################################################################
 
 
 
 #######################################################################
 # (7) Execute "local" rules. (OPTIONAL).                              #
 #######################################################################
 
-nss_build_all: build_nspr all
+nss_build_all: build_nspr all build_samples
 
-nss_clean_all: clobber_nspr clobber
+nss_clean_all: clobber_nspr clobber build_samples
 
 NSPR_CONFIG_STATUS = $(CORE_DEPTH)/../nspr/$(OBJDIR_NAME)/config.status
 NSPR_CONFIGURE = $(CORE_DEPTH)/../nspr/configure
 
 #
 # Translate coreconf build options to NSPR configure options.
 #
 
--- a/samples/sample1/Makefile
+++ b/samples/sample1/Makefile
@@ -1,15 +1,22 @@
-# In some platforms we can't count on pkg-config, on those case
-# invoke make with
-# export LD_LIBARY_PATH=path_to_nss_shared_libraries; make DONT_USE_PKG_CONFIG=1 all
+# In some platforms we can't count on pkg-config, due to nss and nspr not being
+# installed in the system, on those cases invoke make with
+# export LD_LIBARY_PATH=$PATH_TO_NSS_SHARED_LIBS \
+# export PATH=$PATH:${LD_LIBARY_PATH}/../bin \
+# make DONT_USE_PKG_CONFIG=1 all
+
 ifdef DONT_USE_PKG_CONFIG
 # Change this to where you have the nspr/nss headers
 INCLUDES = -I/usr/include/nspr4 -I/usr/include/nss3
-LIBS = -lnspr4 -lc -lnss3 -lnssutil3 -lsmime3 -lplc4
+# For example:
+#NSPR_INC_DIR = /home/emaldona/work4nss/upstream/checkout-samples-branch/dist/Linux3.17_x86_64_glibc_PTH_64_DBG.OBJ/include
+#NSS_INC_DIR = home/emaldona/work4nss/upstream/checkout-samples-branch/dist/includes/nss
+#INCLUDES = -I${NSPR_INC_DIR} -I${NSS_INC_DIR}
+LIBS = -lnspr4 -lc -lnss3 -lnssutil3 -lsmime3 -lplc4 -L${LD_LIBRARY_PATH}
 else
 INCLUDES = `pkg-config --cflags nss`
 LIBS = `pkg-config --libs nss`
 endif
 
 all: sample1
 
 clean:
--- a/samples/sample2/Makefile
+++ b/samples/sample2/Makefile
@@ -1,15 +1,22 @@
-# In some platforms we can't count on pkg-config, on those case
-# invoke make with
-# export LD_LIBARY_PATH=path_to_nss_shared_libraries; make DONT_USE_PKG_CONFIG=1 all
+# In some platforms we can't count on pkg-config, due to nss and nspr not being
+# installed in the system, on those cases invoke make with
+# export LD_LIBARY_PATH=$PATH_TO_NSS_SHARED_LIBS \
+# export PATH=$PATH:${LD_LIBARY_PATH}/../bin \
+# make DONT_USE_PKG_CONFIG=1 all
+
 ifdef DONT_USE_PKG_CONFIG
 # Change this to where you have the nspr/nss headers
 INCLUDES = -I/usr/include/nspr4 -I/usr/include/nss3
-LIBS = -lnspr4 -lc -lnss3 -lnssutil3 -lsmime3 -lplc4
+# For example:
+#NSPR_INC_DIR = /home/emaldona/work4nss/upstream/checkout-samples-branch/dist/Linux3.17_x86_64_glibc_PTH_64_DBG.OBJ/include
+#NSS_INC_DIR = home/emaldona/work4nss/upstream/checkout-samples-branch/dist/includes/nss
+#INCLUDES = -I${NSPR_INC_DIR} -I${NSS_INC_DIR}
+LIBS = -lnspr4 -lc -lnss3 -lnssutil3 -lsmime3 -lplc4 -L${LD_LIBRARY_PATH}
 else
 INCLUDES = `pkg-config --cflags nss`
 LIBS = `pkg-config --libs nss`
 endif
 
 all: sample2
 
 clean: remove-sample2 remove-nssdb
--- a/samples/sample2/sample2.c
+++ b/samples/sample2/sample2.c
@@ -95,17 +95,17 @@ InitSlotPassword(PK11SlotInfo *slot, PRB
    return p0;
 }
        
 /*
  * ChangePW
  */
 SECStatus
 ChangePW(PK11SlotInfo *slot, char *oldPass, char *newPass,
-                      char *oldPwFile, char *newPwFile)
+         char *oldPwFile, char *newPwFile)
 {
     SECStatus rv;
     secuPWData pwdata;
     secuPWData newpwdata;
     char      *oldpw = NULL;
     char      *newpw = NULL;
 
     if (oldPass) {
--- a/samples/sample2/util.c
+++ b/samples/sample2/util.c
@@ -60,17 +60,17 @@ PRBool CheckPassword(char *cp)
    }
    return PR_FALSE;
 }
 
 /*
  * GetPassword
  */
 char* GetPassword(FILE *input, FILE *output, char *prompt,
-                                PRBool (*ok)(char *))
+                  PRBool (*ok)(char *))
 {
     char phrase[200] = {'\0'};
     int infd         = fileno(input);
     int isTTY        = isatty(infd);
 
     for (;;) {
         /* Prompt for password */
         if (isTTY) {
--- a/samples/sample3/Makefile
+++ b/samples/sample3/Makefile
@@ -1,15 +1,22 @@
-# In some platforms we can't count on pkg-config, on those case
-# invoke make with
-# export LD_LIBARY_PATH=path_to_nss_shared_libraries; make DONT_USE_PKG_CONFIG=1 all
+# In some platforms we can't count on pkg-config, due to nss and nspr not being
+# installed in the system, on those cases invoke make with
+# export LD_LIBARY_PATH=$PATH_TO_NSS_SHARED_LIBS \
+# export PATH=$PATH:${LD_LIBARY_PATH}/../bin \
+# make DONT_USE_PKG_CONFIG=1 all
+
 ifdef DONT_USE_PKG_CONFIG
 # Change this to where you have the nspr/nss headers
 INCLUDES = -I/usr/include/nspr4 -I/usr/include/nss3
-LIBS = -lnspr4 -lc -lnss3 -lnssutil3 -lsmime3 -lplc4
+# For example:
+#NSPR_INC_DIR = /home/emaldona/work4nss/upstream/checkout-samples-branch/dist/Linux3.17_x86_64_glibc_PTH_64_DBG.OBJ/include
+#NSS_INC_DIR = home/emaldona/work4nss/upstream/checkout-samples-branch/dist/includes/nss
+#INCLUDES = -I${NSPR_INC_DIR} -I${NSS_INC_DIR}
+LIBS = -lnspr4 -lc -lnss3 -lnssutil3 -lsmime3 -lplc4 -L${LD_LIBRARY_PATH}
 else
 INCLUDES = `pkg-config --cflags nss`
 LIBS = `pkg-config --libs nss`
 endif
 
 all: sample3
 
 clean: remove-sample3 remove-nssdb remove-noise remove-intermediates
--- a/samples/sample4/Makefile
+++ b/samples/sample4/Makefile
@@ -1,15 +1,22 @@
-# In some platforms we can't count on pkg-config, on those case
-# invoke make with
-# export LD_LIBARY_PATH=path_to_nss_shared_libraries; make DONT_USE_PKG_CONFIG=1 all
+# In some platforms we can't count on pkg-config, due to nss and nspr not being
+# installed in the system, on those cases invoke make with
+# export LD_LIBARY_PATH=$PATH_TO_NSS_SHARED_LIBS \
+# export PATH=$PATH:${LD_LIBARY_PATH}/../bin \
+# make DONT_USE_PKG_CONFIG=1 all
+
 ifdef DONT_USE_PKG_CONFIG
 # Change this to where you have the nspr/nss headers
 INCLUDES = -I/usr/include/nspr4 -I/usr/include/nss3
-LIBS = -lnspr4 -lc -lnss3 -lnssutil3 -lsmime3 -lplc4
+# For example:
+#NSPR_INC_DIR = /home/emaldona/work4nss/upstream/checkout-samples-branch/dist/Linux3.17_x86_64_glibc_PTH_64_DBG.OBJ/include
+#NSS_INC_DIR = home/emaldona/work4nss/upstream/checkout-samples-branch/dist/includes/nss
+#INCLUDES = -I${NSPR_INC_DIR} -I${NSS_INC_DIR}
+LIBS = -lnspr4 -lc -lnss3 -lnssutil3 -lsmime3 -lplc4 -L${LD_LIBRARY_PATH}
 else
 INCLUDES = `pkg-config --cflags nss`
 LIBS = `pkg-config --libs nss`
 endif
 
 all: sample4
 
 clean: remove-sample4 remove-nssdb remove-noise remove-intermediates
--- a/samples/sample4/sample4.c
+++ b/samples/sample4/sample4.c
@@ -698,19 +698,19 @@ cleanup:
     return rv;
 }
 
 /*
  * Gets IV, Key label, wrapped AES key and wrapped MAC key
  */
 SECStatus
 GetParametersFromHeader(const char *cipherFileName, SECItem *keyLabelItem,
-            SECItem *ivItem, SECItem *wrappedEncKeyItem, SECItem *wrappedMacKeyItem)
+        SECItem *ivItem, SECItem *wrappedEncKeyItem, SECItem *wrappedMacKeyItem)
 {
-    SECStatus      rv;
+    SECStatus rv;
 
     /* open intermediate file, read in header, get IV, Key label,
      * wrapped AES key and wrapped MAC key from it
      */
     rv = ReadFromHeaderFile(cipherFileName, IV, ivItem, PR_TRUE);
     if (rv != SECSuccess) {
         PR_fprintf(PR_STDERR, "Could not retrieve IV from cipher file\n");
         goto cleanup;
@@ -1406,18 +1406,18 @@ main(int argc, char **argv)
             rv = PK11_Authenticate(slot, PR_TRUE, &pwdata);
             if (rv != SECSuccess) {
                 PR_fprintf(PR_STDERR, "Could not authenticate to token %s.\n",
                            PK11_GetTokenName(slot));
                 goto cleanup;
             }
         }
         rv = EncryptFile(slot, dbdir,
-                          inFileName, headerFileName, encryptedFileName,
-                          noiseFileName, &pwdata, ascii, keyLabel);
+                         inFileName, headerFileName, encryptedFileName,
+                         noiseFileName, &pwdata, ascii, keyLabel);
         if (rv != SECSuccess) {
             PR_fprintf(PR_STDERR, "EncryptFile : Failed\n");
             return SECFailure;
         }
         break;
     case DECRYPT:
         /* Open DB read only, authenticate to it */
         PK11_SetPasswordFunc(GetModulePassword);
--- a/samples/sample5/Makefile
+++ b/samples/sample5/Makefile
@@ -1,15 +1,22 @@
-# In some platforms we can't count on pkg-config, on those case
-# invoke make with
-# export LD_LIBARY_PATH=path_to_nss_shared_libraries; make DONT_USE_PKG_CONFIG=1 all
+# In some platforms we can't count on pkg-config, due to nss and nspr not being
+# installed in the system, on those cases invoke make with
+# export LD_LIBARY_PATH=$PATH_TO_NSS_SHARED_LIBS \
+# export PATH=$PATH:${LD_LIBARY_PATH}/../bin \
+# make DONT_USE_PKG_CONFIG=1 all
+
 ifdef DONT_USE_PKG_CONFIG
 # Change this to where you have the nspr/nss headers
 INCLUDES = -I/usr/include/nspr4 -I/usr/include/nss3
-LIBS = -lnspr4 -lc -lnss3 -lnssutil3 -lsmime3 -lplc4
+# For example:
+#NSPR_INC_DIR = /home/emaldona/work4nss/upstream/checkout-samples-branch/dist/Linux3.17_x86_64_glibc_PTH_64_DBG.OBJ/include
+#NSS_INC_DIR = home/emaldona/work4nss/upstream/checkout-samples-branch/dist/includes/nss
+#INCLUDES = -I${NSPR_INC_DIR} -I${NSS_INC_DIR}
+LIBS = -lnspr4 -lc -lnss3 -lnssutil3 -lsmime3 -lplc4 -L${LD_LIBRARY_PATH}
 else
 INCLUDES = `pkg-config --cflags nss`
 LIBS = `pkg-config --libs nss`
 endif
 
 all: sample5
 
 clean: remove-sample5 remove-nssdb remove-temp-files
--- a/samples/sample6/Makefile
+++ b/samples/sample6/Makefile
@@ -1,15 +1,22 @@
-# In some platforms we can't count on pkg-config, on those case
-# invoke make with
-# export LD_LIBARY_PATH=path_to_nss_shared_libraries; make DONT_USE_PKG_CONFIG=1 all
+# In some platforms we can't count on pkg-config, due to nss and nspr not being
+# installed in the system, on those cases invoke make with
+# export LD_LIBARY_PATH=$PATH_TO_NSS_SHARED_LIBS \
+# export PATH=$PATH:${LD_LIBARY_PATH}/../bin \
+# make DONT_USE_PKG_CONFIG=1 all
+
 ifdef DONT_USE_PKG_CONFIG
 # Change this to where you have the nspr/nss headers
 INCLUDES = -I/usr/include/nspr4 -I/usr/include/nss3
-LIBS = -lnspr4 -lc -lnss3 -lnssutil3 -lsmime3 -lplc4
+# For example:
+#NSPR_INC_DIR = /home/emaldona/work4nss/upstream/checkout-samples-branch/dist/Linux3.17_x86_64_glibc_PTH_64_DBG.OBJ/include
+#NSS_INC_DIR = home/emaldona/work4nss/upstream/checkout-samples-branch/dist/includes/nss
+#INCLUDES = -I${NSPR_INC_DIR} -I${NSS_INC_DIR}
+LIBS = -lnspr4 -lc -lnss3 -lnssutil3 -lsmime3 -lplc4 -L${LD_LIBRARY_PATH}
 else
 INCLUDES = `pkg-config --cflags nss`
 LIBS = `pkg-config --libs nss`
 endif
 
 all: sample6
 
 clean: remove-sample6 remove-alice remove-bob remove-temp-files
--- a/samples/sample6/sample6.c
+++ b/samples/sample6/sample6.c
@@ -802,18 +802,18 @@ cleanup:
     }
     return certReq;
 }
 
 /*
  * Sign Cert
  */
 static SECItem *
-SignCert(CERTCertDBHandle *handle, CERTCertificate *cert, PRBool selfsign,
-         SECOidTag hashAlgTag,
+SignCert(CERTCertDBHandle *handle, CERTCertificate *cert, 
+         PRBool selfsign, SECOidTag hashAlgTag,
          SECKEYPrivateKey *privKey, char *issuerNickName, void *pwarg)
 {
     SECItem der;
     SECStatus rv;
     SECOidTag algID;
     void *dummy;
     PRArenaPool *arena             = NULL;
     SECItem *result                = NULL;
@@ -936,18 +936,19 @@ cleanup:
     }
     return cert;
 }
 
 /*
  * Add a certificate to the nss database
  */
 SECStatus
-AddCert(PK11SlotInfo *slot, CERTCertDBHandle *handle, const char *name, char *trusts,
-        char *inFileName, PRBool ascii, PRBool emailcert, void *pwdata)
+AddCert(PK11SlotInfo *slot, CERTCertDBHandle *handle,
+        const char *name, char *trusts, char *inFileName,
+        PRBool ascii, PRBool emailcert, void *pwdata)
 {
     SECItem         certDER;
     SECStatus       rv;
     CERTCertTrust   *trust = NULL;
     CERTCertificate *cert = NULL;
 
     certDER.data = NULL;
 
--- a/samples/utils/Makefile
+++ b/samples/utils/Makefile
@@ -1,19 +1,9 @@
-# In some platforms we can't count on pkg-config, on those case
-# invoke make with
-# export LD_LIBARY_PATH=path_to_nss_shared_libraries; make DONT_USE_PKG_CONFIG=1 all
-ifdef DONT_USE_PKG_CONFIG
-# Change this to where you have the nspr/nss headers
-INCLUDES = -I/usr/include/nspr4 -I/usr/include/nss3
-LIBS = -lnspr4 -lc -lnss3 -lnssutil3 -lsmime3 -lplc4
-else
-INCLUDES = `pkg-config --cflags nss`
-LIBS = `pkg-config --libs nss`
-endif
+include ../common.mk
 
 all: libutils.a
 	echo "all done"
 
 libutils.a: util.c
 	gcc -Werror -Wfatal-errors -g -c $^ -o util.o \
 	$(INCLUDES) $(LIBS)
 	ar -cvq libutils.a util.o