Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .SECONDEXPANSION:
- .PHONY: all clean
- OUT = out
- SRC_all = 1.c in/2.cc
- OBJ_all = $(SRC_all:%=$(OUT)/%.o)
- OBJ += $(OBJ_all)
- all: $(OBJ_all)
- clean:
- rm -rf $(OUT)
- $(OBJ): $(OUT)/%.o: % | $$(@D)/
- %/:
- mkdir -p $@
- %.c.o:
- @touch $@
- @echo gcc -o $@ $+
- %.cc.o:
- @touch $@
- @echo g++ -o $@ $+
- ### krd@ntbk:~/tmp/test$ find . -printf '%P\n' | xargs -r ls -lhd
- ### -rw-r--r-- 1 krd krd 0 Feb 11 12:33 1.c
- ### -rw-rw-rw- 1 krd krd 331 Feb 11 17:14 Makefile
- ### drwxr-xr-x 2 krd krd 60 Feb 11 17:14 in
- ### -rw-r--r-- 1 krd krd 0 Feb 11 12:33 in/2.cc
- ###
- ### krd@ntbk:~/tmp/test$ make
- ### mkdir -p out/
- ### gcc -o out/1.c.o 1.c
- ### mkdir -p out/in/
- ### g++ -o out/in/2.cc.o in/2.cc
- ###
- ### krd@ntbk:~/tmp/test$ find . -printf '%P\n' | xargs -r ls -lhd
- ### -rw-r--r-- 1 krd krd 0 Feb 11 12:33 1.c
- ### -rw-rw-rw- 1 krd krd 331 Feb 11 17:14 Makefile
- ### drwxr-xr-x 2 krd krd 60 Feb 11 17:14 in
- ### -rw-r--r-- 1 krd krd 0 Feb 11 12:33 in/2.cc
- ### drwxr-xr-x 3 krd krd 80 Feb 11 17:15 out
- ### -rw-r--r-- 1 krd krd 0 Feb 11 17:15 out/1.c.o
- ### drwxr-xr-x 2 krd krd 60 Feb 11 17:15 out/in
- ### -rw-r--r-- 1 krd krd 0 Feb 11 17:15 out/in/2.cc.o
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement