Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7740247
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T08:43:44+00:00 2026-06-01T08:43:44+00:00

I’m working on using a Makefile to help perform build steps for my JS

  • 0

I’m working on using a Makefile to help perform build steps for my JS in my application. The goal is to use Make’s ability to only deal with modified files to prevent extraneous copying and such.

To build the JS you need to

  1. copy the original .js files from the main dev directory to a build directory
  2. minimize the copied file and create a -min.js version of the file
  3. generate a meta.js which has the information on the YUI modules in the built JS files for the combo loader.

So I’ve been working on the Makefile working backwards. meta.js depends on -min.js which depends on $builddir/b/*.js which is copied from %origdir/*.js

In looking through things it seems I should be able to use %.js in order to catch any matching files, but when I try this out I get:

  make: *** No rule to make target `bookie/static/js/build/b/%-min.js', needed by `bookie/static/js/build/b/meta.js'.  Stop.

This is what I’m working with, anyone know what I’m doing wrong? I want that when I make js it copies over the changed .js files, minifies them, and then regenerates the meta.js.

# Makefile to help automate tasks in bookie
WD := $(shell pwd)
PY := bin/python
BOOKIE_JS = bookie/static/js/bookie
JS_BUILD_PATH = bookie/static/js/build
JS_META_SCRIPT = $(PY) scripts/js/generate_meta.py

EXTENSION = $(WD)/extensions
CHROME_BUILD = $(EXTENSION)/chrome_ext/lib


# JAVASCRIPT
#
# Javascript tools for building out combo loader build directory, out meta.js,
# and syncing things over to the chrome extension directory.

.PHONY: js
js: $(JS_BUILD_PATH)/b/meta.js

$(JS_BUILD_PATH)/b/meta.js: $(JS_BUILD_PATH)/b/%-min.js
    echo "META"
    $(JS_META_SCRIPT) -n YUI_MODULES -s $(JS_BUILD_PATH)/b/ \
        -o $(JS_BUILD_PATH)/b/meta.js \
        -x -min.js$

$(JS_BUILD_PATH)/b/%-min.js: $(JS_BUILD_PATH)/b/$*.js
    echo "MIN"
    rm $(JS_BUILD_PATH)/b/meta.js || true
    scripts/js/jsmin_all.py $(JS_BUILD_PATH)/b

$(JS_BUILD_PATH)/b/%.js: $(BOOKIE_JS)/$*.js
    echo "Initial"
    cp $? $(JS_BUILD_PATH)/b/
    cp $? $(CHROME_BUILD)/

.PHONY: clean_js
clean_js:
    rm -rf $(JS_BUILD_PATH)/* || true
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T08:43:45+00:00Added an answer on June 1, 2026 at 8:43 am

    Make wildcards don’t work the way you think. Let’s start with this rule:

    $(JS_BUILD_PATH)/b/%.js: $(BOOKIE_JS)/$*.js
        echo "Initial"
        cp $? $(JS_BUILD_PATH)/b/
        cp $? $(CHROME_BUILD)/
    

    The % implies that it’s a pattern rule, so Make expects a corresponding % in the prerequisite list. Instead it looks as if you’re trying to use either the automatic variable $* (which can’t be used in the prerequisite list) or the wildcard * (which can’t be used without the wildcard command). Try it this way:

    $(JS_BUILD_PATH)/b/%.js: $(BOOKIE_JS)/%.js
        echo "Initial"
        cp $? $(JS_BUILD_PATH)/b/
        cp $? $(CHROME_BUILD)/
    

    This works, but only if you specify exactly which file(s) you want; it doesn’t copy every .js file in the dev directory (more on this later).

    Now for -min.js. I can’t tell exactly how this rule works, but it looks as if you run a python script that acts on all *.js files in the directory at once. If that’s correct, then it doesn’t make sense to have a rule that makes foo-min.js from foo.js; there should be a rule to run the script, and we need a list of all the .js files it will need:

    DEV_JS_FILES := $(wildcard $(BOOKIE_JS)/*.js)
    BUILD_JS_FILES := $(patsubst $(BOOKIE_JS)/%.js,$(JS_BUILD_PATH)/b/%.js,$(DEV_JS_FILES))
    
    .PHONY: min
    min: $(BUILD_JS_FILES)
        echo "MIN"
        rm $(JS_BUILD_PATH)/b/meta.js || true
        scripts/js/jsmin_all.py $(JS_BUILD_PATH)/b
    

    Finally, meta.js:

    $(JS_BUILD_PATH)/b/meta.js: min
            echo "META"
            $(JS_META_SCRIPT) -n YUI_MODULES -s $(JS_BUILD_PATH)/b/ \
            -o $(JS_BUILD_PATH)/b/meta.js \
            -x -min.js$
    

    EDIT:
    I think I see what you’re trying to do. There are a couple of ways to do it; the simplest is just to combine the three rules into one:

    DEV_JS_FILES := $(wildcard $(BOOKIE_JS)/*.js)
    
    $(JS_BUILD_PATH)/b/meta.js: $(DEV_JS_FILES)
        echo "Initial"
        cp $? $(JS_BUILD_PATH)/b/
        cp $? $(CHROME_BUILD)/
        echo "MIN"
        rm $(JS_BUILD_PATH)/b/meta.js || true
        scripts/js/jsmin_all.py $(JS_BUILD_PATH)/b
        rm $(addprefix $(JS_BUILD_PATH)/b/,$?)
        echo "META"
        $(JS_META_SCRIPT) -n YUI_MODULES -s $(JS_BUILD_PATH)/b/ \
      -o $(JS_BUILD_PATH)/b/meta.js \
      -x -min.js
        rm $(JS_BUILD_PATH)/b/*-min.js
    

    This will act only on the .js files in dev that are newer than meta.js (or all of them if meta.js doesn’t yet exist).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want use html5's new tag to play a wav file (currently only supported
We're building an app, our first using Rails 3, and we're having to build
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am trying to understand how to use SyndicationItem to display feed which is
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We are using XSLT to translate a RIXML file to XML. Our RIXML contains

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.