summaryrefslogblamecommitdiffhomepage
path: root/auto/make
blob: cb03dbc2e748a22f37c5c9c80d19ea8ae4369634 (plain) (tree)
1
2
3
4
5
6
7
8
9
10




                                    
              



                              
                                





                           
                                                       


                                                          
                                        
 

                

                                       
 















                                            





                                          
                           




                                                            











                                                                 















                                                                      



                                                               




               

                                                                
  



                                     

                               
                                 

                                                                    
                         
                



                                






                      
                             
 
                             
 
                                               
 




                                                            
 
                       
 




                                                                          
 
                                          
                                                      

                                                    



                                                                        
                                                      





                                                                 






                                                                            

   














                                                                               
 
                                  


                         
                         











                                            

                    

                                      
                             
  
                           


                                                            


                      
                  
 

                           
                                                                 
                                            
                                                                     





                                                              
                    


                             



                                     

                               
                                        


                                             
                                 
                        



                                




    



                           
                                                   


                              









                                                                  

                                                                      
                                        











                                                             




                                           

                     
             
      
                                                     

   

# Copyright (C) Igor Sysoev
# Copyright (C) Valentin V. Bartenev
# Copyright (C) NGINX, Inc.

. auto/cc/deps

$echo "creating $NXT_MAKEFILE"

mkdir -p $NXT_BUILD_DIR/src \
         $NXT_BUILD_DIR/src/test


cat << END > $NXT_MAKEFILE

CC =			$CC

CFLAGS = 		$NXT_CFLAGS $NXT_CC_OPT $CFLAGS

NXT_EXEC_LINK =		$NXT_EXEC_LINK $NXT_LD_OPT
NXT_SHARED_LOCAL_LINK =	$NXT_SHARED_LOCAL_LINK $NXT_LD_OPT
NXT_MODULE_LINK =	$NXT_MODULE_LINK

all: $NXT_DAEMON

.PHONY: $NXT_DAEMON
$NXT_DAEMON: $NXT_BUILD_DIR/$NXT_DAEMON

END


# The include paths list.

$echo -n "NXT_LIB_INCS =" >> $NXT_MAKEFILE

for nxt_inc in src $NXT_BUILD_DIR
do
    $echo -n " -I $nxt_inc" >> $NXT_MAKEFILE
done

$echo >> $NXT_MAKEFILE
$echo >> $NXT_MAKEFILE


# Library object files list.

$echo "NXT_LIB_OBJS = \\" >> $NXT_MAKEFILE

for nxt_src in $NXT_LIB_SRCS
do
    nxt_obj=${nxt_src%.c}.o
    $echo "	$NXT_BUILD_DIR/$nxt_obj \\" >> $NXT_MAKEFILE
done

$echo >> $NXT_MAKEFILE

$echo "NXT_LIB_UNIT_OBJS = \\" >> $NXT_MAKEFILE
$echo "	$NXT_BUILD_DIR/src/nxt_lvlhsh.o \\" >> $NXT_MAKEFILE
$echo "	$NXT_BUILD_DIR/src/nxt_murmur_hash.o \\" >> $NXT_MAKEFILE

for nxt_src in $NXT_LIB_UNIT_SRCS
do
    nxt_obj=${nxt_src%.c}.o
    $echo "	$NXT_BUILD_DIR/$nxt_obj \\" >> $NXT_MAKEFILE
done

$echo >> $NXT_MAKEFILE


# Shared and static library.

cat << END >> $NXT_MAKEFILE

libnxt:	$NXT_BUILD_DIR/$NXT_LIB_SHARED $NXT_BUILD_DIR/$NXT_LIB_STATIC

$NXT_BUILD_DIR/$NXT_LIB_SHARED:	\$(NXT_LIB_OBJS)
	\$(NXT_SHARED_LOCAL_LINK) -o $NXT_BUILD_DIR/$NXT_LIB_SHARED \\
		\$(NXT_LIB_OBJS) \\
		$NXT_LIBM $NXT_LIBS $NXT_LIB_AUX_LIBS

