// @(#) 1.2 nt/src/samples/NMakCpkg.cpp, odsamples, od96nt, odnt9712d 10/24/96 09:57:55 [ 3/21/97 17:38:14 ]
/*====START_GENERATED_PROLOG======================================
 */
/*
 *   COMPONENT_NAME: odsamples
 *
 *   CLASSES: none
 *
 *   ORIGINS: 27
 *
 *
 *   (C) COPYRIGHT International Business Machines Corp. 1995,1996
 *   All Rights Reserved
 *   Licensed Materials - Property of IBM
 *   US Government Users Restricted Rights - Use, duplication or
 *   disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
 *
 *   IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 *   ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 *   PURPOSE. IN NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR
 *   CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
 *   USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
 *   OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
 *   OR PERFORMANCE OF THIS SOFTWARE.
 */
/*====END_GENERATED_PROLOG========================================
 */

// On windows 95, doing this logic as code, instead of in a .bat file, 
// appears to be the only way we can return a non-zero return code to
// nmake to indicate there is a problem and the make rule should not
// continue.

#include <iostream.h>
#include <string.h>
#include <io.h>

int main (int argc, char *argv[])
{

	if (argc > 2) {
		char* sourcedir = argv[1];
		size_t sourcedirlen = strlen(sourcedir);
		char* buffer = NULL;

		for ( int i = 2; i < argc; i++ ) {
			buffer = new char[sourcedirlen + strlen(argv[i]) + 2];
			strcpy(buffer, sourcedir);
			strcat(buffer, "\\");
			strcat(buffer, argv[i]);
			if ( access(buffer,00) == -1 ) {

				cout << "ERROR:  " << buffer << " does not exist." << endl;
				cout << "Package can not be built." << endl << endl;
				delete buffer;
				return 1;
			}
			delete buffer;
		}
	}
	return 0;
}
