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

  • Home
  • SEARCH
  • 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 9008297
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T01:54:34+00:00 2026-06-16T01:54:34+00:00

I have a Makefile like this: baud=19200 src=dimmer avrType=attiny13 programmerDev=/dev/ttyUSB003 programmerType=stk500v1 object: avr-gcc -g

  • 0

I have a Makefile like this:

baud=19200
src=dimmer
avrType=attiny13
programmerDev=/dev/ttyUSB003
programmerType=stk500v1

object:
        avr-gcc -g -DF_CPU=$(avrFreq) -Wall -Os -mmcu=$(avrType) -c -o $(src).o $(src).cpp

read:
        @for memory in calibration eeprom efuse flash fuse hfuse lfuse lock signature application apptable boot prodsig usersig; do \
                avrdude -p $(avrType) -c$(programmerType) -P$(programmerDev) -b$(baud) -v -U $$memory:r:./$(avrType).$$memory.hex:i; \
        done

Which works as intended. When I type make read several files are extracted from the microcontroller. This can take a little while because of the slow connection and data size, so I was thinking it would be nice to be able to just type make read flash, but I can’t figure out how to do that.

Of course I can make entries like read_flash, read_hfuse … but I have a feeling it can be done smarter.

I also want to be able to run a command like make read all which will execute every file in turn from the controller.

Now I am new to creating Makfile’s, so maybe I am on the wrong track all together. Please feel free to explain how it should be done.

I am on Linux.

  • 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-16T01:54:35+00:00Added an answer on June 16, 2026 at 1:54 am

    If a highly GNU-specific makefile is acceptable to you (and I’d argue that it’s much better to use a portable make, such as GNU’s, than writing portable makefiles), you can implement this rather easily:

    ALL = calibration eeprom efuse flash fuse hfuse lfuse lock signature \
          application apptable boot prodsig usersig
    
    ifeq (read,$(firstword $(MAKECMDGOALS)))
      WANT := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS))
      ifneq ($(WANT),)
        $(eval $(WANT):;@:)
      endif
      UNKNOWN := $(filter-out $(ALL),$(WANT))
      ifneq ($(UNKNOWN),)
        $(error Invalid arguments: $(UNKNOWN))
      endif
    endif
    
    read-one = avrdude -p $(avrType) -c$(programmerType) -P$(programmerDev) \
            -b$(baud) -v -U $1:r:./$(avrType).$1.hex:i
    
    .PHONY: read
    read:
        $(foreach w,$(or $(WANT),$(ALL)),$(call read-one,$w) &&) :
    

    If the first argument in the command line is “read”, this sets the WANT variable to the list of arguments after the first. It then turns those names into no-op targets and makes the read target invoke the read-one function for each name, or for $(ALL) if no name was specified.

    I use variations of this quite often, for things like make print VARIABLE..., which will just print $(VARIABLE) or make help TOPIC to display information about a target.

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

Sidebar

Related Questions

I have a Makefile that looks like this CXX = g++ -O2 -Wall all:
I have a Makefile that looks something like this: sometarget: command_one # calls fork()
I have a makefile structured something like this: all : compile executable clean :
I have a Makefile.am file right now that looks like this: lib_LIBRARIES = foo.a
My project directory looks like this: /project Makefile main /src main.cpp foo.cpp foo.h bar.cpp
For example, I have something like this in my makefile: all: cd some_directory But
I have a makefile, with two variables like this OS = foo.o bar.o baz.o
I have a GNU Makefile that looks a bit like this: LIST = item1
I have Makefile like this: b: @echo b a: @echo a @make b I
I would like to have a makefile like this: cudaLib : # Create shared

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.