Thanks Philip,

I want to compile objects in order of the writting: y.o z.o x.o .
The order of compiling x.o are different in below three cases.
I don't understand the difference. 


x : y.o z.o x.o  # compiles x.o last
        $(CC) $^ -o $@  # with recipe


x : y.o z.o      # compiles x.o last


x : y.o z.o x.o  # compiles x.o first


My purpose is to keep my Makefile simple. With the patsubst function in 
Makefile, I just put Makefile with my source files and need to do nothing.
It just compiles. But this is gone if the order of compiling matters.


x : $(patsubst %.c,%.o,$(wildcard *.c))




Thanks


---


# My Minimal Makefile for C, C++
# build shared library with -fPIC, -shared
CFLAGS   = -Wall -Wextra -g # -O3 -fPIC  # CXXFLAGS for .cpp
LDFLAGS  = # -L../hello # -shared
LDLIBS   = # -lhello
CPPFLAGS = -MMD -MP # -I../hello
#CC      = $(CXX)  # link with CXX for .cpp


# target name is basename of one of the source files
main : $(patsubst %.c,%.o,$(wildcard *.c))  # .cpp
-include *.d
clean : ; -rm -fr *.o *.d
.PHONY : clean

Reply via email to