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 5944375
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T16:31:43+00:00 2026-05-22T16:31:43+00:00

I’ve been working on a makefile with parametrized targets. On my OpenSUSE PC, it

  • 0

I’ve been working on a makefile with parametrized targets. On my OpenSUSE PC, it runs successfully when given make all, but (strangely) runs a clean instead of a make all if you only provide make with no extra arguments. Worse, on my Ubuntu PC, make all doesn’t work at all, and from browsing through make -pn all | less, all isn’t even being generated as a target.

Clearly I’m doing something wrong when generating the all target. Here is the makefile:

# To see predefined preprocessor macros:
# gcc -dM -E - < /dev/null | sort | less

# After a default installation of opencc, you might need to run:
# sudo ln -s /opt/x86_open64-4.2.5/lib/gcc-lib /usr/lib/gcc-lib

allflags = -Wall -pipe
cflags   = -std=c99
cxxflags =

flags_O0 = -O0 -ggdb
flags_O1 = -O1
flags_O2 = -O2
flags_O3 = -O3 -fomit-frame-pointer

flags_opt_gcc    = -march=native -s
flags_opt_icc    = -march=native -s
flags_opt_opencc = -march=auto -s
flags_opt_clang  = -march=native

ldflags_O0 = $(cflags_O0)
ldflags_O1 = $(cflags_O1) -Wl,-s -Wl,-O,1
ldflags_O2 = $(cflags_O2) -Wl,-s -Wl,-O,2
ldflags_O3 = $(cflags_O3) -Wl,-s -Wl,-O,3

define dcompiler =
version-$(1):
    $(1) --version 2>&1 | sed 's/.*/"&\\n"/' > $$@
flags_$(1)_O0 = $$(allflags) $$(flags_O0) $$(flags_$(1))
flags_$(1)_O1 = $$(allflags) $$(flags_O1) $$(flags_$(1)) $$(flags_opt_$(1))
flags_$(1)_O2 = $$(allflags) $$(flags_O2) $$(flags_$(1)) $$(flags_opt_$(1))
flags_$(1)_O3 = $$(allflags) $$(flags_O3) $$(flags_$(1)) $$(flags_opt_$(1))
$$(eval $$(call diter,$(1),O0))
$$(eval $$(call diter,$(1),O1))
$$(eval $$(call diter,$(1),O2))
$$(eval $$(call diter,$(1),O3))
endef

define dimpaler =
cc_impaler_$(2) = gcc $$(flags_gcc_$(2)) $$(cflags)
all: impaler$(1)
impaler$(1): impaler$(1).o util$(1).o
    $$(cc_impaler_$(2)) -o $$@ $$^ $$(ldflags_$(2)) -ldl -lm -lpopt
impaler$(1).o: impaler.c impaler.h util.h makefile
    $$(cc_impaler_$(2)) -o $$@ $$< -c
util$(1).o: util.c util.h makefile
    $$(cc_impaler_$(2)) -o $$@ $$< -c
clean::
    rm -f impaler$(1)
endef

define diter =
cc_iters_$(1)_$(2) = $(1) $$(flags_$(1)_$(2))
all: iters-$(1)-$(2).so
iters-$(1)-$(2).so: iters-$(1)-$(2).c.o iters-$(1)-$(2).cpp.o
    $$(cc_iters_$(1)_$(2)) -o $$@ $$^ -shared $$(ldflags_$(2))
iters-$(1)-$(2).c.o: iters.c impaler.h version-$(1) makefile
    $$(cc_iters_$(1)_$(2)) $$(cflags) -o $$@ $$< -c
iters-$(1)-$(2).cpp.o: iters.cpp impaler.h version-$(1) makefile
    $$(cc_iters_$(1)_$(2)) $$(cxxflags) -o $$@ $$< -c
endef

clean::
    rm -f *.o *.so version-*

$(eval $(call dimpaler,-debug,O0))
$(eval $(call dimpaler,,O3))
$(eval $(call dcompiler,gcc))
$(eval $(call dcompiler,icc))
$(eval $(call dcompiler,opencc))
$(eval $(call dcompiler,clang))

Any hints would be appreciated. Thanks.


Edit:

Even when I reduce the makefile to the following:

define dimpaler =
all: impaler
impaler: impaler.o
    gcc -o $$@ $$^
impaler.o: impaler.c
    gcc -o $$@ $$< -c
endef

$(eval $(call dimpaler))

“all” is still not generated.


Edit:

Contrary to the very clearly explained syntax in http://www.gnu.org/software/make/manual/make.html#Reading-Makefiles , apparently adding an = after a define makes everything silently fail, and omitting the = makes the makefile behave better.

Now I’m left with the other problem: make all works, but make doesn’t.

  • 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-05-22T16:31:44+00:00Added an answer on May 22, 2026 at 4:31 pm

    As you said, removing the = after the define makes it work better. It may be a change in how the = is handled in define.

    As for the other problem, make doesn’t work because all is not defined as the first rule. Try adding an empty all: rule at the beginning. There should be also a way of establishing the default target rule, but I’ll look into the documentation as I don’t remember it right now.

    Edit:

    Seems to be the variable .DEFAULT_TARGET.

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

Sidebar

Related Questions

I need to clean up various Word 'smart' characters in user input, including but
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
I need a function that will clean a strings' special characters. I do NOT

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.