How to write a makefile with multiple targets and multiple sources?How do JavaScript closures work?What is the difference between the GNU Makefile variable assignments =, ?=, := and +=?How do you check if a variable is an array in JavaScript?How to symlink a file in Linux?What is the purpose of .PHONY in a makefile?How to determine if variable is 'undefined' or 'null'?How do I find all files containing specific text on Linux?Change directory in makefile for main shellMakefile improvements: several executables & directoriesMakefiles, targets as dependencies

Way of the bicycle

Where are they calling from?

Did Apollo carry and use WD40?

Why does NASA publish all the results/data it gets?

Is there a scenario where a gnoll flesh gnawer can move at least 45 feet during its Rampage bonus action?

Hiking with a mule or two?

Is it right to extend flaps only in the white arc?

Norwegian refuses EU delay (4.7 hours) compensation because it turned out there was nothing wrong with the aircraft

California Emission Standards

Do all creatures have souls?

What happens if nobody can form a government in Israel?

How use custom order in folder on Windows 7 and 10

Is the mass of paint relevant in rocket design?

Is it true that, "just ten trading days represent 63 per cent of the returns of the past 50 years"?

Will Proving or Disproving of any of the following have effects on Chemistry in general?

Allocating credit card points

Worms crawling under skin

Is it a good idea to leave minor world details to the reader's imagination?

Is it really necessary to have a four hour meeting in Sprint planning?

How can I repair this gas leak on my new range? Teflon tape isn't working

Can this word order be rearranged?

If an object moving in a circle experiences centripetal force, then doesn't it also experience centrifugal force, because of Newton's third law?

Idiom for "I came, I saw, I ate" (or drank)

How to make interviewee comfortable interviewing in lounge chairs



How to write a makefile with multiple targets and multiple sources?


How do JavaScript closures work?What is the difference between the GNU Makefile variable assignments =, ?=, := and +=?How do you check if a variable is an array in JavaScript?How to symlink a file in Linux?What is the purpose of .PHONY in a makefile?How to determine if variable is 'undefined' or 'null'?How do I find all files containing specific text on Linux?Change directory in makefile for main shellMakefile improvements: several executables & directoriesMakefiles, targets as dependencies






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








1















I'm learning how to write makefiles and would like to create a makefile that can create multiple targets from multiple sources according to a given argument.



Here is what I tried so far:



# Compiler and others
CC=gcc

# Flags
CFLAGS = -g -c -Wall -DLOGFILE -D_REENTRANT

target1_EXEC = ../build/target1
target2_EXEC = ../build/target2

target1_SRC = ../source/target1
target2_SRC = ../source/target2

target1: TARGET=target1
target1: all

target2: TARGET=target2
target2: all

EXEC=$($(TARGET)_EXEC)
SRC=$($(TARGET)_SRC)
OBJ=$(SRC:.c=.o)

all: $(EXEC)

$(EXEC): $(OBJ)
$(CC) $(INCLUDES) -o $@ $^ $(LDFLAGS) $(LIBS)

%.o: %.c
$(CC) -o $@ -c $< $(CFLAGS)


I would like to call the makefile with the target as an argument:



makefile target1


But then it seems that it does not find the subtarget:



make: Nothing to be done for 'target1'.


What am I doing wrong ?










share|improve this question






























    1















    I'm learning how to write makefiles and would like to create a makefile that can create multiple targets from multiple sources according to a given argument.



    Here is what I tried so far:



    # Compiler and others
    CC=gcc

    # Flags
    CFLAGS = -g -c -Wall -DLOGFILE -D_REENTRANT

    target1_EXEC = ../build/target1
    target2_EXEC = ../build/target2

    target1_SRC = ../source/target1
    target2_SRC = ../source/target2

    target1: TARGET=target1
    target1: all

    target2: TARGET=target2
    target2: all

    EXEC=$($(TARGET)_EXEC)
    SRC=$($(TARGET)_SRC)
    OBJ=$(SRC:.c=.o)

    all: $(EXEC)

    $(EXEC): $(OBJ)
    $(CC) $(INCLUDES) -o $@ $^ $(LDFLAGS) $(LIBS)

    %.o: %.c
    $(CC) -o $@ -c $< $(CFLAGS)


    I would like to call the makefile with the target as an argument:



    makefile target1


    But then it seems that it does not find the subtarget:



    make: Nothing to be done for 'target1'.


    What am I doing wrong ?










    share|improve this question


























      1












      1








      1








      I'm learning how to write makefiles and would like to create a makefile that can create multiple targets from multiple sources according to a given argument.



      Here is what I tried so far:



      # Compiler and others
      CC=gcc

      # Flags
      CFLAGS = -g -c -Wall -DLOGFILE -D_REENTRANT

      target1_EXEC = ../build/target1
      target2_EXEC = ../build/target2

      target1_SRC = ../source/target1
      target2_SRC = ../source/target2

      target1: TARGET=target1
      target1: all

      target2: TARGET=target2
      target2: all

      EXEC=$($(TARGET)_EXEC)
      SRC=$($(TARGET)_SRC)
      OBJ=$(SRC:.c=.o)

      all: $(EXEC)

      $(EXEC): $(OBJ)
      $(CC) $(INCLUDES) -o $@ $^ $(LDFLAGS) $(LIBS)

      %.o: %.c
      $(CC) -o $@ -c $< $(CFLAGS)


      I would like to call the makefile with the target as an argument:



      makefile target1


      But then it seems that it does not find the subtarget:



      make: Nothing to be done for 'target1'.


      What am I doing wrong ?










      share|improve this question














      I'm learning how to write makefiles and would like to create a makefile that can create multiple targets from multiple sources according to a given argument.



      Here is what I tried so far:



      # Compiler and others
      CC=gcc

      # Flags
      CFLAGS = -g -c -Wall -DLOGFILE -D_REENTRANT

      target1_EXEC = ../build/target1
      target2_EXEC = ../build/target2

      target1_SRC = ../source/target1
      target2_SRC = ../source/target2

      target1: TARGET=target1
      target1: all

      target2: TARGET=target2
      target2: all

      EXEC=$($(TARGET)_EXEC)
      SRC=$($(TARGET)_SRC)
      OBJ=$(SRC:.c=.o)

      all: $(EXEC)

      $(EXEC): $(OBJ)
      $(CC) $(INCLUDES) -o $@ $^ $(LDFLAGS) $(LIBS)

      %.o: %.c
      $(CC) -o $@ -c $< $(CFLAGS)


      I would like to call the makefile with the target as an argument:



      makefile target1


      But then it seems that it does not find the subtarget:



      make: Nothing to be done for 'target1'.


      What am I doing wrong ?







      linux variables makefile






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 28 at 15:07









      user3923073user3923073

      516 bronze badges




      516 bronze badges

























          0






          active

          oldest

          votes














          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );














          draft saved

          draft discarded
















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55400935%2fhow-to-write-a-makefile-with-multiple-targets-and-multiple-sources%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          draft saved

          draft discarded















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55400935%2fhow-to-write-a-makefile-with-multiple-targets-and-multiple-sources%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

          SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

          은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현