$NXT_BUILD_DIR/$NXT_LIB_STATIC:	\$(NXT_LIB_OBJS)
	$NXT_STATIC_LINK $NXT_BUILD_DIR/$NXT_LIB_STATIC \\
		\$(NXT_LIB_OBJS)

$NXT_BUILD_DIR/$NXT_LIB_UNIT_STATIC:	\$(NXT_LIB_UNIT_OBJS)
	$NXT_STATIC_LINK $NXT_BUILD_DIR/$NXT_LIB_UNIT_STATIC \\
		\$(NXT_LIB_UNIT_OBJS)

END


# Object files.

for nxt_src in $NXT_LIB_SRCS $NXT_TEST_SRCS $NXT_LIB_UNIT_SRCS \
               src/test/nxt_unit_app_test.c
do
    nxt_obj=${nxt_src%.c}.o
    nxt_dep=${nxt_src%.c}.dep
    nxt_dep_flags=`nxt_gen_dep_flags`
    nxt_dep_post=`nxt_gen_dep_post`
    cat << END >> $NXT_MAKEFILE

$NXT_BUILD_DIR/$nxt_obj: $nxt_src
	\$(CC) -c \$(CFLAGS) \$(NXT_LIB_INCS) $NXT_LIB_AUX_CFLAGS \\
	-o $NXT_BUILD_DIR/$nxt_obj \\
	$nxt_dep_flags \\
	$nxt_src
	$nxt_dep_post

-include $NXT_BUILD_DIR/$nxt_dep

END

done

$echo >> $NXT_MAKEFILE


if [ $NXT_TESTS = YES ]; then

    # Test object files list.

    $echo "NXT_TEST_OBJS = \\" >> $NXT_MAKEFILE

    for nxt_src in $NXT_TEST_SRCS
    do
        nxt_obj=${nxt_src%.c}.o
        $echo "	$NXT_BUILD_DIR/$nxt_obj \\" >> $NXT_MAKEFILE
    done

    # Test executables.

    cat << END >> $NXT_MAKEFILE

.PHONY: tests
tests:		$NXT_BUILD_DIR/tests $NXT_BUILD_DIR/utf8_file_name_test \\
			$NXT_BUILD_DIR/unit_app_test

$NXT_BUILD_DIR/tests: \$(NXT_TEST_OBJS) \\
			$NXT_BUILD_DIR/$NXT_LIB_STATIC
	\$(NXT_EXEC_LINK) -o $NXT_BUILD_DIR/tests \\
		\$(CFLAGS) \$(NXT_TEST_OBJS) \\
		$NXT_BUILD_DIR/$NXT_LIB_STATIC \\
		$NXT_LD_OPT $NXT_LIBM $NXT_LIBS $NXT_LIB_AUX_LIBS

$NXT_BUILD_DIR/utf8_file_name_test: $NXT_LIB_UTF8_FILE_NAME_TEST_SRCS \\
			$NXT_BUILD_DIR/$NXT_LIB_STATIC
	\$(CC) \$(CFLAGS) \$(NXT_LIB_INCS) $NXT_LIB_AUX_CFLAGS \\
		-o $NXT_BUILD_DIR/utf8_file_name_test \\
		$NXT_LIB_UTF8_FILE_NAME_TEST_SRCS \\
		$NXT_BUILD_DIR/$NXT_LIB_STATIC \\
		$NXT_LD_OPT $NXT_LIBM $NXT_LIBS

$NXT_BUILD_DIR/unit_app_test: $NXT_BUILD_DIR/src/test/nxt_unit_app_test.o \\
		$NXT_BUILD_DIR/$NXT_LIB_UNIT_STATIC
	\$(NXT_EXEC_LINK) -o $NXT_BUILD_DIR/unit_app_test \\
		\$(CFLAGS) $NXT_BUILD_DIR/src/test/nxt_unit_app_test.o \\
		$NXT_BUILD_DIR/$NXT_LIB_UNIT_STATIC \\
		$NXT_LD_OPT $NXT_LIBM $NXT_LIBS $NXT_LIB_AUX_LIBS

