Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Some help on interpreting this makefile for linux...

Some help on interpreting this makefile for linux...

Scheduled Pinned Locked Moved C / C++ / MFC
helpcsharplinuxquestion
4 Posts 4 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    leslie wu
    wrote on last edited by
    #1

    Hello all, I got the following makefile for the GD Library (http://www.fred.net/brv/chart/gdchart0.94b.tar.gz[^] : GDC_INCL = . GD_INCL = gd1.3 GD_LIB = gd1.3 CC=gcc all: gdc_samp1 gdc_samp2 gdc_pie_samp # compile the samples gdc_samp1: gdc.o gdchart.o price_conv.o gdc_samp1.o $(GD_LIB)/libgd.a $(CC) -o gdc_samp1 gdc.o gdchart.o price_conv.o gdc_samp1.o -L$(GD_LIB) -lgd -lm gdc_samp1.o: $(GDC_INCL)/gdc.h $(GDC_INCL)/gdchart.h gdc_samp1.c $(CC) -I$(GDC_INCL) -c gdc_samp1.c gdc_samp2: gdc.o gdchart.o price_conv.o gdc_samp2.o $(GD_LIB)/libgd.a $(CC) -o gdc_samp2 gdc.o gdchart.o price_conv.o gdc_samp2.o -L$(GD_LIB) -lgd -lm gdc_samp2.o: $(GDC_INCL)/gdc.h $(GDC_INCL)/gdchart.h gdc_samp2.c $(CC) -I$(GDC_INCL) -c gdc_samp2.c gdc_pie_samp: gdc.o gdc_pie.o price_conv.o gdc_pie_samp.o $(GD_LIB)/libgd.a $(CC) -o gdc_pie_samp gdc.o gdc_pie.o price_conv.o gdc_pie_samp.o -L$(GD_LIB) -lgd -lm gdc_pie_samp.o: $(GDC_INCL)/gdc.h $(GDC_INCL)/gdcpie.h gdc_pie_samp.c $(CC) -I$(GDC_INCL) -c gdc_pie_samp.c # --- compile the lib --- price_conv.o: price_conv.c $(CC) -c price_conv.c gdc.o: gdc.c gdc.h $(CC) -I$(GD_INCL) -I$(GDC_INCL) -c gdc.c gdc_pie.o: $(GDC_INCL)/gdc.h $(GDC_INCL)/gdcpie.h gdc_pie.c $(CC) -I$(GD_INCL) -I$(GDC_INCL) -c gdc_pie.c gdchart.o: $(GDC_INCL)/gdc.h $(GDC_INCL)/gdchart.h gdchart.c $(CC) -I$(GD_INCL) -I$(GDC_INCL) -c gdchart.c $(GD_LIB)/libgd.a: cd $(GD_LIB) ; make -f Makefile libgd.a # --- clean --- clean: rm -f *.o gdc_samp1 gdc_samp2 gdc_pie_samp cd $(GD_LIB) ; make -f Makefile clean My problem is : 1. How did the make file compile and link the gdc_samp1.c file ? Really appreciated if anyone could have some answers ...I am a BIG NOOB in linkers... Thanks, Leslie

    S B CPalliniC 3 Replies Last reply
    0
    • L leslie wu

      Hello all, I got the following makefile for the GD Library (http://www.fred.net/brv/chart/gdchart0.94b.tar.gz[^] : GDC_INCL = . GD_INCL = gd1.3 GD_LIB = gd1.3 CC=gcc all: gdc_samp1 gdc_samp2 gdc_pie_samp # compile the samples gdc_samp1: gdc.o gdchart.o price_conv.o gdc_samp1.o $(GD_LIB)/libgd.a $(CC) -o gdc_samp1 gdc.o gdchart.o price_conv.o gdc_samp1.o -L$(GD_LIB) -lgd -lm gdc_samp1.o: $(GDC_INCL)/gdc.h $(GDC_INCL)/gdchart.h gdc_samp1.c $(CC) -I$(GDC_INCL) -c gdc_samp1.c gdc_samp2: gdc.o gdchart.o price_conv.o gdc_samp2.o $(GD_LIB)/libgd.a $(CC) -o gdc_samp2 gdc.o gdchart.o price_conv.o gdc_samp2.o -L$(GD_LIB) -lgd -lm gdc_samp2.o: $(GDC_INCL)/gdc.h $(GDC_INCL)/gdchart.h gdc_samp2.c $(CC) -I$(GDC_INCL) -c gdc_samp2.c gdc_pie_samp: gdc.o gdc_pie.o price_conv.o gdc_pie_samp.o $(GD_LIB)/libgd.a $(CC) -o gdc_pie_samp gdc.o gdc_pie.o price_conv.o gdc_pie_samp.o -L$(GD_LIB) -lgd -lm gdc_pie_samp.o: $(GDC_INCL)/gdc.h $(GDC_INCL)/gdcpie.h gdc_pie_samp.c $(CC) -I$(GDC_INCL) -c gdc_pie_samp.c # --- compile the lib --- price_conv.o: price_conv.c $(CC) -c price_conv.c gdc.o: gdc.c gdc.h $(CC) -I$(GD_INCL) -I$(GDC_INCL) -c gdc.c gdc_pie.o: $(GDC_INCL)/gdc.h $(GDC_INCL)/gdcpie.h gdc_pie.c $(CC) -I$(GD_INCL) -I$(GDC_INCL) -c gdc_pie.c gdchart.o: $(GDC_INCL)/gdc.h $(GDC_INCL)/gdchart.h gdchart.c $(CC) -I$(GD_INCL) -I$(GDC_INCL) -c gdchart.c $(GD_LIB)/libgd.a: cd $(GD_LIB) ; make -f Makefile libgd.a # --- clean --- clean: rm -f *.o gdc_samp1 gdc_samp2 gdc_pie_samp cd $(GD_LIB) ; make -f Makefile clean My problem is : 1. How did the make file compile and link the gdc_samp1.c file ? Really appreciated if anyone could have some answers ...I am a BIG NOOB in linkers... Thanks, Leslie

      S Offline
      S Offline
      Stuart Dootson
      wrote on last edited by
      #2

      It follows the rules from all -> gdc_samp1 -> gdc_samp1.o -> gdc_samp1.c. Just follow target dependencies to their associated targets, then follow those dependencies to their targets, until you get dependencies which have no corresponding target, at which point, either a) the file must exist, or b) there must be an implicit rule that knows how to make that file from some other file. Quite simple really. Here's a useful intro to Makefiles[^].

      Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

      1 Reply Last reply
      0
      • L leslie wu

        Hello all, I got the following makefile for the GD Library (http://www.fred.net/brv/chart/gdchart0.94b.tar.gz[^] : GDC_INCL = . GD_INCL = gd1.3 GD_LIB = gd1.3 CC=gcc all: gdc_samp1 gdc_samp2 gdc_pie_samp # compile the samples gdc_samp1: gdc.o gdchart.o price_conv.o gdc_samp1.o $(GD_LIB)/libgd.a $(CC) -o gdc_samp1 gdc.o gdchart.o price_conv.o gdc_samp1.o -L$(GD_LIB) -lgd -lm gdc_samp1.o: $(GDC_INCL)/gdc.h $(GDC_INCL)/gdchart.h gdc_samp1.c $(CC) -I$(GDC_INCL) -c gdc_samp1.c gdc_samp2: gdc.o gdchart.o price_conv.o gdc_samp2.o $(GD_LIB)/libgd.a $(CC) -o gdc_samp2 gdc.o gdchart.o price_conv.o gdc_samp2.o -L$(GD_LIB) -lgd -lm gdc_samp2.o: $(GDC_INCL)/gdc.h $(GDC_INCL)/gdchart.h gdc_samp2.c $(CC) -I$(GDC_INCL) -c gdc_samp2.c gdc_pie_samp: gdc.o gdc_pie.o price_conv.o gdc_pie_samp.o $(GD_LIB)/libgd.a $(CC) -o gdc_pie_samp gdc.o gdc_pie.o price_conv.o gdc_pie_samp.o -L$(GD_LIB) -lgd -lm gdc_pie_samp.o: $(GDC_INCL)/gdc.h $(GDC_INCL)/gdcpie.h gdc_pie_samp.c $(CC) -I$(GDC_INCL) -c gdc_pie_samp.c # --- compile the lib --- price_conv.o: price_conv.c $(CC) -c price_conv.c gdc.o: gdc.c gdc.h $(CC) -I$(GD_INCL) -I$(GDC_INCL) -c gdc.c gdc_pie.o: $(GDC_INCL)/gdc.h $(GDC_INCL)/gdcpie.h gdc_pie.c $(CC) -I$(GD_INCL) -I$(GDC_INCL) -c gdc_pie.c gdchart.o: $(GDC_INCL)/gdc.h $(GDC_INCL)/gdchart.h gdchart.c $(CC) -I$(GD_INCL) -I$(GDC_INCL) -c gdchart.c $(GD_LIB)/libgd.a: cd $(GD_LIB) ; make -f Makefile libgd.a # --- clean --- clean: rm -f *.o gdc_samp1 gdc_samp2 gdc_pie_samp cd $(GD_LIB) ; make -f Makefile clean My problem is : 1. How did the make file compile and link the gdc_samp1.c file ? Really appreciated if anyone could have some answers ...I am a BIG NOOB in linkers... Thanks, Leslie

        B Offline
        B Offline
        bolivar123
        wrote on last edited by
        #3

        Your question has little to do with linkers. Make files follow a fairly simple syntax: build_target1: dependency1.o dependency2.o build_target2 ....etc. commands to build the build target build_target2: command(s) needed to build this build target. So, looking at your make file: # compile the samples gdc_samp1: gdc.o gdchart.o price_conv.o gdc_samp1.o $(GD_LIB)/libgd.a $(CC) -o gdc_samp1 gdc.o gdchart.o price_conv.o gdc_samp1.o -L$(GD_LIB) -lgd -lm The build target "gdc_samp1:" is what defines all that is needed to make the gdc_samp1. So, make converts the line: $(CC) -o gdc_samp1 gdc.o gdchart.o price_conv.o gdc_samp1.o -L$(GD_LIB) -lgd -lm to: gcc -o gdc_samp1 gdc.o gdchart.o price_conv.o gdc_samp1.o -L$(GD_LIB) -lgd -lm For more info on make files: Clickety[^] Hope this helps

        1 Reply Last reply
        0
        • L leslie wu

          Hello all, I got the following makefile for the GD Library (http://www.fred.net/brv/chart/gdchart0.94b.tar.gz[^] : GDC_INCL = . GD_INCL = gd1.3 GD_LIB = gd1.3 CC=gcc all: gdc_samp1 gdc_samp2 gdc_pie_samp # compile the samples gdc_samp1: gdc.o gdchart.o price_conv.o gdc_samp1.o $(GD_LIB)/libgd.a $(CC) -o gdc_samp1 gdc.o gdchart.o price_conv.o gdc_samp1.o -L$(GD_LIB) -lgd -lm gdc_samp1.o: $(GDC_INCL)/gdc.h $(GDC_INCL)/gdchart.h gdc_samp1.c $(CC) -I$(GDC_INCL) -c gdc_samp1.c gdc_samp2: gdc.o gdchart.o price_conv.o gdc_samp2.o $(GD_LIB)/libgd.a $(CC) -o gdc_samp2 gdc.o gdchart.o price_conv.o gdc_samp2.o -L$(GD_LIB) -lgd -lm gdc_samp2.o: $(GDC_INCL)/gdc.h $(GDC_INCL)/gdchart.h gdc_samp2.c $(CC) -I$(GDC_INCL) -c gdc_samp2.c gdc_pie_samp: gdc.o gdc_pie.o price_conv.o gdc_pie_samp.o $(GD_LIB)/libgd.a $(CC) -o gdc_pie_samp gdc.o gdc_pie.o price_conv.o gdc_pie_samp.o -L$(GD_LIB) -lgd -lm gdc_pie_samp.o: $(GDC_INCL)/gdc.h $(GDC_INCL)/gdcpie.h gdc_pie_samp.c $(CC) -I$(GDC_INCL) -c gdc_pie_samp.c # --- compile the lib --- price_conv.o: price_conv.c $(CC) -c price_conv.c gdc.o: gdc.c gdc.h $(CC) -I$(GD_INCL) -I$(GDC_INCL) -c gdc.c gdc_pie.o: $(GDC_INCL)/gdc.h $(GDC_INCL)/gdcpie.h gdc_pie.c $(CC) -I$(GD_INCL) -I$(GDC_INCL) -c gdc_pie.c gdchart.o: $(GDC_INCL)/gdc.h $(GDC_INCL)/gdchart.h gdchart.c $(CC) -I$(GD_INCL) -I$(GDC_INCL) -c gdchart.c $(GD_LIB)/libgd.a: cd $(GD_LIB) ; make -f Makefile libgd.a # --- clean --- clean: rm -f *.o gdc_samp1 gdc_samp2 gdc_pie_samp cd $(GD_LIB) ; make -f Makefile clean My problem is : 1. How did the make file compile and link the gdc_samp1.c file ? Really appreciated if anyone could have some answers ...I am a BIG NOOB in linkers... Thanks, Leslie

          CPalliniC Offline
          CPalliniC Offline
          CPallini
          wrote on last edited by
          #4

          The GNU Make Manual. :)

          If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
          This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
          [My articles]

          In testa che avete, signor di Ceprano?

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups