Makefile target with wildcard to create symlink using target string

Colin

I'd like a set of makefile rules that create a symlink to one of several code modules before building the project. The name of the make target would determine the file to which the symlink points. For example:

  • The user invokes 'make R3000'
  • Make sees that 'data.asm' doesn't exist yet, so a symlink is created from 'data_R3000.asm' to 'data.asm'
  • The build process continues, using data.asm

How can I set up make rules to do this?

MadScientist

Maybe something like:

MODULES := $(patsubst data_%.asm,%,$(wildcard data_*.asm))

all:
    ...

data.asm:
        [ -n "$(filter $(MAKECMDGOALS),$(MODULES))" ] || { echo unknown module: $(MAKECMDGOALS) ; exit 1; }
        ln -s $(filter $(MAKECMDGOALS),$(MODULES)) $@

Then make sure data.asm is listed as a prerequisite in the appropriate rules.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Using ~ in symlink target or making a symlink with a variable

From Dev

Makefile target-based dependencies with a wildcard (compact)

From Dev

Is there a way to create a symlink to a non-existent target?

From Dev

How to read the target of a symlink in android using java

From Dev

How to read the target of a symlink in android using java

From Dev

copying a symlink to a target file using cp -t

From Dev

list files by symlink target

From Dev

Symlink Source Target confusion

From Dev

Makefile target references Makefile

From Dev

How to create a symlink which opens (literally) the target file

From Dev

How to create a symlink which opens (literally) the target file

From Dev

Makefile rule not a target when using eval

From Dev

Make command using default target name 'Makefile'

From Dev

Using a result of shell's find as a target in a Makefile

From Dev

Read target of symlink and increment target by one

From Dev

NTFS symlink not syncing to target folder

From Dev

Go to directory of symlink file target

From Dev

Change target of symlink without deletion

From Dev

Makefile set variable in target

From Dev

Alias target name in Makefile

From Dev

Makefile generic target rule

From Dev

Target name in Makefile prerequisite

From Dev

Dynamic Makefile target

From Dev

Makefile target color output

From Dev

Directory independent target in Makefile

From Dev

Makefile remaking directory target

From Dev

Makefile Automatic Target Generation

From Dev

Directory independent target in Makefile

From Dev

Replace characters in Makefile target