to decide static or dynamic



  • Dear friends: I am creating a makefile.
    Sometimes I can not execute dynamically and sometimes statically. So I want something like following but I do not know how to check in GNU.

    #makefile 
         cc = g++
         CFLAGS= -c -g -Wall -O3 -I. -DUNIX 
         if (glibc-static c library exits in operating system), then 
         CFLAGS1= -O3 -I. -DUNIX -static
       else 
         CFLAGS1= -O3 -I. -DUNIX 
        PROG = myprogram
        OBJS = file1.o file2.o 
        $(cc) $(CFLAGS1) -o   $(PROG) $(OBJS)    
      file1.o: file1.cpp file1.h 
    		$(cc) $(CFLAGS) file1.cpp file1.h 
      file2.o: file2.cpp file2.h 
    		$(cc) $(CFLAGS) file2.cpp file2.h 
    PHONY: clean
    clean: 	 
    		rm $(OBJS)
    

    I do not know how to check this in GNU make. Can anyone write me the codes for the following macro code for GNU make ?

    CFLAGS= -c -g -Wall -O3 -I. -DUNIX
         if (glibc-static c library exits in operating system), then
         CFLAGS1= -O3 -I. -DUNIX -static
    else
         CFLAGS1= -O3 -I. -DUNIX
    

    I would be very thankful



  • perhaps(?) compile and link a test.cpp with static lib, show if it worked, and call your makefile recursively with the new information.


Anmelden zum Antworten