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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T20:33:16+00:00 2026-05-28T20:33:16+00:00

i have created a Makefile which i would change so, that it will generate

  • 0

i have created a Makefile which i would change so, that it will generate more then one target when i run make.

In my program i use self predefined macros (e.g. TIME, REG and _DEBUG ) and i would like to have my Makefile i that way that it will generate one target with out predefined macros, one with REG and another one with REG and TIME.

I hope that what i wish is a reasonable wish from Makefile, if not, then please let me know.

P.S.:

recommendations would be gladly excepted

I am using
Here is my Makefile:

CXX = g++
SOURCES = random.cpp
OBJECTS = $(SOURCES:.cpp=.o) 
EXECUTABLE = random-64bit
DEBUG = -g -p -ggdb
CXXFLAGS = -Wall -ansi -pedantic -W -pipe -O3 -std=gnu++0x -march=native \
    --fast-math -ftree-vectorize -ffast-math -D NDEBUG \
    -D TIME -D REG -D _DEBUG
#CXXFLAGS+=$(DEBUG)
DEPS = def_type.hpp \
    ls_regression.hpp \
    network.hpp \
    statistics.hpp \
    knot.hpp \
    nachbarn.hpp \
    $(SOURCES:.cpp=.hpp) \
    zufallszahlengenerator.hpp 
INCLUDES = -I/home/phymihsa/eigen/ -I/home/phymihsa/boost_1_48_0
LIBPATH = -L/usr/local/lib64
LDFLAGS = -lm

all: $(SOURCES) $(EXECUTABLE) 

$(EXECUTABLE): $(OBJECTS) $(DEPS) 
    $(CXX) $(LIBPATH) $(OBJECTS) -o $@

.cpp.o: $<
    $(CXX) $(LIBPATH) $(INCLUDES) $(LDFLAGS) $(CXXFLAGS) -c $<

%.o: %.cpp
    $(CXX) $(LIBPATH) $(INCLUDES) $(LDFLAGS) $(CXXFLAGS) -c $<


.PHONY: clean

clean:
    rm -rf $(OBJECTS) $(EXECUTABLE) *~ p1 *.o 

EDIT

Based on the answer of @trojanfoe, i would to know if it is possible to use arrays

OBJECTS = $(SOURCES:.cpp=_none.o) $(SOURCES:.cpp=_reg.o) $(SOURCES:.cpp=_reg_time.o)
EXECUTABLE = $(SOURCES:.cpp=_none) $(SOURCES:.cpp=_reg) $(SOURCES:.cpp=_reg_time)

instead of each one writing each one specific?

  • 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-28T20:33:18+00:00Added an answer on May 28, 2026 at 8:33 pm

    Here is what i was searching for:

    CXX = g++
    OPTIONS := none reg reg_inter reg_time
        none_CXXFLAGS  :=
         reg_CXXFLAGS  := -D REG
    reg_inter_CXXFLAGS := $(reg_CXXFLAGS) -D INTERMEDIATE_STEP
     reg_time_CXXFLAGS := $(reg_CXXFLAGS) -D TIME
    EXECUTABLES = $(addprefix random_,$(OPTIONS))
    DEBUG = -g3 -p -ggdb
    CXXFLAGS = -Wall -ansi -pedantic -W -pipe -O3 -std=gnu++0x -march=core2 -mtune=core2 \
               --fast-math -ftree-vectorize -ffast-math -D NDEBUG
    CXXFLAGS+=$(DEBUG)
    DEPS = def_type.hpp \
           ls_regression.hpp \
           network.hpp \
           statistics.hpp \
           knot.hpp \
           nachbarn.hpp \
           zufallszahlengenerator.hpp
    INCFLAGS = -I/usr/include/eigen3 -I/usr/include/boost_1_48
    LIBPATH = -L/usr/lib64
    LDFLAGS = -lm
    
    .PHONY: all
    all: $(EXECUTABLES)
    
    random_%: random_%.o
        $(CXX) $(LDFLAGS) $(LIBPATH) $^ -o $@
    
    random_%.o : random.cpp $(DEPS)
        $(CXX) $(INCFLAGS) $(CXXFLAGS) $($*_CXXFLAGS) -c $< -o $@
    
    .PHONY: clean
    clean:
        rm -rf $(OBJECTS) $(EXECUTABLES) *~ p1 *.o
    

    in this solution there is a use of variables instead of writing each time the all text

    regards

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

Sidebar

Related Questions

I have a data directory which I would like automake to generate install and
I have one set of source files from which I need to generate multiple
I have a Makefile where most of my targets are created generically through a
we have some C++ code that we need to create a make file in.
I have created a PHP-script to update a web server that is live inside
I have created a UserControl that has a ListView in it. The ListView is
I have created a few small flash widgets that stream .mp3 audio from an
i have created a workflow activity that do give the item creater of a
I would like to create a Makefile which also creates a simple script for
I'd like to create a Makefile.am file which generates one header file mentioned in

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.