#* --------------------------------------------------------------------*/
#*    Copyright (c) 1992-1998 by Manuel Serrano. All rights reserved.  */
#*                                                                     */
#*                                     ,--^,                           */
#*                               _ ___/ /|/                            */
#*                           ,;'( )__, ) '                             */
#*                          ;;  //   L__.                              */
#*                          '   \   /  '                               */
#*                               ^   ^                                 */
#*                                                                     */
#*                                                                     */
#*    This program is distributed in the hope that it will be useful.  */
#*    Use and copying of this software and preparation of derivative   */
#*    works based upon this software are permitted, so long as the     */
#*    following conditions are met:                                    */
#*           o credit to the authors is acknowledged following         */
#*             current academic behaviour                              */
#*           o no fees or compensation are charged for use, copies,    */
#*             or access to this software                              */
#*           o this copyright notice is included intact.               */
#*      This software is made available AS IS, and no warranty is made */
#*      about the software or its performance.                         */
#*                                                                     */
#*      Bug descriptions, use reports, comments or suggestions are     */
#*      welcome. Send them to                                          */
#*        Manuel Serrano -- Manuel.Serrano@unice.fr                    */
#*-------------------------------------------------------------------- */
#*=====================================================================*/
#*    serrano/prgm/project/bigloo/tools/Makefile                       */
#*    -------------------------------------------------------------    */
#*    Author      :  Manuel Serrano                                    */
#*    Creation    :  Tue Jan 30 15:19:19 1996                          */
#*    Last change :  Thu Mar 26 10:45:15 1998 (serrano)                */
#*    -------------------------------------------------------------    */
#*    The makefile to build args                                       */
#*=====================================================================*/

#*---------------------------------------------------------------------*/
#*    flags                                                            */
#*---------------------------------------------------------------------*/
BIN		= ../bin
BIGLOO		= $(BIN)/bigloo
BGLOPTFLAGS	= -O +rm
BFLAGS		= $(BGLOPTFLAGS)
CC 		= gcc
CFLAGS		= -g
LDFLAGS		= 
LICENSE		= ../LICENSE

#*---------------------------------------------------------------------*/
#*    Objects and sources                                              */
#*---------------------------------------------------------------------*/
C_FILE	= copyright if_mach if_not_there libcversion

C_OBJ		= $(C_FILE:%=%.o)
C_SRC		= $(C_OBJ:%.o=%.c)

#*---------------------------------------------------------------------*/
#*    All objects and sources                                          */
#*---------------------------------------------------------------------*/
OBJ		= $(C_OBJ) $(SCM_OBJ)
SRC		= $(C_SRC) $(SCM_SRC)

POPULATION	= $(SRC) Makefile

#*---------------------------------------------------------------------*/
#*    the goals.                                                       */
#*---------------------------------------------------------------------*/
pop:
	@ echo $(POPULATION:%=tools/%)

clean:
	@- rm -f license.c license.o
	@ find . \( -name '*[~%]'                   \
                       -o -name '.??*[~%]'          \
                       -o -name '#*#'               \
                       -o -name '?*#'               \
                       -o -name \*core \)           \
                     -type f -exec rm {} \;   
	@- \rm -f $(OBJ)
	@- \rm -f $(DEST) 

#*---------------------------------------------------------------------*/
#*    distrib                                                          */
#*---------------------------------------------------------------------*/
distrib:
	@ if [ `pwd` = $$HOME/prgm/project/bigloo/tools ]; then      \
             echo "*** ERROR:Illegal dir to make a distrib `pwd`";   \
             exit 1;                                                 \
          fi
	@ $(MAKE) clean
	@ $(BIN)/copyright $(POPULATION)

#*---------------------------------------------------------------------*/
#*    $(BIN)/copyright                                                 */
#*---------------------------------------------------------------------*/
.PHONY: copyright
copyright: $(BIN)/copyright

$(BIN)/copyright: copyright.o license.o
	@ $(CC) -o $(BIN)/copyright $(CFLAGS) copyright.o license.o

$(BIN)/libcversion: libcversion.o
	@ $(CC) -o $(BIN)/libcversion $(CFLAGS) libcversion.o

license.c: $(LICENSE)
	@- rm -f $@
	@ echo "/* Automatically generated file (don't edit) */" > $@
	@ echo "char *license() {" >> $@
	@ echo " return \" `cat ../LICENSE` \";" >> $@
	@ echo "}" >> $@

#*---------------------------------------------------------------------*/
#*    Suffixes                                                         */
#*---------------------------------------------------------------------*/
.SUFFIXES:
.SUFFIXES: .c .o

#*---------------------------------------------------------------------*/
#*    .c.o                                                             */
#*---------------------------------------------------------------------*/
.c.o:
	@ echo $*.c:
	@ $(CC) -c $(CFLAGS) $*.c -o $*.o

