Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have some files in a folder source. I want to process them using program program and output them into folder target just by typing

$ make

How should I write a makefile for this?

Directory tree:

/ 
   Makefile 
   program
   /source
      foo.x
      bar.x
      spam.x
   /target
      foo.y
      bar.y
      spam.y
share|improve this question
    
This might be helpful –  sr_ Feb 7 '12 at 10:03
add comment

1 Answer 1

up vote 3 down vote accepted

Something like this:

SOURCES := $(wildcard source/*)
TARGETS := $(patsubst source/%.x, target/%.y, $(SOURCES))

all: $(TARGETS)

target/%.y: source/%.x
    program -i $< -o $@
share|improve this answer
    
works like a charm! :) –  Pratik Deoghare Feb 7 '12 at 11:58
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.