END

else

    cat << END >> $NXT_MAKEFILE

.PHONY: tests
tests:
	@(echo; \\
	  echo "error: to make tests you need to configure --tests option."; \\
	  echo; \\
	  exit 1)

END

fi


NXT_MAKE_INCS="src $NXT_BUILD_DIR"
NXT_MAKE_SRCS="$NXT_SRCS"


# The include paths list.

$echo -n "NXT_INCS =" >> $NXT_MAKEFILE

for nxt_inc in $NXT_MAKE_INCS
do
    $echo -n " -I $nxt_inc" >> $NXT_MAKEFILE
done

$echo >> $NXT_MAKEFILE
$echo >> $NXT_MAKEFILE


# Object files list.

$echo "NXT_OBJS = \\" >> $NXT_MAKEFILE

for nxt_src in $NXT_MAKE_SRCS
do
    nxt_obj=${nxt_src%.c}.o
    $echo "	$NXT_BUILD_DIR/$nxt_obj \\" >> $NXT_MAKEFILE
done

$echo >> $NXT_MAKEFILE


# unit executable.

cat << END >> $NXT_MAKEFILE

$NXT_BUILD_DIR/$NXT_DAEMON:	$NXT_BUILD_DIR/$NXT_LIB_STATIC \\
				\$(NXT_OBJS)
	\$(NXT_EXEC_LINK) -o $NXT_BUILD_DIR/$NXT_DAEMON \$(CFLAGS) \\
		\$(NXT_OBJS) $NXT_BUILD_DIR/$NXT_LIB_STATIC \\
		$NXT_LIBM $NXT_LIBS $NXT_LIB_AUX_LIBS

END


# unit object files.

for nxt_src in $NXT_MAKE_SRCS
do
    nxt_obj=${nxt_src%.c}.o
    nxt_dep=${nxt_src%.c}.dep
    nxt_dep_flags=`nxt_gen_dep_flags`
    nxt_dep_post=`nxt_gen_dep_post`
    cat << END >> $NXT_MAKEFILE

$NXT_BUILD_DIR/$nxt_obj:	$nxt_src
	\$(CC) -c \$(CFLAGS) \$(NXT_INCS) \\
		$NXT_LIB_AUX_CFLAGS \\
		-o $NXT_BUILD_DIR/$nxt_obj \\
		$nxt_dep_flags \\
		$nxt_src
	$nxt_dep_post

-include $NXT_BUILD_DIR/$nxt_dep

END

done


# install

cat << END >> $NXT_MAKEFILE

.PHONY: install ${NXT_DAEMON}-install install-check

install: ${NXT_DAEMON}-install

install-check:
	@test -n "\$(DESTDIR)$NXT_PREFIX" \\
	|| (echo; \\
	    echo "error: to make install you need either"; \\
	    echo "    to configure --prefix option"; \\
	    echo "    or to set DESTDIR environment variable."; \\
	    echo; \\
	    exit 1)

${NXT_DAEMON}-install: $NXT_DAEMON install-check
	install -d \$(DESTDIR)$NXT_SBINDIR
	install -p $NXT_BUILD_DIR/$NXT_DAEMON \$(DESTDIR)$NXT_SBINDIR/
	install -d \$(DESTDIR)$NXT_STATE


.PHONY: uninstall ${NXT_DAEMON}-uninstall

uninstall: ${NXT_DAEMON}-uninstall

${NXT_DAEMON}-uninstall:
	rm -f \$(DESTDIR)$NXT_SBINDIR/$NXT_DAEMON
	@rmdir -p \$(DESTDIR)$NXT_SBINDIR 2>/dev/null || true

END

# Makefile.
# *.dSYM is MacOSX Clang debug information.

cat << END > Makefile

include $NXT_MAKEFILE

.PHONY: clean
clean:
		rm -rf $NXT_BUILD_DIR *.dSYM Makefile

END